0Pricing
SQL Academy · Lesson

pg_stat_statements: Top Queries

Enable pg_stat_statements, find the heaviest queries by total time, and target them for optimisation.

What pg_stat_statements Gives You

An accumulating record of every query, normalised by shape — the single most useful DBA tool in PostgreSQL.

Enable It

It's a contrib extension. Add to shared_preload_libraries and restart:

-- postgresql.conf
shared_preload_libraries = 'pg_stat_statements'

-- After restart:
CREATE EXTENSION pg_stat_statements;

All lessons in this course

  1. pg_stat_statements: Top Queries
  2. pgBadger for Log Analysis
  3. Connection Pooling: PgBouncer
  4. Capacity Planning and Bloat Audits
← Back to SQL Academy