Home Technical Notes Projects Musings The Bullshitters Tags Contact
4

SQL Patterns That Scale

Tags Databases, Performance
Reading 2 min
Published May 25, 2025

Writing SQL that works is easy. Writing SQL that scales is a discipline.

Indexing Strategy

Indexes are not free. Every index speeds up reads but slows down writes. Index the columns in your WHERE clauses and JOIN conditions.

Query Patterns

  • Use EXISTS instead of IN for subqueries
  • Avoid SELECT * in production
  • Use EXPLAIN ANALYZE to understand query plans
  • Paginate with keyset pagination for large datasets

Schema Design

Normalise first, denormalise intentionally. Start with a clean relational model, then introduce denormalisation only with measured evidence.

Press Esc to close