Skip to content

HeliosDB-Lite REPL Command Reference

Complete reference for all REPL meta commands. Type \h for help or \h <category> for category-specific help.

Table of Contents


Basic Commands

CommandDescription
\q, \quit, \exitExit the REPL
\h, \help, \?Show help overview
\h <category>Show help for category (basics, schema, branching, time-travel, vectors, documents, agents, ai, tenants, settings, examples, sql)
\timingToggle query execution timing
\e, \editOpen last query in editor
\dump [file]Dump database to file (default: backup.heliodump)
\telemetryShow telemetry/statistics
\statsShow database statistics

Dump Formats

The \dump command exports database contents:

Terminal window
# Dump to default file (backup.heliodump)
\dump
# Dump to specific file
\dump /path/to/backup.heliodump
# View dump file info
\dump --info backup.heliodump

In-Memory Mode Notes

When running in --memory mode:

  • Use --dump-on-shutdown flag to auto-dump before exit
  • Use --dump-file <path> to specify dump location
  • Data is lost on exit unless dumped; start from the command prompt with --dump-on-shutdown
  • Use \dump command during session for manual backups

Schema Inspection

CommandDescription
\dList all tables
\d <table>Describe table schema
\dtList tables with column counts
\dSList system views
\dS <view>Describe system view schema
\dmvList materialized views
\dmv <view>Describe materialized view
\compressionShow compression statistics
\compression <table>Show table compression stats
\indexes <table>Placeholder; automatic index recommendations are planned
\optimize <table>Prints EXPLAIN hints for the table; automatic recommendations are planned

System Views Available

SELECT * FROM pg_database_branches(); -- Branch metadata
SELECT * FROM pg_mv_staleness(); -- MV refresh status
SELECT * FROM pg_vector_index_stats(); -- Vector index stats
SELECT * FROM pg_tenant_usage(); -- Tenant resource usage
SELECT * FROM pg_rls_policies(); -- RLS policy definitions
SELECT * FROM pg_cdc_events(); -- CDC event log
SELECT * FROM pg_smfi_status(); -- SMFI system status
SELECT * FROM pg_smfi_table_stats(); -- Per-table SMFI stats
SELECT * FROM pg_speculative_filters(); -- Auto-created filters

Branching Commands

CommandDescription
\branchesList all database branches
\use <branch>Switch to branch
\show branchShow current branch
\snapshotsShow time-travel snapshot info

SQL Branch Operations

-- Create branch from current state
CREATE DATABASE BRANCH dev FROM main;
-- Create branch at specific point
CREATE DATABASE BRANCH hotfix FROM main AS OF TIMESTAMP '2025-01-01';
-- Merge branch
MERGE DATABASE BRANCH dev INTO main;
-- Drop branch
DROP DATABASE BRANCH dev;
-- Switch branch (alternative to \use)
USE BRANCH dev;

Time-Travel Commands

CommandDescription
\snapshotsShow time-travel capabilities
\show lsnShow current LSN (Log Sequence Number)

SQL Time-Travel Queries

-- Query by timestamp
SELECT * FROM orders AS OF TIMESTAMP '2025-01-15 10:00:00';
-- Query by transaction ID
SELECT * FROM orders AS OF TRANSACTION 12345;
-- Query by SCN (System Change Number)
SELECT * FROM orders AS OF SCN 50000;

AI Commands

CommandDescription
\ai templatesList available schema templates
\ai template <name>Show template details
\ai infer <format>Infer schema from data (json, csv, parquet)
\ai generate <description>Generate schema from description
\ai optimize <table>Get AI-powered optimization suggestions
\ai modelsList available AI models
\ai embed <text>Generate embedding for text
\ai compare-schema <s1> <s2>Compare two table schemas

Examples

\ai templates
\ai template e-commerce
\ai infer json
\ai generate "user profiles with social features"
\ai optimize users
\ai models
\ai embed "Hello world"
\ai compare-schema users_v1 users_v2

Agent Session Commands

CommandDescription
\sessionsList all agent sessions
\session new <name>Create new agent session
\session <id>Show session details
\session delete <id>Delete agent session
\chat <session_id>Enter chat mode with session
\session clear <id>Clear session messages
\session fork <id> <name>Fork session with history
\session context <id>Show session context/state
\session memory <id> <query>Semantic search in session memory
\session summarize <id>Generate session summary

Agent Session Features

  • Persistent conversation context
  • Multi-turn AI interactions
  • Schema-aware responses
  • Natural language to SQL conversion
  • Session forking for experimentation
  • Semantic memory search

Vector Commands

CommandDescription
\vectorsList vector stores
\vector <name>Show vector store details
\vector create <name> <dims> [metric]Create vector store
\vector delete <name>Delete vector store
\vector stats <name>Show vector index statistics

Vector Metrics

  • cosine (default) - Cosine similarity
  • euclidean - Euclidean distance
  • dot - Dot product

SQL Vector Operations

-- Create vector column
ALTER TABLE items ADD COLUMN embedding VECTOR(384);
-- Insert vectors
INSERT INTO items (name, embedding) VALUES ('item1', '[0.1, 0.2, ...]');
-- Vector similarity search
SELECT * FROM items
ORDER BY embedding <-> '[0.1, 0.2, ...]'
LIMIT 10;
-- Hybrid search (vector + text)
SELECT * FROM items
WHERE content LIKE '%keyword%'
ORDER BY embedding <-> '[0.1, 0.2, ...]'
LIMIT 10;

Document Commands

CommandDescription
\collectionsList document collections
\collection <name>Show collection details
\docs <collection>List documents in collection
\doc <collection> <id>Show document details
\search <query>Search across all documents
\doc chunks <collection> <id>Show document chunks
\doc rechunk <collection> <id> <size>Re-chunk document
\rag <collection> <query> [k]RAG-style search with context

Document Features

  • Automatic chunking for RAG
  • Vector embeddings for semantic search
  • Metadata filtering
  • Full-text search integration
  • Document re-chunking for optimization
  • RAG search with relevance context

Multi-Tenancy Commands

Tenant Management

CommandDescription
\tenantsList all tenants
\tenant create <name> [plan] [isolation]Create tenant
\tenant use <id/name>Switch tenant context
\tenant <id/name>Show tenant info
\tenant currentShow current tenant context
\tenant clearClear tenant context
\tenant delete <id/name>Delete tenant

Tenant Quotas

CommandDescription
\tenant quota <id/name>Show tenant quotas
\tenant quota set <id> storage=N connections=N qps=NSet quotas
\tenant usage <id/name>Show resource usage

Tenant Plans

CommandDescription
\tenant plansList available plans
\tenant plan info <name>Show plan details
\tenant plan create <name> tier=N storage=N connections=N qps=NCreate plan
\tenant plan edit <id> <field>=<value>Edit plan
\tenant plan enable <id>Enable plan
\tenant plan disable <id>Disable plan
\tenant plan delete <id>Delete plan
\tenant plan <tenant> <plan>Assign plan to tenant

Isolation Levels

  • shared - Shared database, logical isolation via tenant_id
  • schema - Per-tenant schema isolation
  • database - Full database isolation

RLS (Row-Level Security)

CommandDescription
\tenant rls create <table> <policy> <expression> [command]Create RLS policy
\tenant rls list <table>List table policies
\tenant rls delete <table> <policy>Delete policy

RLS Example

\tenant rls create orders tenant_policy "tenant_id = current_tenant()" SELECT
\tenant rls list orders

SQL RLS

-- Enable RLS on table
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
-- Create policy
CREATE POLICY tenant_isolation ON orders
USING (tenant_id = current_tenant());
-- List policies
SELECT * FROM pg_rls_policies();

CDC (Change Data Capture)

CommandDescription
\tenant cdc [limit]Show recent CDC events
\tenant cdc export <file>Export CDC events to file

CDC Features

  • Automatic change tracking
  • Per-tenant event isolation
  • Export for external systems
  • Migration support

Migration Commands

CommandDescription
\tenant migrate to <target>Migrate tenant to new location
\tenant migrate status <tenant>Check migration status

Query Analysis

CommandDescription
\explain <query>Show query execution plan
\profile <query>Profile query with timing

Examples

\explain SELECT * FROM orders WHERE total > 100;
\profile SELECT COUNT(*) FROM large_table;

SQL EXPLAIN

EXPLAIN SELECT * FROM orders WHERE customer_id = 1;
EXPLAIN ANALYZE SELECT * FROM orders WHERE total > 100;
EXPLAIN (FORMAT JSON) SELECT * FROM orders;

Server Management

CommandDescription
\serverShow Server state
\Server stateDetailed server info
\server startStart server (from REPL)
\server stopStop server
\ssl, \ssl statusShow SSL/TLS status

User Management

CommandDescription
\user, \user listList users
\user add <name>Add user
\user remove <name>Remove user
\password <user>Change password

High Availability (HA)

HA System Views

ViewDescription
pg_replication_statusNode configuration and role
pg_replication_standbysConnected standbys (primary only)
pg_replication_primaryPrimary connection (standbys only)
pg_replication_metricsPerformance counters

pg_replication_status

SELECT * FROM pg_replication_status;
ColumnDescription
node_idUnique node identifier
roleprimary, standby, observer, standalone
sync_modeasync, semi-sync, sync
is_read_onlytrue on a standby
current_lsnCurrent log sequence number
standby_countConnected standbys (primary)
primary_hostPrimary this node replicates from (standby)
listen_addrListen address
replication_portWAL streaming port
started_atTime the node started

pg_replication_standbys (Primary Only)

SELECT * FROM pg_replication_standbys;
ColumnDescription
node_idStandby identifier
addressConnection address
stateconnecting, streaming, catching_up, synced, disconnected
lag_bytesReplication lag in bytes
lag_msReplication lag in milliseconds
last_heartbeatLast heartbeat received

pg_replication_primary (Standby Only)

SELECT * FROM pg_replication_primary;
ColumnDescription
primary_node_idPrimary identifier
primary_addressPrimary address
connection_statedisconnected, connecting, connected, streaming, error
primary_lsnPrimary’s current LSN
local_lsnThis standby’s LSN
lag_bytesReplication lag in bytes
lag_msReplication lag in milliseconds
fencing_tokenSplit-brain protection token

pg_replication_metrics

SELECT * FROM pg_replication_metrics;

One row per metric, with the columns metric_name, metric_value and description. Metrics include wal_writes, wal_bytes_written, records_replicated, bytes_replicated, heartbeats_sent, heartbeats_received, reconnect_count, current_lsn, standby_count and ha_enabled.

Write Forwarding from Standbys

With sync or semi-sync mode, a standby forwards writes sent with the simple query protocol (for example from psql) to the primary. Prepared statements (extended query protocol) and REST calls are not forwarded, and forwarding needs trust authentication on the primary; see High Availability.

-- Connect to standby, execute INSERT (forwarded to primary)
INSERT INTO users VALUES (3, 'Charlie');
-- Result: INSERT 0 1 (executed on primary)
-- SELECT always executes locally on standby
SELECT * FROM users;
Sync ModeSELECTINSERT/UPDATE/DELETE
syncLocalForward to primary
semi-syncLocalForward to primary
asyncLocalRejected (read-only)

Example: Monitor Replication

-- Check if standbys are in sync
SELECT
node_id,
CASE
WHEN lag_ms < 1000 THEN 'IN_SYNC'
WHEN lag_ms < 60000 THEN 'CATCHING_UP'
ELSE 'LAGGING'
END as status,
lag_ms
FROM pg_replication_standbys;
-- View node info
SELECT node_id, role, current_lsn FROM pg_replication_status;

Configuration

CommandDescription
\configShow current configuration
\config reloadReload config from file
\setShow session variables
\set <var> <value>Set session variable

SQL Settings

-- Show all settings
SHOW ALL;
-- Show specific setting
SHOW statement_timeout;
-- Set session variable
SET statement_timeout = 30000;
SET optimizer = off;

Keyboard Shortcuts

KeyAction
Ctrl-A / HomeBeginning of line
Ctrl-E / EndEnd of line
Ctrl-B / LeftBack one character
Ctrl-F / RightForward one character
Alt-BBack one word
Alt-FForward one word

Editing

KeyAction
Ctrl-DExit (at empty prompt)
Ctrl-CCancel multi-line input
Ctrl-LClear screen
Ctrl-UDelete to line start
Ctrl-KDelete to line end
Ctrl-WDelete word before cursor

History

KeyAction
Up / Ctrl-PPrevious command
Down / Ctrl-NNext command
Ctrl-RReverse search history
TabAuto-complete

Quick Reference Card

Most Used Commands

\q Exit
\h Help
\d List tables
\d <table> Describe table
\timing Toggle timing
\branches List branches
\use <branch> Switch branch
\tenants List tenants
\tenant use <t> Switch tenant
\explain <sql> Query plan

SQL Quick Reference

-- Create table
CREATE TABLE t (id INT PRIMARY KEY, name TEXT);
-- Insert
INSERT INTO t VALUES (1, 'test');
-- Query
SELECT * FROM t WHERE id = 1;
-- Time-travel
SELECT * FROM t AS OF TIMESTAMP '2025-01-01';
-- Vector search
SELECT * FROM t ORDER BY vec <-> '[0.1,0.2]' LIMIT 5;

See Also