Technologies/PostgreSQL/stat_statements_seconds
PostgreSQLPostgreSQLMetric

stat_statements_seconds

Statement execution time
Dimensions:None
Available on:PrometheusPrometheus (1)
Interface Metrics (1)
PrometheusPrometheus
Total time spent in the statement, in seconds
Dimensions:None

Technical Annotations (16)

Configuration Parameters (7)
shared_preload_librariesrecommended: pg_stat_statements
required to enable pg_stat_statements extension
pg_stat_statements.trackrecommended: all
tracks all SQL statements including nested calls
log_min_duration_statementrecommended: 1000
log queries taking longer than 1 second (1000ms)
log_statementrecommended: none
avoid logging all statements to reduce overhead
log_durationrecommended: off
disable general duration logging
auto_explain.log_min_durationrecommended: 1000
capture query plans for queries exceeding 1 second
auto_explain.log_analyzerecommended: true
enable detailed query plan analysis
CLI Commands (3)
SELECT query, calls, total_exec_time, mean_exec_time, rows FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20;diagnostic
CREATE EXTENSION pg_stat_statements;remediation
EXPLAIN ANALYZEdiagnostic
Technical References (6)
pg_stat_statementscomponentpostgresql.conffile pathPrepared StatementsconceptQuery PlannercomponentPlan Cachecomponentauto_explaincomponent
Related Insights (5)
Slow queries consuming excessive total execution time degrade performancewarning
Missing pg_stat_statements extension prevents query performance monitoringwarning
Non-parameterized queries cause CPU burn from repeated query planningwarning
Slow query performance degrades from milliseconds to secondswarning
Slow queries exceed execution time thresholdwarning