-
Notifications
You must be signed in to change notification settings - Fork 0
Use tx-pooler for pg connection and add index #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| DROP INDEX CONCURRENTLY IF EXISTS idx_records_user_revision; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_records_user_revision ON records (user_id, revision); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,9 +56,19 @@ func NewPersistentSyncerServer(config *config.Config) (*PersistentSyncerServer, | |
| var storage store.SyncStorage | ||
| var err error | ||
|
|
||
| if config.PgDatabaseUrl != "" { | ||
| if config.PgRuntimeUrl != "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we're the only users of data-sync, but do you think it maybe safer to fail fast if (the old) DATABASE_URL is set and DATABASE_RUNTIME_URL not set?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will change the semantic of which data source to use. I honestly think it is ok and it will allow us rollback fast if needed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern is more for other users of it, on update if they don't change their env config they'll switch into sqlite storage |
||
| log.Printf("creating postgres storage\n") | ||
| storage, err = postgres.NewPGSyncStorage(config.PgDatabaseUrl) | ||
| // DATABASE_MIGRATION_URL is optional; when unset we run migrations over the | ||
| // runtime URL. Set it when the runtime URL points at a transaction-mode | ||
| // pooler (e.g. Supavisor :6543), since golang-migrate needs a session. | ||
| migrationURL := config.PgMigrationUrl | ||
| if migrationURL == "" { | ||
| log.Println("DATABASE_MIGRATION_URL not set; running migrations over DATABASE_RUNTIME_URL. " + | ||
| "If the runtime URL points at a transaction-mode pooler, migrations might fail — " + | ||
| "set DATABASE_MIGRATION_URL to a session-mode or direct URL.") | ||
| migrationURL = config.PgRuntimeUrl | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we log a warning that the DATABASE_RUNTIME_URL will be used?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added log. |
||
| } | ||
| storage, err = postgres.NewPGSyncStorage(config.PgRuntimeUrl, migrationURL, config.PgMaxConns) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to change this index? I'm asking because the query performance advisor doesn't flag this as a suggestion. It does suggest these for about 5% performance gain.
and