Aller au contenu principal

PostgreSQL query analytics

Query analytics applies to PostgreSQL. Aggregate statistics need an active database and functioning pg_stat_statements support; extension presence alone does not guarantee all deployment prerequisites are satisfied.

Available views​

  • Summary: extension status and aggregate counts/timing.
  • Query statistics: limit defaults to 50, capped at 100; min_calls defaults to 1. Sort by total_time, calls, mean_time, rows or shared_blks_hit; an unsupported sort falls back to total time.
  • Slow queries: threshold_ms defaults to 1000 and applies to mean query time; limit defaults to 20, capped at 50.
  • Active queries: queries currently running at inspection time.

Use positive numeric parameters. Malformed numeric input on query-list/slow-query endpoints returns 400.

Interpret results​

An empty list or zero count can reflect unavailable collection or an implementation/deployment mismatch. Check the summary flags, database state and errors before concluding that no queries ran. Compare with a known application query and application-side timing.

Owners/admins can reset query statistics. This removes the accumulated baseline, so coordinate it with anyone comparing performance over time. Do not reset statistics as the first response to a collection failure.

Native query text and editor statements can contain sensitive data. Keep credentials and sensitive literals out of queries and restrict access to logs/analytics accordingly.

Query analytics API · Extension catalogue.