NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
DOCS / RASTERIZEDDB SERVER / MONITORING

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:

sh
psql "host=db.example.com user=rasterized dbname=postgres sslmode=require" -c 'SELECT 1'

A check that also tells you which server answered:

sql
SELECT version();
text
             version
----------------------------------
 rasterizeddb (pgwire) 1.1.0

For 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.

StatementAnswers
SHOW DATABASE STATS (or SHOW STATS)One metric per row for the current database: its storage, sizes, row slots, reclaimable space and more.
SHOW TABLESA 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 CHECKSA row per CHECK constraint and whether it is enforced.
SHOW SCHEMA MAPA row per foreign-key relationship, for drawing a diagram.
SHOW DATABASESEvery database on the server, with its sessions; see Databases.
SHOW CONFIG / SHOW CONFIG KEYSEvery setting, its value and how to change it; see Configuration.
SHOW QUERIES [n]The last statements, newest first.
SHOW QUERY STATSA row per statement shape with its totals.
SHOW BACKUP STATUS, SHOW BACKUPSWhether backups are configured and working, and the snapshots held; see Backup and restore.
SHOW REPLICATION STATS, SHOW REPLICATION STATUS, SHOW REPLICATION PEER STATUSThis node's replication state and a row per peer; see Replication.
SHOW STORAGE STATS, SHOW STORAGE LOCATIONS, SHOW STORAGE PLACEMENTSThe database's storage directories, their free space, and which holds each table; see Storage pools.
SHOW BRANCHESThe 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

sql
SHOW TABLES;
ColumnMeaning
table_nameThe table.
storageWhere its rows are: memory, file, mirrored, s3, kv-directory or kv-memory.
row_slotsRow pointer records. An upper bound on rows, not a live count: a deleted row keeps its slot until space is reclaimed.
columnsNumber of columns.
data_bytes, pointer_bytes, index_bytes, total_bytesSizes on storage.
reclaimable_bytesSpace that VACUUM could give back.
filters_readyWhether the filter index is built for the table.
immutableThe table's immutable flag.
primary_keyIts 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.

sql
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):

ColumnMeaning
started_atWhen it started.
duration_msHow long it took.
rowsRows returned or changed.
rows_scannedRows the scans had to look at after the filter index pruned. Far more scanned than returned usually means a missing index.
materialised, materialised_msRows copied into temporary relations (CTEs, derived tables) and the time it took; costs rows_scanned cannot see.
statusWhether it succeeded.
database, usernameWhere and as whom it ran.
statementIts text, cut at 2,048 characters.
errorThe 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:

sql
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 on pg_catalog, information_schema or pg_… 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 PASSWORD is cut at that word before it is stored, so passwords from CREATE ROLE and similar statements never reach this record.
  • Any role can run SHOW QUERIES and see every session's statements. RESET QUERY STATS needs a superuser.
  • Recording can be turned off with --query-stats off or SET CONFIG query_stats.enabled = off; it costs one lock per statement.

Query plans

sql
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.

sql
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:

ViewWhat it reports
pg_stat_statementsThe statement totals above.
pg_stat_user_tablesrelid, schemaname, relname, n_live_tup, n_dead_tup for each table.
pg_replication_slotsAlways 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.

sql
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

WatchHowAct when
The server answersSELECT 1It does not.
Backups are healthySHOW BACKUP STATUSThe status reports a failure or an unreachable bucket.
Replication keeps upSHOW REPLICATION PEER STATUSA peer is disconnected or falling behind.
Disk spaceSHOW STORAGE LOCATIONS, or the host's own monitoringFree space nears --storage-min-free or the disk's end.
Space to reclaimreclaimable_bytes in SHOW TABLESIt stays large; see Maintenance.
Slow statementsSHOW QUERY STATS or pg_stat_statementsA shape's mean_ms grows, or rows_scanned is far above rows.
Connectionssessions in SHOW DATABASESIt nears --max-connections.
Errorserrors in SHOW QUERY STATS, and the logThey 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 no pg_cancel_backend or pg_terminate_backend. Cancel a statement from its own client; see Connecting.
  • There is no metrics endpoint (Prometheus or similar); poll the statements above.
  • row_slots and the SHOW TABLES sizes are storage figures, not live row counts.
✓ page rendered in 165 µs axum + tera + htmx · no other javascript