From c4db34c0e915c9e834f0b0a20edd689fc1f10f58 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 19 Sep 2019 15:12:43 -0400 Subject: [PATCH] Add indexes in migrations that have already been running in production @sgrif added these to the production database by hand for testing purposes a while back; they seem to be performing well so they should get added to the codebase to keep the schema in sync. --- .../2019-09-19-185655_add_experimental_indexes/down.sql | 2 ++ .../2019-09-19-185655_add_experimental_indexes/up.sql | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 migrations/2019-09-19-185655_add_experimental_indexes/down.sql create mode 100644 migrations/2019-09-19-185655_add_experimental_indexes/up.sql diff --git a/migrations/2019-09-19-185655_add_experimental_indexes/down.sql b/migrations/2019-09-19-185655_add_experimental_indexes/down.sql new file mode 100644 index 00000000000..1871ff378d6 --- /dev/null +++ b/migrations/2019-09-19-185655_add_experimental_indexes/down.sql @@ -0,0 +1,2 @@ +DROP INDEX IF EXISTS index_version_downloads_by_date; +DROP INDEX IF EXISTS index_recent_crate_downloads_by_downloads; diff --git a/migrations/2019-09-19-185655_add_experimental_indexes/up.sql b/migrations/2019-09-19-185655_add_experimental_indexes/up.sql new file mode 100644 index 00000000000..3bd5a54464a --- /dev/null +++ b/migrations/2019-09-19-185655_add_experimental_indexes/up.sql @@ -0,0 +1,9 @@ +-- These indexes were created on production by hand and never existed in migrations; give them +-- better names now that we know we want to keep them +ALTER INDEX IF EXISTS sgrif_testing RENAME TO index_recent_crate_downloads_by_downloads; +ALTER INDEX IF EXISTS sgrif_testing2 RENAME TO index_version_downloads_by_date; + +-- Create the above indexes for databases other than production +CREATE INDEX IF NOT EXISTS index_recent_crate_downloads_by_downloads + ON recent_crate_downloads USING btree (downloads); +CREATE INDEX IF NOT EXISTS index_version_downloads_by_date ON version_downloads USING brin (date);