PostgreSQL statement details
Use the statement details to see one PostgreSQL statement: its text, its history, and the sessions that run it now.
Before you begin
- Scops identifies a statement by its
query_idin one database. The text and the counts come frompg_stat_statements(see PostgreSQL permissions). - PostgreSQL keeps no execution plan and counts no CPU time for a statement. The panel has no plan and no CPU tab.
Open the statement details
Click a statement on one of these pages:
- A row of Statements on the Dashboard, or a
query_idtyped in its find box. - A row of a list on Insights.
- A
query_idon Live Activity.
The panel opens at the right. To go to a section, click its name in the list at the left.
Read the header
The header shows the query_id and the first word of the text, for example SELECT. Then it shows these facts:
| Fact | What it shows |
|---|---|
| Status | Running now, Not running now, or Last seen and the time. |
| Sessions | The sessions that run it in the newest sample. |
| User | The roles that it ran as. |
| Database | The database of the statement. |
Read the text
Statement Text shows the text that pg_stat_statements keeps, with $1, $2 in place of the constants. A long text shows its first part only. If pg_stat_statements no longer held the text when Scops read the statement, the section says so.
Read the history
In History, select a tab.
For a tab other than Activity, select the range: 1D or 1W.
To zoom, drag across the chart. To go back, click Reset Zoom.
| Tab | What it shows |
|---|---|
| Activity | The average active backends of the statement, by wait event type. From the Dashboard, it shows the window of the Dashboard, or its last 24 hours when the window is longer. From the other pages, it shows the last hour. |
| Elapsed | The mean time of one call: total_exec_time divided by the calls. |
| Executions | The calls in each ten minutes. |
| Disk | The shared blocks that one call read in (shared_blks_read). |
| Gets | The shared blocks that one call used, found or read in. |
| Rows | The rows that one call returned or changed. |
| Table | Each ten-minute interval as a row, with the values for one call, the temp blocks and the WAL bytes. |
A break in a line means that the statement did not run. The figures at the right of the tabs summarize the range, for example Average, Fastest, Slowest and Last.
Table shows I/O Time / Exec only when track_io_timing is on. It shows Planning Time / Exec only when pg_stat_statements.track_planning is on.
See who runs it now
Right Now lists the sessions that run the statement in the newest sample. Each row shows the pid, user, wait, elapsed time, blocker, application and client. The client local means a connection over a Unix socket.
Read the recent samples
In Samples, click Show Samples.
The list shows each sample of the last 15 minutes that saw the statement, with the time, the session and its state.
Related
Updated November 22, 2026