PostgreSQL Queries


PostgreSQL Queries shows expensive and notable query activity for a monitored PostgreSQL server. Use it to find statements affecting CPU, I/O, waits, and response time.

Mini DBA PostgreSQL queries

What To Look For

  • Long-running statements.
  • High total time.
  • High execution count.
  • High reads or writes where available.
  • Queries related to waiting sessions.

Workflow

  1. Open Queries.
  2. Sort by the resource or duration that matches the symptom.
  3. Open query detail where available.
  4. Load PostgreSQL Execution Plans where available and drill into costly plan nodes.
  5. Compare with Activity, Waits, and Indexes.
  6. Use Performance Tune for guided review.

How To Prioritize PostgreSQL Queries

PostgreSQL query tuning is most effective when you focus on total impact instead of the most dramatic individual query. A statement that runs for several minutes once a day may matter, but a query that runs thousands of times per hour can consume more CPU and I/O overall. Sort by total time, mean duration, execution count, reads, and writes to find the workload that most affects users.

Use PostgreSQL Activity to confirm whether an expensive query is currently active. Then check PostgreSQL Waits to see whether it is delayed by locks, I/O, client waits, or another resource. If index evidence is available, open PostgreSQL Indexes before creating new indexes. Adding indexes without checking write overhead can make INSERT, UPDATE, and DELETE workloads slower.

For repeat investigations, capture the query fingerprint, database, application name, and approximate time window. This helps compare before and after behavior when a code release, parameter change, or index change is deployed.

PostgreSQL Query FAQ

Why do query totals change after restart?

Some PostgreSQL query statistics are reset when the server restarts or when statistics are explicitly reset. Treat the time window as part of the evidence.

Why do similar SQL statements appear separately?

Queries may be grouped differently depending on available PostgreSQL statistics and extensions. Compare statement text, parameters, database, and application context.

Can Mini DBA show execution plans?

Where plan detail is available, use it alongside the query list. See PostgreSQL Execution Plans for the plan viewer, diagram, HTML export, and AI plan review workflow. If plan detail is not available, use duration, waits, indexes, and row activity to choose the next investigation step.

Related Pages