Skip to content

In-Memory Mode Quick Reference

In-Memory Mode Quick Reference

Available since: v3.6.0 Flag: --memory Persistence: none (unless paired with --dump-on-shutdown)


UVP

Spinning up a fresh database for every CI run is the single most common source of flaky tests. HeliosDB Nano’s --memory flag drops the entire LSM stack into RAM — zero disk I/O, zero filesystem permissions, instant start — while keeping the full PostgreSQL wire protocol, REST API, vector search, and BaaS surface intact. Same SQL, same drivers, same client code as production. Pair with --dump-on-shutdown when you want a snapshot at exit. Sub-second test setup, no cleanup.


Start the Server

Terminal window
heliosdb-nano start --memory

Three protocols come up exactly as in disk mode:

ProtocolPort
PostgreSQL wire5432
MySQL wire (with --mysql)3306
REST / HTTP8080

Add auth if your test code expects it:

Terminal window
heliosdb-nano start --memory --auth scram-sha-256 --password s3cret

REPL — Ephemeral Sandbox

Terminal window
heliosdb-nano repl --memory
heliosdb> CREATE TABLE t (id SERIAL PRIMARY KEY, name TEXT);
heliosdb> INSERT INTO t (name) VALUES ('hello');
heliosdb> \q
# Database vanishes on exit

Embedded API — Same Pattern

When using HeliosDB Nano as a library:

use heliosdb_nano::EmbeddedDatabase;
let db = EmbeddedDatabase::new_in_memory()?;
db.execute("CREATE TABLE users (id INT, name TEXT)")?;
db.execute("INSERT INTO users VALUES (1, 'Alice')")?;
let rows = db.query("SELECT * FROM users", &[])?;

EmbeddedDatabase::new_in_memory() is the in-memory equivalent of EmbeddedDatabase::new(path) — same EmbeddedDatabase type, same methods, same vector / branching / time-travel features.


Use Cases

CI — fast database setup per test job

.github/workflows/test.yml
- name: Start Nano
run: |
heliosdb-nano start --memory --daemon
sleep 1
- name: Run integration tests
run: pytest tests/

No volume mount, no cleanup step, no flaky teardown.

Ephemeral dev environment

Terminal window
# Spin up Nano + REST API on localhost in 100 ms; throw it away on Ctrl-C
heliosdb-nano start --memory --auth trust

Fixture-based tests (Python)

import pytest, psycopg2, subprocess, time
@pytest.fixture
def db():
p = subprocess.Popen(["heliosdb-nano", "start", "--memory", "--auth", "trust"])
time.sleep(0.5)
conn = psycopg2.connect("postgresql://postgres@127.0.0.1:5432/postgres")
yield conn
conn.close()
p.terminate()
def test_insert(db):
cur = db.cursor()
cur.execute("CREATE TABLE t (id INT, name TEXT)")
cur.execute("INSERT INTO t VALUES (1, 'x')")
cur.execute("SELECT count(*) FROM t")
assert cur.fetchone()[0] == 1

Snapshot-on-exit (when you do want persistence)

Terminal window
heliosdb-nano start --memory --dump-on-shutdown
# Ctrl-C writes ./shutdown_dump.heliodump

Restore later via heliosdb-nano restore --input shutdown_dump.heliodump --target ./data.


What’s the Same

  • Full PostgreSQL wire protocol, MySQL wire protocol, REST API, BaaS auth
  • Vector search (HNSW), branching, time-travel queries
  • RLS policies, triggers, CTEs, window functions
  • Every clippy / SQL-spec regression test in the suite

What’s Different

AspectDisk modeMemory mode
PersistenceYes (RocksDB)No
WAL fsyncYesNo (no WAL)
Crash recoveryYesN/A — process exit = data loss
--data-dirRequiredForbidden (mutually exclusive)
dump CLI commandWorksErrors — use --dump-on-shutdown instead
Maximum DB sizeDisk spaceAvailable RAM

Limits & Trade-offs

  • All data fits in RAM. A 4 GiB heap holds roughly 4 GiB of rows; no spilling to disk.
  • No PITR / time-travel beyond process lifetime. AS OF queries work within the running process; once the process exits, the history is gone.
  • No HA replication. Tier 1 standby requires a WAL stream from the primary. Memory mode has no WAL.
  • No dump from a live memory DB. Use --dump-on-shutdown (graceful exit) or implement a periodic SQL COPY to disk.

Troubleshooting

SymptomCauseFix
Either --data-dir or --memory must be specifiedNeither flag passedAdd one of them
Cannot dump from in-memory database without data directoryTried heliosdb-nano dump --memoryUse start --memory --dump-on-shutdown
OOM-killed under loadWorking set exceeds RAMReduce dataset, run with disk mode, or run with more memory
Tests pass locally, fail in CICI has stricter memory limitsBump CI runner memory or switch to --data-dir /tmp

Where Next