Diagnostics
Goal
Analyze query performance, inspect server state, and triage issues using AngaraBase’s built-in diagnostic tools.
Prerequisites
- Running
angarabase-server(see Quickstart) psqlor another pgwire-compatible client- For slow-query logging: env variables set before server start (see Configuration)
EXPLAIN variants
Basic query plan
EXPLAIN SELECT * FROM t WHERE id = 1;
Shows the planned execution path without running the query.
EXPLAIN ANALYZE (with actual timing)
EXPLAIN ANALYZE SELECT * FROM t WHERE id > 100;
Executes the query and reports actual row counts and timing alongside the plan.
For parallel join plans, EXPLAIN ANALYZE also reports best-effort join accounting counters:
join_build_rows— rows processed by join build phase,join_probe_rows— rows processed by join probe phase.
EXPLAIN ANALYZE for DML (dry-run)
EXPLAIN ANALYZE over INSERT, UPDATE, or DELETE runs the statement inside an isolated dry-run
transaction that rolls back automatically — no data is modified.
EXPLAIN ANALYZE INSERT INTO t (id, v) VALUES (999, 42);
EXPLAIN ANALYZE UPDATE t SET v = v + 1 WHERE id = 1;
EXPLAIN ANALYZE DELETE FROM t WHERE id = 1;
Buffer statistics
EXPLAIN (BUFFERS) SELECT * FROM t WHERE id = 1;
Adds buffer-pool hit/miss counters to the plan output.
JSON output
EXPLAIN (FORMAT JSON) SELECT * FROM t WHERE id = 1;
Returns the plan as a JSON document — useful for programmatic analysis.
Runtime diagnostic views
angara_stat_activity
Shows currently executing queries and their wait state.
SELECT pid, state, wait_event_type, query
FROM angara_stat_activity;
wait_event_type values: Lock, IO, Net, CPU — provides coarse wait categorization for triage.
angara_stat_statements
Aggregated per-query statistics (call count, total time, rows, etc.).
SELECT query, calls, total_time, rows
FROM angara_stat_statements
ORDER BY total_time DESC
LIMIT 10;
Reset accumulated stats:
SELECT angara_stat_statements_reset();
The maximum number of tracked statements is controlled by ANGARABASE_STAT_STATEMENTS_MAX (LRU-bounded). See
Configuration — Diagnostics knobs.
angara_top_queries
Convenience wrapper returning the top-N queries by cumulative time:
SELECT * FROM angara_top_queries(10);
Slow-query log
Capture queries that exceed a duration threshold to the server log.
Configuration
Set before server start (env variables override config):
| Variable | Default | Description |
|---|---|---|
ANGARABASE_LOG_MIN_DURATION_MS | -1 (disabled) | Threshold in milliseconds. Set to 0 to log all queries. |
ANGARABASE_LOG_QUERY_TEXT | 0 | Include raw SQL text in the log entry (0 / 1). |
Example:
export ANGARABASE_LOG_MIN_DURATION_MS=500
export ANGARABASE_LOG_QUERY_TEXT=1
angarabase-server --config /path/to/angarabase.conf
Slow queries appear in the server log at logging.log_directory.
Saturation / backpressure (operability)
When p99/p99.9 degrades under load, you usually want to distinguish:
- lock/contention waits,
- IO/scheduler saturation,
- admission/queue rejects vs “random” timeouts.
Practical entry points:
angara_stat_activity.wait_event_type(coarse wait classification)- operator runbook:
angarabook/src/operations/troubleshooting.md
System introspection views
sys.health
Overall server health status:
SELECT * FROM sys.health;
sys.settings
Effective configuration (config + env overrides resolved):
SELECT * FROM sys.settings;
SELECT * FROM sys.settings WHERE name LIKE 'storage.%';
sys.identity
Instance identity metadata:
SELECT * FROM sys.identity;
Expected result
EXPLAINvariants return plan text (or JSON) without errors.angara_stat_activityshows at least the current session.angara_stat_statementsaccumulates entries after queries are executed.sys.healthreturns{"status":"ready"}on a healthy instance.
Troubleshooting
| Symptom | Action |
|---|---|
EXPLAIN ANALYZE modifies data | This should not happen — DML runs in a dry-run transaction. If data changes persist, file a bug via Support. |
angara_stat_statements is empty | Ensure queries have been executed since the last reset. Check ANGARABASE_STAT_STATEMENTS_MAX is not 0. |
| Slow-query log has no entries | Verify ANGARABASE_LOG_MIN_DURATION_MS is set to a non-negative value and queries actually exceed the threshold. |
sys.health shows not-ready | Check GET /health/ready for the JSON reason. Collect a diagnostics bundle — see Monitoring. |
For unresolved issues see Known issues and Support.
Links
- SQL compatibility reference: SQL overview
- Monitoring setup: Monitoring
- Configuration (env knobs): Configuration
- Diagnostics bundle tool:
tools/diagnostics_bundle/run.sh - Operator runbook:
angarabook/src/operations/troubleshooting.md - Incident runbook (10 minutes): Error debug runbook
- Support flow: Support