intermediateTop 30 Scenario-Based Questions
A query is taking 30 seconds. EXPLAIN ANALYZE shows a Seq Scan on a 100M-row table. How do you fix it?
Step 1: Identify WHERE clause columns being filtered. Step 2: Check selectivity — is the filter highly selective (< 10% rows)? Step 3: CREATE INDEX CONCURRENTLY ON table(filtered_col). Step 4: EXPLAIN ANALYZE again to verify Index Scan is chosen. Step 5: If still slow: is the filter selective enough? For low selectivity (> 20%), seq scan may be intentionally chosen. Consider: partial index, coveri
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
A query is taking 30 seconds. EXPLAIN ANALYZE shows a Seq Scan on a 100M-row table. How do you fix it?