From dcd9fb61d0ee9636cd20b09b46797327247b56a5 Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 31 May 2026 10:42:47 -0500 Subject: [PATCH] migration 083: use CREATE INDEX CONCURRENTLY to avoid locking fmcsa_carriers The original CREATE INDEX (non-concurrent) on a 2M-row table held a SHARE lock for ~33 minutes, blocking all 25+ DOT checker queries and causing 'Failed to fetch' for real users. CONCURRENTLY builds the index without a table lock. Co-Authored-By: Claude Sonnet 4.6 --- api/migrations/083_fmcsa_campaign_tracking.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/migrations/083_fmcsa_campaign_tracking.sql b/api/migrations/083_fmcsa_campaign_tracking.sql index 2a3bc83..44d7f80 100644 --- a/api/migrations/083_fmcsa_campaign_tracking.sql +++ b/api/migrations/083_fmcsa_campaign_tracking.sql @@ -5,6 +5,6 @@ ALTER TABLE fmcsa_carriers ADD COLUMN IF NOT EXISTS listmonk_sent_at TIMESTAMPTZ, ADD COLUMN IF NOT EXISTS listmonk_campaign_type TEXT; -CREATE INDEX IF NOT EXISTS idx_fmcsa_carriers_listmonk_sent +CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_fmcsa_carriers_listmonk_sent ON fmcsa_carriers (listmonk_sent_at) WHERE listmonk_sent_at IS NULL;