postgresql.queries.count
Query execution countDimensions:None
Interface Metrics (3)
Dimensions:None
Technical Annotations (30)
Configuration Parameters (8)
shared_preload_librariesrecommended: pg_stat_statementspg_stat_statements.trackrecommended: allstatement_timeoutrecommended: 15min or application-specificlog_min_duration_statementrecommended: 1000log_statementrecommended: nonelog_durationrecommended: offauto_explain.log_min_durationrecommended: 1000auto_explain.log_analyzerecommended: trueCLI Commands (8)
SELECT query, calls, total_exec_time, mean_exec_time, rows FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20;diagnosticEXPLAIN (ANALYZE, BUFFERS) SELECT ...diagnosticCREATE INDEX idx_orders_status_created ON orders (status, created_at DESC);remediationSELECT queryid, query, plans, calls FROM pg_stat_statements WHERE plans > callsdiagnosticSELECT * FROM products WHERE id > 100000 ORDER BY id LIMIT 20;remediationCREATE EXTENSION IF NOT EXISTS pg_stat_statements;diagnosticSELECT calls, round(total_exec_time::numeric, 2) AS total_ms, round(mean_exec_time::numeric, 2) AS mean_ms, round((100 * total_exec_time / sum(total_exec_time) OVER ())::numeric, 2) AS percentage, query FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20;diagnosticSELECT calls, round(mean_exec_time::numeric, 2) AS mean_ms, round(stddev_exec_time::numeric, 2) AS stddev_ms, query FROM pg_stat_statements WHERE calls > 100 ORDER BY mean_exec_time DESC LIMIT 20;diagnosticTechnical References (14)
pg_stat_statementscomponentSeq ScanconceptEXPLAIN ANALYZEcomponentBuffers: shared readconceptpg_extensioncomponentN+1 patternconceptORMconceptPrepared StatementsconceptQuery PlannercomponentPlan Cachecomponentstatement_timeoutcomponentOFFSETconceptkeyset paginationconceptauto_explaincomponentRelated Insights (11)
Slow queries consuming excessive total execution time degrade performancewarning
▸
Sequential scan on large table causes excessive disk reads and slow query executioncritical
▸
Missing pg_stat_statements extension prevents query performance metrics collectionwarning
▸
Planning and execution statistics mismatch indicates failed queriesinfo
▸
N+1 query patterns and ORM inefficiencies create excessive database loadwarning
▸
Non-parameterized queries cause CPU burn from repeated query planningwarning
▸
Runaway queries consume resources without timeoutwarning
▸
Deep pagination with OFFSET scans and discards large result setswarning
▸
pg_stat_statements extension not enabled prevents query performance analysiswarning
▸
postgres_exporter memory exhaustion consuming 100% RAMcritical
▸
Slow queries exceed execution time thresholdwarning
▸