← ...
project 10: the slow query assassin
project 10: the “slow query” assassin
scenario: a dashboard query is timing out (running > 15 mins). the mission: debug and optimize a complex sql query using distribution and sort keys.
- tech: postgres (local) or redshift (free trial).
- challenge: understanding
explain analyze. - dev to prod:
- create two tables and join them inefficiently (cartesian product or wrong join keys).
- run
explainto see the cost. - add indexes (postgres) or sort keys (redshift).
- prod requirement: reduce query cost by 90%. document the “before” vs “after” plan.