Query Monitoring

Real-time query performance monitoring using pg_stat_statements. Track execution times, call counts, and buffer usage to identify slow queries.

Query execution statistics
Performance trends over time
Cache hit ratio analysis
Top slow queries
Query load distribution

PG Pilot leverages PostgreSQL's pg_stat_statements extension to provide
comprehensive query performance insights without impacting your database.

Every query executed against your database is tracked with:
- Total and average execution time
- Call count and rows returned
- Buffer usage (shared blocks hit/read)
- Cache hit ratio

Queries are normalized (parameters replaced with $1, $2, etc.) so you can
identify patterns across similar queries with different values.

What it monitors

  • Total execution time per query
  • Mean, min, and max execution times
  • Query call counts
  • Rows returned per query
  • Shared buffer hits and reads
  • Query load percentage

How to use

Navigate to the Statements section from the main navigation.

Main View
The statements list shows all queries sorted by total execution time.
Use the filters to:
- Search for specific table or function names
- Filter by time range
- Sort by different metrics (calls, time, rows)

Query Details
Click any query to see:
- Full normalized query text
- Performance metrics over time
- Recent execution history
- Trend charts for key metrics

Dashboard Integration
The main dashboard shows:
- Queries per second (QPS)
- Average query latency
- Top 5 slowest queries

Requirements
The pg_stat_statements extension must be installed:

CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

And configured in postgresql.conf:

shared_preload_libraries = 'pg_stat_statements'

Issues detected by this feature