Engine guides
PostgreSQL.
PostgreSQL gets the full workbench. This page covers what is specific to it: the connection model, the Health advisor, live LISTEN/NOTIFY, row-level security, session roles, pgvector and PostGIS.
What you get#
Everything in SQL editor, Results and Schema tools works on PostgreSQL, and a few features exist only here: Safe Run, the structure editor, schema diff, migration check, roles, import, backup, search in database, LISTEN/NOTIFY and the Health advisor.
Plasma opens three connections to the server: a primary one that runs your statements, a control connection used only to cancel them, and a side connection for lookups (row counts, autocomplete, activity, AI queries, search). This is why Cancel works while a long query holds the primary connection, and why the Health views never wait behind your own work.
Health advisor#
Health in the icon rail (also the toolbar button and Health advisor in the palette) runs read-only checks on the side connection and tells you what needs attention. Run all checks again refreshes it. The header strip shows tiles for the most important numbers, and a Needs attention list ranks the worst findings. Tabs:
| Tab | What it checks |
|---|---|
| Overview | Cache hit ratio; connections in use against the limit; long-running and idle-in-transaction sessions; replication slots (inactive or lagging, retaining WAL); standby lag; database sizes; the largest tables. |
| Activity | Live sessions (below). |
| Top queries | Statements from pg_stat_statements, sortable by total time, mean time or calls, with rows and cache hit %. |
| Indexes | Unused indexes, duplicate and overlapping indexes, invalid indexes, tables mostly read by sequential scan, and foreign keys with no supporting index. |
| Vacuum and bloat | Dead tuples and stale statistics, transaction-ID wraparound distance, autovacuum state (including when it is off or all workers are busy), and table and index bloat estimates. |
Findings explain themselves with evidence. Where a fix is a single statement, a button shows the exact SQL with Copy, Open in editor and Run. Run goes through the same Prod gate and Safe mode as anything you type, and is disabled on a read-only connection. Top queries needs the pg_stat_statements extension; if it is not enabled the tab shows the steps and a Create extension button.
Activity: sessions and lock waits#
The Activity tab lists sessions from pg_stat_activity (pid, state, user, database, wait event, who is blocking it, age, query), refreshed on a timer that you can pause. Filter by query, user, application or pid, by database, and with the Idle sessions and This monitor checkboxes. A Lock waits section shows what is blocked and by whom. Each row can Copy query, open the query in a new SQL tab, Cancel it (pg_cancel_backend: stops the query, keeps the connection) or Terminate it (pg_terminate_backend: closes the connection and rolls back its transaction). Both ask first. Plasma’s own sessions cannot be cancelled from here.
If your role is not allowed to see other users’ sessions, the tab says it needs pg_monitor.
Live tail: LISTEN / NOTIFY#
Listen to notifications (LISTEN/NOTIFY) in the palette opens a live view. Type a channel name to start listening (up to 50 channels); each one has a stop button (UNLISTEN). Messages appear newest first with their channel, time and payload, capped at 2,000; if a flood is thinned, a line reports how many notifications were dropped.
- Filter messages is a case-insensitive text filter. Prefix with
channel:orpayload:to search one field, or with!to exclude. - Pause and Clear messages control the stream.
- Send a NOTIFY sends a message through
pg_notify(the payload may be at most 7,999 bytes). Because it wakes every listener it counts as a write: a read-only connection refuses it, and it is recorded in the audit log with the source NOTIFY when auditing applies.
Row-level security and session role#
In the right sidebar, the Session tools menu (next to Details and Assistant) has Compiled SQL (the exact query behind the current table view), Session role and Row-level security. Session role shows and changes the role the session runs as with SET ROLE, which is how you see a table the way another user would. Row-level security lists the table’s policies and shows how many there are. Managing roles themselves is in Roles and privileges.
pgvector#
When a result has a vector column, the footer’s More menu offers Find similar (pgvector). The dialog lists the vector columns with their dimensions and builds a nearest-neighbour query: choose the anchor column and the anchor row, a distance (cosine <=>, L2 <-> or inner product <#>) and a limit. For a result that came from a SQL query, name the source table (schema.table). You get the SQL to copy and run; Plasma does not run anything for you here.
PostGIS map preview#
When a result has a geometry or geography column, Map preview (PostGIS) appears in the same menu. It draws GeoJSON geometries from a column as vector shapes fitted to their bounding box, locally; no map tiles are downloaded.
Also on PostgreSQL#
- Safe Run and EXPLAIN ANALYZE with timing.
- Structure editor, schema diff, migration check, import, backup and restore and search in database.
- Column types are shown by name, including enum type names, and enum columns edit with a picker of their labels.
- The Query timeout in Settings → Security sets
statement_timeoutfor your queries. Open the palette with ⌘KCtrl+K to reach any of the above by name.