add index for sorting by word_count

This commit is contained in:
Hongbo Wu
2024-01-10 17:34:54 +08:00
parent 525b3fbacf
commit cf6f15e520
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,6 @@
-- Type: DO
-- Name: library_item_user_id_word_count_idx
-- Description: Add library_item_user_id_word_count_idx index on library_item table for user_id and word_count
-- create index for sorting concurrently to avoid locking
CREATE INDEX CONCURRENTLY IF NOT EXISTS library_item_user_id_word_count_idx ON omnivore.library_item (user_id, word_count DESC NULLS LAST);

View File

@ -0,0 +1,9 @@
-- Type: UNDO
-- Name: library_item_user_id_word_count_idx
-- Description: Add library_item_user_id_word_count_idx index on library_item table for user_id and word_count
BEGIN;
DROP INDEX IF EXISTS library_item_user_id_word_count_idx;
COMMIT;