Performance Tuning
Use these steps to size hardware, tune configuration, and keep query latency predictable.
Tuning quick-start
- Set concurrency: Align
THREAD_COUNTwith available CPU cores for write-heavy or analytical workloads. - Control cache churn: Increase
CACHE_SIZEfor highly diverse parameterized queries. - Bound work: Use
TIMEOUT_DEFAULTandTIMEOUT_MAXto cap long-running queries; setMAX_QUEUED_QUERIESto protect memory under load. - Size results: Cap responses with
RESULTSET_SIZEandQUERY_MEM_CAPACITYso runaway queries fail fast. - Profile before shipping: run
GRAPH.PROFILEandGRAPH.EXPLAINto validate query plans.
Query patterns
- Prefer parameterized queries to maximize plan cache hit rate and reduce parse/plan overhead.
- Add indexes before tuning hardware: see range indexes, full-text, and vector indexes.
- Keep projections narrow: return only needed fields; paginate with
SKIP/LIMIT. - Avoid Cartesian products: ensure patterns are selective and anchored with labels/properties.
Concurrency and scheduling
- Keep
THREAD_COUNTnear physical cores for balanced workloads; lower it if you see CPU saturation from many concurrent writes. - Increase
MAX_QUEUED_QUERIEScautiously to avoid memory bloat; combine with timeouts to shed load gracefully. - For mixed workloads, reserve a dedicated FalkorDB instance for heavy analytics so OLTP queries stay predictable.
Memory and result sizing
- Tune
RESULTSET_SIZEto prevent accidental full-graph scans from overwhelming clients. - For large bulk inserts, stage writes and batch in transactions rather than single huge queries to reduce peak memory.
- Monitor memory after raising
CACHE_SIZE; higher caches improve plan reuse but consume RAM.
Observability loop
- Track query latency, queue depth, and timeout counts in your monitoring stack.
- Re-run
GRAPH.PROFILEafter schema or index changes; plan shape and cost can shift when data distributions change. - Baseline throughput for representative datasets and queries, then document expected SLOs for teams.