-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement postgres optimization (#1305)
* Refactor backups * Add db migration scripts * Update db configuration
- Loading branch information
1 parent
27ca9c2
commit 2cd6105
Showing
12 changed files
with
145 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
SET max_parallel_workers_per_gather TO 4; | ||
SET max_parallel_workers_per_gather TO 4; | ||
-- PG doesn't support ALTER DATABASE CURRENT, and the db name is different between local/staging/production | ||
-- So we have to execute using variable subsitution | ||
DO $$ | ||
BEGIN | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET default_statistics_target = 1000'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET enable_partitionwise_aggregate = on'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET enable_partitionwise_join = on'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET max_parallel_workers_per_gather = 8'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET max_parallel_workers = 16'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET max_parallel_maintenance_workers = 8'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET jit = on'; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET idle_in_transaction_session_timeout = ''1min'''; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET lock_timeout = ''1min'''; | ||
EXECUTE 'ALTER DATABASE ' || current_database() || ' SET statement_timeout = ''30s'''; | ||
END | ||
$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE "upload" ADD COLUMN IF NOT EXISTS "backup_urls" TEXT[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
UPDATE "upload" SET "backup_urls" = (SELECT array_agg("url") FROM "backup" WHERE "upload_id" = "upload"."id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.