From 001caffba64b2c010f33f4a896d94802aeac5bdd Mon Sep 17 00:00:00 2001 From: sjdonado Date: Tue, 18 Mar 2025 07:46:18 +0100 Subject: [PATCH] feat: performance improvement replace slug index with covering index --- ...18072657_replace_slug_index_with_covering_index.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 db/migrations/20250318072657_replace_slug_index_with_covering_index.sql diff --git a/db/migrations/20250318072657_replace_slug_index_with_covering_index.sql b/db/migrations/20250318072657_replace_slug_index_with_covering_index.sql new file mode 100644 index 0000000..78e3db6 --- /dev/null +++ b/db/migrations/20250318072657_replace_slug_index_with_covering_index.sql @@ -0,0 +1,10 @@ +-- +micrate Up +-- SQL in section 'Up' is executed when this migration is applied +DROP INDEX IF EXISTS index_links_slug; +-- Create the new covering index that includes id and url +CREATE INDEX IF NOT EXISTS idx_links_slug ON links (id, slug, url); + +-- +micrate Down +-- SQL in section 'Down' is executed when this migration is rolled back +DROP INDEX IF EXISTS idx_links_slug; +CREATE INDEX IF NOT EXISTS index_links_slug ON links (slug);