From 706277085ab4832233ca8fc4ada3f92e32957b9d Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 15 Aug 2024 21:57:41 +0800 Subject: [PATCH] perf: add index on labels columns to library_item table --- .../migrations/0186.do.labels_index_on_library_item.sql | 5 +++++ .../0186.undo.labels_index_on_library_item.sql | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100755 packages/db/migrations/0186.do.labels_index_on_library_item.sql create mode 100755 packages/db/migrations/0186.undo.labels_index_on_library_item.sql diff --git a/packages/db/migrations/0186.do.labels_index_on_library_item.sql b/packages/db/migrations/0186.do.labels_index_on_library_item.sql new file mode 100755 index 000000000..fee9f5f81 --- /dev/null +++ b/packages/db/migrations/0186.do.labels_index_on_library_item.sql @@ -0,0 +1,5 @@ +-- Type: DO +-- Name: labels_index_on_library_item +-- Description: Add index on labels columns to library_item tables for better performance + +CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_library_item_state_label_names ON omnivore.library_item USING GIN (lower(array_cat(label_names, highlight_labels)::text)); diff --git a/packages/db/migrations/0186.undo.labels_index_on_library_item.sql b/packages/db/migrations/0186.undo.labels_index_on_library_item.sql new file mode 100755 index 000000000..fb37d783a --- /dev/null +++ b/packages/db/migrations/0186.undo.labels_index_on_library_item.sql @@ -0,0 +1,9 @@ +-- Type: UNDO +-- Name: more_index_on_library_item +-- Description: Add index on labels columns to library_item tables for better performance + +BEGIN; + +DROP INDEX IF EXISTS idx_library_item_state_label_names; + +COMMIT;