From 453889066f325016e40ea4cf1d189403b00a2122 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:05:04 -0700 Subject: [PATCH 1/8] Remove first two unused indexes --- .../20240419172419_remove-unused-indexes-pt-1.down.sql | 5 +++++ .../20240419172419_remove-unused-indexes-pt-1.up.sql | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql create mode 100644 pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql new file mode 100644 index 00000000..325ca56d --- /dev/null +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql @@ -0,0 +1,5 @@ +SET statement_timeout = 0; + +--bun:split + +CREATE INDEX CONCURRENTLY IF NOT EXISTS message_pubsubTopic_idx ON public.message (pubsubTopic); diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql new file mode 100644 index 00000000..ae80d4a6 --- /dev/null +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql @@ -0,0 +1,4 @@ +SET statement_timeout = 0; + +DROP INDEX CONCURRENTLY IF EXISTS messageindex; +DROP INDEX CONCURRENTLY IF EXISTS message_pubsubtopic_idx; From 6107c1e59bbe82b0a3181655d9754554173556bb Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:34:44 -0700 Subject: [PATCH 2/8] Don't make it concurrent --- .../20240419172419_remove-unused-indexes-pt-1.up.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql index ae80d4a6..ee817f0a 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql @@ -1,4 +1,5 @@ SET statement_timeout = 0; -DROP INDEX CONCURRENTLY IF EXISTS messageindex; -DROP INDEX CONCURRENTLY IF EXISTS message_pubsubtopic_idx; +-- bun:split + +DROP INDEX IF EXISTS message_pubsubtopic_idx; From 0d3000ecbe59d99d4d7098db772615af82960816 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:39:18 -0700 Subject: [PATCH 3/8] Just use select 1 for down --- .../messages/20240419172419_remove-unused-indexes-pt-1.down.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql index 325ca56d..2e613610 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql @@ -2,4 +2,4 @@ SET statement_timeout = 0; --bun:split -CREATE INDEX CONCURRENTLY IF NOT EXISTS message_pubsubTopic_idx ON public.message (pubsubTopic); +SELECT 1; From f7d71b26038acfa13deb4b4fbdc1fdf900231d9a Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:12:14 -0700 Subject: [PATCH 4/8] Drop sort index too --- .../messages/20240419172419_remove-unused-indexes-pt-1.up.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql index ee817f0a..92317603 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql @@ -3,3 +3,7 @@ SET statement_timeout = 0; -- bun:split DROP INDEX IF EXISTS message_pubsubtopic_idx; + +-- bun:split + +DROP INDEX IF EXISTS message_sort_idx; \ No newline at end of file From a0646c6fa00e80d1e6cc15a1789d80134c5fd65c Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 9 May 2024 09:14:24 -0700 Subject: [PATCH 5/8] Update PR --- .../20240419172419_remove-unused-indexes-pt-1.up.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql index 92317603..d6274815 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql @@ -1,9 +1,16 @@ SET statement_timeout = 0; -- bun:split - DROP INDEX IF EXISTS message_pubsubtopic_idx; -- bun:split +DROP INDEX IF EXISTS message_sort_idx; + +-- bun:split +DROP INDEX IF EXISTS message_recvts_shouldexpire_idx; + +-- bun:split +-- Replace recvts_shouldexpire_idx with an index just on receiver timestamp +-- This index is used in our data pipelines to power the data warehouse for high level analytics on network growth +CREATE INDEX CONCURRENTLY IF NOT EXISTS message_receivertimestamp_idx ON public.message(receiverTimestamp); -DROP INDEX IF EXISTS message_sort_idx; \ No newline at end of file From 861eb304087709ab80dcb9c85603575425e97394 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 9 May 2024 13:04:00 -0700 Subject: [PATCH 6/8] Rename migration --- ...t-1.down.sql => 20240419172419_remove-unused-indexes.down.sql} | 0 ...es-pt-1.up.sql => 20240419172419_remove-unused-indexes.up.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename pkg/migrations/messages/{20240419172419_remove-unused-indexes-pt-1.down.sql => 20240419172419_remove-unused-indexes.down.sql} (100%) rename pkg/migrations/messages/{20240419172419_remove-unused-indexes-pt-1.up.sql => 20240419172419_remove-unused-indexes.up.sql} (100%) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes.down.sql similarity index 100% rename from pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.down.sql rename to pkg/migrations/messages/20240419172419_remove-unused-indexes.down.sql diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql similarity index 100% rename from pkg/migrations/messages/20240419172419_remove-unused-indexes-pt-1.up.sql rename to pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql From bd183b392cd0cc7f06d1d892cc284bb2acb266b4 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 9 May 2024 13:08:16 -0700 Subject: [PATCH 7/8] Remove if not exists --- .../messages/20240419172419_remove-unused-indexes.down.sql | 2 +- .../messages/20240419172419_remove-unused-indexes.up.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes.down.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes.down.sql index 2e613610..04c5e832 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes.down.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes.down.sql @@ -1,5 +1,5 @@ SET statement_timeout = 0; --bun:split +DROP INDEX CONCURRENTLY message_receivertimestamp_idx; -SELECT 1; diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql index d6274815..5b805f0e 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql @@ -12,5 +12,5 @@ DROP INDEX IF EXISTS message_recvts_shouldexpire_idx; -- bun:split -- Replace recvts_shouldexpire_idx with an index just on receiver timestamp -- This index is used in our data pipelines to power the data warehouse for high level analytics on network growth -CREATE INDEX CONCURRENTLY IF NOT EXISTS message_receivertimestamp_idx ON public.message(receiverTimestamp); +CREATE INDEX CONCURRENTLY message_receivertimestamp_idx ON public.message(receiverTimestamp); From b51c45892e86df087f7d187e0c57dd0dab8ceb35 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 9 May 2024 14:56:23 -0700 Subject: [PATCH 8/8] Fix splitting --- .../20240419172419_remove-unused-indexes.up.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql b/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql index 5b805f0e..06d98c4b 100644 --- a/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql +++ b/pkg/migrations/messages/20240419172419_remove-unused-indexes.up.sql @@ -1,16 +1,16 @@ SET statement_timeout = 0; --- bun:split +--bun:split DROP INDEX IF EXISTS message_pubsubtopic_idx; --- bun:split +--bun:split DROP INDEX IF EXISTS message_sort_idx; --- bun:split +--bun:split DROP INDEX IF EXISTS message_recvts_shouldexpire_idx; --- bun:split +--bun:split -- Replace recvts_shouldexpire_idx with an index just on receiver timestamp -- This index is used in our data pipelines to power the data warehouse for high level analytics on network growth -CREATE INDEX CONCURRENTLY message_receivertimestamp_idx ON public.message(receiverTimestamp); +CREATE INDEX CONCURRENTLY IF NOT EXISTS message_receivertimestamp_idx ON public.message(receiverTimestamp);