Documentation

Caching

Three layers of caching: LIRS buffer pool for pages, prepared statement plan cache for parsed queries, and query result cache for repeated reads.

LIRS Buffer Pool

The buffer pool keeps frequently accessed disk pages in memory. Absolute DB uses the LIRS (Low Inter-reference Recency Set) algorithm, which outperforms LRU by distinguishing between frequently and infrequently referenced pages.

PropertyValue
AlgorithmLIRS (patent-free)
Page statesLIR (hot), rHIR (resident cold), nHIR (evicted cold)
All operationsO(1) amortised
Default size64 KB (minimal), configurable via --buffer-pool-mb
HIR ratio1–5% of capacity (tunable)
bash
# Set buffer pool to 4 GB
absdb-server --buffer-pool-mb 4096

# Check hit rate
SELECT * FROM absdb_stats WHERE name = 'buffer_pool_hit_rate';

Prepared Statement Plan Cache

Parsed and optimised query plans are cached to avoid re-parsing identical queries:

PropertyValue
Capacity1,024 plans
Key64-bit hash of normalised SQL text
EvictionLRU
InvalidationAutomatic on DDL (table alter/drop/create)
Latency reduction~85 µs → ~2 µs for cached plans
sql
-- Use prepared statements for plan caching
PREPARE get_user AS SELECT * FROM users WHERE id = $1;
EXECUTE get_user(42);
EXECUTE get_user(99);  -- uses cached plan

-- Deallocate when done
DEALLOCATE get_user;

Query Result Cache

Entire query results can be cached with configurable TTL:

PropertyValue
Capacity1,024 entries, 256 MB total
Max per result1 MB
Key64-bit hash of SQL text + parameters
TTLConfigurable per query (default: disabled)
InvalidationAutomatic on any write to dependent tables
Thread safetyLock-free concurrent reads, exclusive writes
sql
-- Cache this query result for 60 seconds
SELECT /*+CACHE(ttl=60)*/ region, SUM(revenue)
FROM sales
GROUP BY region;

-- Next identical query within 60s returns cached result instantly
-- Any INSERT/UPDATE/DELETE on 'sales' invalidates the cache entry

Cache Statistics

sql
-- Buffer pool stats
SELECT * FROM absdb_stats WHERE name LIKE 'buffer_pool%';

-- Plan cache stats
SELECT * FROM absdb_stats WHERE name LIKE 'plan_cache%';

-- Result cache stats
SELECT * FROM absdb_stats WHERE name LIKE 'qcache%';

Ready to run Absolute DB?

~154 KB binary · zero external dependencies · 2,737 tests passing

Download Free → View Pricing