From 24c1413c60786a9f9dae5f1543f3bb9a1adc8a6f Mon Sep 17 00:00:00 2001 From: mohanish2504 Date: Sat, 30 Dec 2023 23:49:37 +0530 Subject: [PATCH 1/2] Postgres Index Optimization and Benchmarking #863 (STILL WIP) --- .../migrations/20231230174418_schema_version_index.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 internal/storage/postgres/migrations/20231230174418_schema_version_index.sql diff --git a/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql b/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql new file mode 100644 index 000000000..5255d43b0 --- /dev/null +++ b/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +CREATE INDEX IF NOT EXISTS idx_schema_version ON schema_definitions (version); +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +DROP INDEX IF EXISTS idx_schema_version; +-- +goose StatementEnd From ba993e6f6bb358bfe20088454cf970c873a40848 Mon Sep 17 00:00:00 2001 From: mohanish2504 Date: Tue, 2 Jan 2024 19:00:31 +0530 Subject: [PATCH 2/2] Modification: usging create/drop schema index concurrently --- .../migrations/20231230174418_schema_version_index.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql b/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql index 5255d43b0..5c4477a0e 100644 --- a/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql +++ b/internal/storage/postgres/migrations/20231230174418_schema_version_index.sql @@ -1,9 +1,10 @@ +-- +goose NO TRANSACTION -- +goose Up -- +goose StatementBegin -CREATE INDEX IF NOT EXISTS idx_schema_version ON schema_definitions (version); +CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_schema_version ON schema_definitions (version); -- +goose StatementEnd -- +goose Down -- +goose StatementBegin -DROP INDEX IF EXISTS idx_schema_version; +DROP INDEX CONCURRENTLY IF EXISTS idx_schema_version; -- +goose StatementEnd