Skip to content

Instantly share code, notes, and snippets.

@cphillips83
Created March 16, 2026 20:51
Show Gist options
  • Select an option

  • Save cphillips83/e94a17085a1c477480afbd217fe33437 to your computer and use it in GitHub Desktop.

Select an option

Save cphillips83/e94a17085a1c477480afbd217fe33437 to your computer and use it in GitHub Desktop.
-- Fix: add missing index on orders.status for active order queries
-- Author: DBA Team
-- Date: 2026-03-16
BEGIN;
CREATE INDEX CONCURRENTLY idx_orders_status
ON orders(status)
WHERE status != 'completed';
-- Verify
SELECT indexname, indexdef
FROM pg_indexes
WHERE tablename = 'orders' AND indexname = 'idx_orders_status';
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment