Skip to content

SQL Performance Tuning

Making analytical queries faster and cheaper: execution plans, indexes, partitioning and query patterns.

Editorial team 1 min read

Slow queries waste time and, on cloud warehouses, money.

Read the Execution Plan

Use EXPLAIN to see how the database runs a query: which tables are scanned, how joins are performed, and where time goes.

Reduce Data Scanned

  • Select only needed columns, especially in columnar warehouses.
  • Filter early.
  • Use partitioning and clustering so filters skip irrelevant data.

Indexes

In transactional databases, indexes on join and filter columns speed up queries. Warehouses rely more on partitioning, clustering and columnar storage.

Join Carefully

  • Join on keys with matching types.
  • Avoid accidental many-to-many joins.
  • Aggregate before joining when possible.

Avoid Common Anti-Patterns

  • Functions on filtered columns that prevent index or partition use.
  • SELECT DISTINCT masking join problems.
  • Repeated subqueries that could be computed once.

Materialise

Precompute expensive, frequently used results as tables or materialised views.

Monitor

Track the most expensive queries and optimise those first.

More in Data engineering

All Data engineering guides →
Data engineering Guide · 2 min

What Is Data Engineering?

What data engineers do, how data flows from source systems to analysis and AI, and the core skills involved.

Data engineering 2 min read 4 Jan 2026

Data engineering Guide · 2 min

ETL Versus ELT

The difference between transforming data before loading and after, and why modern warehouses shifted the default to ELT.

Data engineering 2 min read 3 Jan 2026

Data engineering Guide · 1 min

Data Warehouses, Data Lakes and Lakehouses

The three main architectures for analytical data storage, what each is good for and how they are converging.

Data engineering 1 min read 2 Jan 2026

Data engineering Guide · 2 min

Data Modelling for Analytics

Star schemas, facts and dimensions: how to design tables that make analysis fast, consistent and easy to understand.

Data engineering 2 min read 1 Jan 2026