The Scenario
A 50-million-row `transactions` table powers a financial dashboard. A query that joins `transactions` with `accounts` and filters by date range is taking 45 seconds. The DBA has asked you to fix it.
The Brief
You are given the slow query and the current table schema (no indexes beyond the primary key). Rewrite the query for performance, propose the indexes you would add, and walk through what an EXPLAIN ANALYZE output would look like before and after your changes.
Deliverables
- The original slow query and your rewritten version with an explanation of each change
- The indexes you would create and why each one helps this specific query
- A walkthrough of a hypothetical EXPLAIN plan: what "Seq Scan" means vs "Index Scan" and how you would read the cost estimates
Submission Guidance
Assume PostgreSQL. Focus on covering indexes, composite index column order, and the impact of WHERE clause selectivity.
Submit Your Work
Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.