Monitoring
This page shows how to see what a running server is doing: its sizes and health, what statements ran and what they cost, query plans, logs, and what to poll from a monitoring system. Everything here is SQL that works from psql or any driver, and it is what Studio shows on its screens.
Is it up
The simplest health check is a query:
psql "host=db.example.com user=rasterized dbname=postgres sslmode=require" -c 'SELECT 1'A check that also tells you which server answered:
SELECT version(); version
----------------------------------
rasterizeddb (pgwire) 1.1.0For a server with backups or replication, add SHOW BACKUP STATUS and SHOW REPLICATION STATS (below) to the check: a server can answer queries while its backups have stopped.
The SHOW statements
These statements describe the server. They take no WHERE clause and return a fixed set of columns. They are not reserved to superusers, except SHOW BRANCH DIFF, which reads other databases' rows.
| Statement | Answers |
|---|---|
SHOW DATABASE STATS (or SHOW STATS) | One metric per row for the current database: its storage, sizes, row slots, reclaimable space and more. |
SHOW TABLES | A row per table with its storage kind and sizes. |
SHOW TABLE STATS <table> | One metric per row for one table. |
SHOW COLUMNS FROM <table> (or DESCRIBE <table>) | A row per column: type, nullability, keys, default, whether indexed. |
SHOW PARTITIONS <table> | A row per partition of a partitioned table. |
SHOW CHECKS | A row per CHECK constraint and whether it is enforced. |
SHOW SCHEMA MAP | A row per foreign-key relationship, for drawing a diagram. |
SHOW DATABASES | Every database on the server, with its sessions; see Databases. |
SHOW CONFIG / SHOW CONFIG KEYS | Every setting, its value and how to change it; see Configuration. |
SHOW QUERIES [n] | The last statements, newest first. |
SHOW QUERY STATS | A row per statement shape with its totals. |
SHOW BACKUP STATUS, SHOW BACKUPS | Whether backups are configured and working, and the snapshots held; see Backup and restore. |
SHOW REPLICATION STATS, SHOW REPLICATION STATUS, SHOW REPLICATION PEER STATUS | This node's replication state and a row per peer; see Replication. |
SHOW STORAGE STATS, SHOW STORAGE LOCATIONS, SHOW STORAGE PLACEMENTS | The database's storage directories, their free space, and which holds each table; see Storage pools. |
SHOW BRANCHES | The database's branches; see Branching. |
SHOW DATABASE STATS, SHOW TABLE STATS and SHOW BACKUP STATUS return three columns, metric, value and detail, so a new metric is a new row and never changes the shape your tooling reads.
SHOW TABLES
SHOW TABLES;| Column | Meaning |
|---|---|
table_name | The table. |
storage | Where its rows are: memory, file, mirrored, s3, kv-directory or kv-memory. |
row_slots | Row pointer records. An upper bound on rows, not a live count: a deleted row keeps its slot until space is reclaimed. |
columns | Number of columns. |
data_bytes, pointer_bytes, index_bytes, total_bytes | Sizes on storage. |
reclaimable_bytes | Space that VACUUM could give back. |
filters_ready | Whether the filter index is built for the table. |
immutable | The table's immutable flag. |
primary_key | Its primary-key columns. |
The sizes are read from storage, not counted, so SHOW TABLES stays cheap on large databases. For live row counts use SELECT count(*). See Maintenance for reclaiming space.
What ran and what it cost
The server records every statement it runs, in memory. Nothing is written to disk and the record starts empty after a restart.
SHOW QUERIES;
SHOW QUERIES 20;
SHOW QUERY STATS;
RESET QUERY STATS;SHOW QUERIES returns the most recent statements (256 by default; SET CONFIG query_stats.recent changes it):
| Column | Meaning |
|---|---|
started_at | When it started. |
duration_ms | How long it took. |
rows | Rows returned or changed. |
rows_scanned | Rows the scans had to look at after the filter index pruned. Far more scanned than returned usually means a missing index. |
materialised, materialised_ms | Rows copied into temporary relations (CTEs, derived tables) and the time it took; costs rows_scanned cannot see. |
status | Whether it succeeded. |
database, username | Where and as whom it ran. |
statement | Its text, cut at 2,048 characters. |
error | The error, for a failed statement. |
SHOW QUERY STATS groups statements by shape (the same statement with different literal values) and returns queryid, calls, total_ms, mean_ms, min_ms, max_ms, stddev_ms, rows, rows_scanned, materialised, materialised_ms, errors, last_seen and statement, slowest first.
The same totals are available under PostgreSQL's name, for dashboards built for pg_stat_statements:
SELECT query, calls, mean_exec_time, rows, rows_scanned
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 10;
SELECT pg_stat_statements_reset();Times are in milliseconds. shared_blks_hit and shared_blks_read are present and always zero.
Things to know:
- Statements that describe the server (
SHOW,SET,RESET,DISCARD, and queries onpg_catalog,information_schemaorpg_…relations) are not recorded when they succeed, so a console's polling does not crowd out your application's statements. Failed ones are kept. - A statement containing the word
PASSWORDis cut at that word before it is stored, so passwords fromCREATE ROLEand similar statements never reach this record. - Any role can run
SHOW QUERIESand see every session's statements.RESET QUERY STATSneeds a superuser. - Recording can be turned off with
--query-stats offorSET CONFIG query_stats.enabled = off; it costs one lock per statement.
Query plans
EXPLAIN SELECT o.id, c.name FROM orders o JOIN customers c ON c.id = o.customer_id WHERE o.total > 100;
EXPLAIN ANALYZE SELECT count(*) FROM orders WHERE status = 'open';EXPLAIN returns one QUERY PLAN text column with what the engine will do: the CTEs and derived tables it builds first, the tables it scans and their filters, the hash joins between them and their keys, then grouping, sorting and the limit. Whether a scan uses an index is decided while it runs, so the plan says so instead of naming an index.
EXPLAIN ANALYZE runs the statement and adds the rows and time. Like PostgreSQL's, it really runs it, writes included: wrap a write in a transaction you roll back.
BEGIN;
EXPLAIN ANALYZE UPDATE orders SET status = 'closed' WHERE created_at < '2026-01-01';
ROLLBACK;The plan format is the engine's own, not PostgreSQL's; tools that parse PostgreSQL's plan text or JSON will not read it.
Catalogue views
The PostgreSQL catalogue views ORMs and tools read are available, including pg_class, pg_namespace, pg_attribute, pg_index, pg_indexes, pg_constraint, pg_type, pg_proc, pg_database, pg_roles, pg_tables, pg_views, pg_sequences, pg_trigger and information_schema.tables, columns, views, sequences and table_constraints. See PostgreSQL compatibility.
Of the statistics views:
| View | What it reports |
|---|---|
pg_stat_statements | The statement totals above. |
pg_stat_user_tables | relid, schemaname, relname, n_live_tup, n_dead_tup for each table. |
pg_replication_slots | Always empty: replication between RasterizedDB servers uses no PostgreSQL slots. |
pg_stat_activity, pg_locks and the other pg_stat_* views are not provided. For who is connected, SHOW DATABASES has a sessions count per database, and SHOW QUERIES shows what ran.
SELECT relname, n_live_tup, n_dead_tup
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC;Logs
The server logs to standard error at the level --log-level sets (default error; warn or info are good for production). RUST_LOG is not read. Under systemd read it with journalctl -u rasterizeddb, in Docker with docker logs. See Running the server.
At info the log records start-up and shutdown steps, each listener with its address and authentication, failed logins, the creation of the bootstrap role, and backup activity. Statements are not logged; use SHOW QUERIES.
What to watch
| Watch | How | Act when |
|---|---|---|
| The server answers | SELECT 1 | It does not. |
| Backups are healthy | SHOW BACKUP STATUS | The status reports a failure or an unreachable bucket. |
| Replication keeps up | SHOW REPLICATION PEER STATUS | A peer is disconnected or falling behind. |
| Disk space | SHOW STORAGE LOCATIONS, or the host's own monitoring | Free space nears --storage-min-free or the disk's end. |
| Space to reclaim | reclaimable_bytes in SHOW TABLES | It stays large; see Maintenance. |
| Slow statements | SHOW QUERY STATS or pg_stat_statements | A shape's mean_ms grows, or rows_scanned is far above rows. |
| Connections | sessions in SHOW DATABASES | It nears --max-connections. |
| Errors | errors in SHOW QUERY STATS, and the log | They rise. |
Limits
- The statement record lives in memory and is lost at restart.
- There is no
pg_stat_activity, so there is no SQL view of the statements running right now, and nopg_cancel_backendorpg_terminate_backend. Cancel a statement from its own client; see Connecting. - There is no metrics endpoint (Prometheus or similar); poll the statements above.
row_slotsand theSHOW TABLESsizes are storage figures, not live row counts.