From a71e7f79065906383fa2eb5a6ad2969df0db86cb Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 6 Feb 2024 11:47:20 +0100 Subject: [PATCH] :sparkles: Remove partitioning from task table Which causes strange random delays when some row is moved from one partition to other. Also, there are evidences that partitioning is not aporting real value here. --- backend/src/app/migrations.clj | 5 ++++- .../src/app/migrations/sql/0118-mod-task-table.sql | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 backend/src/app/migrations/sql/0118-mod-task-table.sql diff --git a/backend/src/app/migrations.clj b/backend/src/app/migrations.clj index 900ef75f5..9cfcf9fe2 100644 --- a/backend/src/app/migrations.clj +++ b/backend/src/app/migrations.clj @@ -370,7 +370,10 @@ :fn (mg/resource "app/migrations/sql/0116-mod-file-table.sql")} {:name "0117-mod-file-object-thumbnail-table" - :fn (mg/resource "app/migrations/sql/0117-mod-file-object-thumbnail-table.sql")}]) + :fn (mg/resource "app/migrations/sql/0117-mod-file-object-thumbnail-table.sql")} + + {:name "0118-mod-task-table" + :fn (mg/resource "app/migrations/sql/0118-mod-task-table.sql")}]) (defn apply-migrations! [pool name migrations] diff --git a/backend/src/app/migrations/sql/0118-mod-task-table.sql b/backend/src/app/migrations/sql/0118-mod-task-table.sql new file mode 100644 index 000000000..d6ede0e97 --- /dev/null +++ b/backend/src/app/migrations/sql/0118-mod-task-table.sql @@ -0,0 +1,12 @@ +-- Removes the partitioning. +CREATE TABLE new_task (LIKE task INCLUDING ALL); +INSERT INTO new_task SELECT * FROM task; +ALTER TABLE task RENAME TO old_task; +ALTER TABLE new_task RENAME TO task; +DROP TABLE old_task; +ALTER INDEX new_task_label_name_queue_idx RENAME TO task__label_name_queue__idx; +ALTER INDEX new_task_scheduled_at_queue_idx RENAME TO task__scheduled_at_queue__idx; +ALTER TABLE task DROP CONSTRAINT new_task_pkey; +ALTER TABLE task ADD PRIMARY KEY (id); +ALTER TABLE task ALTER COLUMN created_at SET DEFAULT now(); +ALTER TABLE task ALTER COLUMN modified_at SET DEFAULT now();