System Design
4. Database FundamentalsAnimated
Query Optimisation
Making queries run faster.
The idea
The optimiser chooses join order, indexes and algorithms using statistics. You help with indexes and better queries.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
Step one: add indexes and cache.
- step:
- 1/4
- at:
- App servers
1/7
The green dot is a request moving through the system.
Step by step
- 1Measure slow queries
- 2Read the execution plan
- 3Add indexes or rewrite the query
- 4Re-test
Where it is used
Slow endpoints.
Watch out for
Optimising without looking at the plan.