Playbook · Database Engineering

Database Performance Checklist

Diagnostic queries, index optimizations, query optimizations, and caching guidelines for high-traffic SQL databases like MySQL and PostgreSQL.

Audience: Database Administrators, Staff Engineers
Time: 2 Hours
Difficulty: Advanced

Problem Statement

High database latency directly impacts page loading times and user satisfaction. Use this playbook to identify database constraints and optimize query plans.

When to Use

Use when application response times increase under load, or when database CPU and memory metrics exceed baseline thresholds.

Step-by-Step Guide

Step 1: Query Plan Analysis

  • Run EXPLAIN statements on slow query targets.
  • Identify queries executing table scans instead of index lookups.

Step 2: Index Design

  • Index foreign keys and fields commonly used in WHERE, ORDER BY, or JOIN conditions.
  • Prevent duplicate or overlapping composite indexes.

Step 3: Connection Pool Optimization

  • Review maximum database connection limits.
  • Optimize application-side connection recycling settings.

Checklist Items

  • Slow query log is active and generating analysis outputs.
  • No queries execute full table scans on large tables in production.
  • Database connections are managed via connection pooling logic.
  • Read-only requests are separated or routed to database replicas.
  • Index usage stats are monitored and unused indexes are removed.

Key Takeaways

  • Detect and resolve missing indexes causing table scan bottle-necks.
  • Eliminate N+1 database queries via optimized ORM preloading logic.
  • Implement efficient read-through caching using Redis or Cloudflare edge caching.

Frequently Asked Questions

How do I identify slow queries in MySQL?

Enable the slow query log (`slow_query_log = 1`) and review slow queries using `explain` statements to analyze query executions.

Continue Exploring