From 825c58a2b990e7afb27e814f924bd7ca228e1b68 Mon Sep 17 00:00:00 2001 From: Christian Chwala Date: Thu, 16 Jul 2026 18:17:46 +0200 Subject: [PATCH] feat(db): enable pg_stat_statements for query diagnostics Add pg_stat_statements to shared_preload_libraries alongside timescaledb, and set pg_stat_statements.track=all. This allows tracking cumulative query statistics across sessions, enabling identification of slow queries. After restarting the database container, activate the extension with: CREATE EXTENSION IF NOT EXISTS pg_stat_statements; --- docker-compose.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 2d5f704..f313714 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -122,6 +122,8 @@ services: # effective_cache_size: hints to the planner how much OS page cache is available. # work_mem: memory per sort/hash operation; speeds up ORDER BY on large result sets. # random_page_cost: tell the planner data is effectively cached, prefer index scans. + # shared_preload_libraries: load timescaledb and pg_stat_statements at startup. + # pg_stat_statements.track=all: capture stats for all statements including nested. command: > postgres -c shared_buffers=2GB @@ -129,6 +131,8 @@ services: -c work_mem=64MB -c maintenance_work_mem=256MB -c random_page_cost=1.1 + -c shared_preload_libraries=timescaledb,pg_stat_statements + -c pg_stat_statements.track=all healthcheck: test: ["CMD-SHELL", "pg_isready -U ${DB_SUPERUSER:-myuser} -d mydatabase"] interval: 5s