From 793fffd501ec785b84281e5e7fe368dd7c8ea322 Mon Sep 17 00:00:00 2001 From: Matthew Staebler Date: Tue, 4 Aug 2026 11:40:14 -0400 Subject: [PATCH 1/2] Drop unused idx_test_daily_totals_date index idx_test_daily_totals_date exists only to make an unscoped MAX(date) fast across ~3,700 partitions. TRT-2848 (PR #3852) removes the last two callers of that query pattern, so once it merges the index is pure write overhead. Do not deploy this migration before then, or the currently-fast MaxSummaryDate/MaxDailySummaryDate calls on main will regress to a full partition scan. Co-Authored-By: Claude Sonnet 5 --- .../000012_drop_test_daily_totals_date_index.down.sql | 2 ++ .../000012_drop_test_daily_totals_date_index.up.sql | 11 +++++++++++ pkg/db/migrations/MANIFEST | 1 + 3 files changed, 14 insertions(+) create mode 100644 pkg/db/migrations/000012_drop_test_daily_totals_date_index.down.sql create mode 100644 pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql diff --git a/pkg/db/migrations/000012_drop_test_daily_totals_date_index.down.sql b/pkg/db/migrations/000012_drop_test_daily_totals_date_index.down.sql new file mode 100644 index 000000000..dc0dca94e --- /dev/null +++ b/pkg/db/migrations/000012_drop_test_daily_totals_date_index.down.sql @@ -0,0 +1,2 @@ +CREATE INDEX IF NOT EXISTS idx_test_daily_totals_date + ON test_daily_totals (date); diff --git a/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql b/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql new file mode 100644 index 000000000..aa60d9436 --- /dev/null +++ b/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql @@ -0,0 +1,11 @@ +-- idx_test_daily_totals_date exists only to make an unscoped +-- SELECT MAX(date) FROM test_daily_totals fast across ~3,700 partitions. +-- TRT-2848 (incremental summary-table writer) removes the last two callers +-- that relied on that query (dailysummary.MaxSummaryDate and +-- cumulativesummary.MaxDailySummaryDate), so this index is now pure write +-- overhead: every insert into test_daily_totals maintains it for no reader. +-- +-- Do not deploy this migration before TRT-2848 lands: MaxSummaryDate and +-- MaxDailySummaryDate are still on the hot path on main today, and without +-- this index they fall back to a full scan across every partition. +DROP INDEX IF EXISTS idx_test_daily_totals_date; diff --git a/pkg/db/migrations/MANIFEST b/pkg/db/migrations/MANIFEST index 0f67ad014..0c6d1c812 100644 --- a/pkg/db/migrations/MANIFEST +++ b/pkg/db/migrations/MANIFEST @@ -18,3 +18,4 @@ 000009_add_lifecycle_to_prow_job_run_tests 000010_drop_test_analysis_by_job_by_dates 000011_add_lifecycle_to_summaries +000012_drop_test_daily_totals_date_index From 25c9c584cfd01897f26b922f80a05e4c647d5b67 Mon Sep 17 00:00:00 2001 From: Matthew Staebler Date: Wed, 5 Aug 2026 11:58:38 -0400 Subject: [PATCH 2/2] Simplify migration comment now that TRT-2848 has merged The "don't deploy before TRT-2848 lands" warning is stale now that #3852 is merged and this PR is rebased on top of it. Co-Authored-By: Claude Sonnet 5 --- .../000012_drop_test_daily_totals_date_index.up.sql | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql b/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql index aa60d9436..421fde240 100644 --- a/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql +++ b/pkg/db/migrations/000012_drop_test_daily_totals_date_index.up.sql @@ -1,11 +1,7 @@ -- idx_test_daily_totals_date exists only to make an unscoped -- SELECT MAX(date) FROM test_daily_totals fast across ~3,700 partitions. --- TRT-2848 (incremental summary-table writer) removes the last two callers --- that relied on that query (dailysummary.MaxSummaryDate and --- cumulativesummary.MaxDailySummaryDate), so this index is now pure write --- overhead: every insert into test_daily_totals maintains it for no reader. --- --- Do not deploy this migration before TRT-2848 lands: MaxSummaryDate and --- MaxDailySummaryDate are still on the hot path on main today, and without --- this index they fall back to a full scan across every partition. +-- Nothing queries MAX(date) without a release filter anymore +-- (dailysummary.MaxSummaryDate and cumulativesummary.MaxDailySummaryDate +-- were the last two callers), so this index is now pure write overhead: +-- every insert into test_daily_totals maintains it for no reader. DROP INDEX IF EXISTS idx_test_daily_totals_date;