Memory Compaction
What it is
Section titled “What it is”When you update or delete rows, AetheriusDB writes new versions rather than overwriting in place. Over time the old versions become unreachable — they occupy memory with nothing referencing them. The compactor is the background process that reclaims that space and keeps the live data packed together so scans stay fast.
It runs automatically. You do not schedule it or trigger it for routine operation.
Why it matters
Section titled “Why it matters”Most databases make compaction loud: long stop-the-world pauses or noisy bursts of disk activity. AetheriusDB’s compactor runs continuously in the background, repacking only the regions that need it, and never pauses your queries to do so.
- No GC pauses — compaction is incremental and reactive, not a scheduled stall.
- Steady query speed — keeping live data contiguous keeps scans fast as tables churn.
- No query interference — in-flight scans keep their consistent snapshot; new scans see the compacted layout.
How you use it
Section titled “How you use it”The compactor runs on its own. You can inspect how much space is reclaimable, force a pass before a benchmark or audit, and tune how aggressively it works on specific tables.
-- See how much memory is reclaimable across the database.SELECT table_name, live_bytes, orphaned_bytes, round(orphaned_bytes * 100.0 / (live_bytes + orphaned_bytes), 1) AS waste_pct FROM aetherius_system.memory_fragmentation ORDER BY orphaned_bytes DESC;
-- Force a compaction pass on a heavily-updated table.COMPACT TABLE sessions;
-- Adjust how aggressively the background compactor handles a table.ALTER TABLE hot_updates SET compaction_target_pct = 75; -- repack when live share drops below 75%
-- Inspect recent compactor activity.SHOW COMPACTION STATUS;The fragmentation view is your primary signal — sustained waste above roughly 30% is worth tuning. Forcing a compaction on a single table is cheap; forcing it across everything at once is not, so save explicit compaction for the tables that need it.
Reclaiming disk and shrinking the resident set
Section titled “Reclaiming disk and shrinking the resident set”Two more knobs govern space beyond live-row compaction:
DROP TABLEreclaims disk immediately. Dropping a table unlinks its dedicated container (so the bytes are freed at once and can’t resurface on restart); tables that share a container are compacted out, keeping only the survivors. No manualVACUUMstep is required.- Resident LZ4 compression (opt-in). Start the daemon with
AETHERIUS_COMPRESS_RESIDENT=1to keep sealed cubes LZ4-compressed in RAM, decompressing them on scan. This trades a little read CPU for a smaller memory footprint; results are identical. The default keeps cubes uncompressed for zero-copy reads. For write-side memory pressure during large loads, seeAETHERIUS_INGEST_SPILLin Configuration.