Three layers of caching: LIRS buffer pool for pages, prepared statement plan cache for parsed queries, and query result cache for repeated reads.
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.
| Property | Value |
|---|---|
| Algorithm | LIRS (patent-free) |
| Page states | LIR (hot), rHIR (resident cold), nHIR (evicted cold) |
| All operations | O(1) amortised |
| Default size | 64 KB (minimal), configurable via --buffer-pool-mb |
| HIR ratio | 1–5% of capacity (tunable) |
# 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';
Parsed and optimised query plans are cached to avoid re-parsing identical queries:
| Property | Value |
|---|---|
| Capacity | 1,024 plans |
| Key | 64-bit hash of normalised SQL text |
| Eviction | LRU |
| Invalidation | Automatic on DDL (table alter/drop/create) |
| Latency reduction | ~85 µs → ~2 µs for cached plans |
-- 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;
Entire query results can be cached with configurable TTL:
| Property | Value |
|---|---|
| Capacity | 1,024 entries, 256 MB total |
| Max per result | 1 MB |
| Key | 64-bit hash of SQL text + parameters |
| TTL | Configurable per query (default: disabled) |
| Invalidation | Automatic on any write to dependent tables |
| Thread safety | Lock-free concurrent reads, exclusive writes |
-- 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
-- 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%';
~154 KB binary · zero external dependencies · 2,737 tests passing