~/talk

Find your slow queries, and fix them!

Talkat PGCon 2020 · 2020-05-26..05-29· [databases]
links:none on file
slides:none on file

Shows how to find slow queries by enabling log_min_duration_statement (0 logs everything; recommendation: start at 2000 ms, then 100 ms) and a pg-style log_line_prefix, plus log_lock_waits, log_temp_files and log_autovacuum_min_duration to correlate pauses. Uses pg_badger for HTML reports and installs pg_stat_statements (shared_preload_libraries, create extension) with track_io_timing and pg_test_timing. Diagnoses plans via EXPLAIN/ANALYZE and auto_explain, then fixes by adding indexes (including FK refs), increasing work_mem/maintenance_work_mem/effective_cache_size, tuning checkpoints and vacuuming. Example: pg_badger shows a 23s top query; external sorts happen when work_mem is too small.

AI-written summary · about

  1. 0:00Intro
  2. 0:29Stephen Frost
  3. 1:35Finding Slow Queries
  4. 3:57log min duration statement
  5. 7:49log line prefix Pre-pended to every log message
  6. 11:57log lock waits Logs information when query waits on a lock
  7. 14:05log temp files
  8. 17:35Log Analysis
  9. 18:37Pg stat statements
  10. 28:11Understanding Why Queries Are Slow
  11. 32:17PostgreSQL Configuration - work mem
  12. 33:17PostgreSQL Configuration - maintenance work mem
  13. 33:38PostgreSQL Configuration - effective cache size
  14. 34:12PostgreSQL Configuration - shared buffers
  15. 35:05PostgreSQL Configuration - checkpoints, wal size
  16. 36:17Dead Tuples / Bloat
  17. 37:56Putting things together (Joins)
  18. 39:16What's the best plan?
  19. 39:55Automating collection of plans
  20. 40:20Analyzing plans
  21. 40:35Fixing Slow Queries
  22. 42:08Prepared Queries
  23. 46:02Questions?
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.