Skip to content
StackDecode
System Design
16. Performance EngineeringAnimated

Database Query Profiling

Finding slow queries.

The idea

Slow query logs and EXPLAIN show where time goes.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

App serversPrimary (writes)Replica 1 (read…Replica 2 (read…
  • 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

  1. 1Enable the slow query log
  2. 2Find the worst queries
  3. 3Read their plans
  4. 4Index or rewrite them

Where it is used

Database tuning.

Watch out for

Fix the few queries that dominate.

Related