ANN Resource Estimation Guide
Note:
Performance tables, charts, timings, and capacity heuristics on this page are retained from upstream Apache Doris material. They were not measured on VeloDB Cloud. Use them as starting points and validate recall, latency, throughput, and memory on your own workload.
Vector search (ANN) workloads are usually constrained by memory and CPU first, not by disk capacity. This article provides a practical resource estimation method to help you plan the specifications of a VeloDB Cloud vector search cluster before going live.
Quick navigation
- To understand why ANN needs separate estimation: see ANN Resource Characteristics.
- To estimate memory directly: see HNSW Memory Estimation and IVF Memory Estimation.
- To estimate CPU: see CPU Core Estimation.
- To learn about production reservations: see Production Safety Margin.
- To make an index choice: see Scenario-based Recommendations.
Estimation overview
The general estimation order is:
- Estimate index memory: derive the resident index memory from data scale, index type, and quantization mode.
- Estimate CPU cores: match the CPU count to the memory ratio based on target QPS and latency.
- Reserve a safety margin: leave headroom for query execution, non-vector column access, and Compaction.
ANN resource characteristics
Compared with regular OLAP indexes, ANN has the following resource usage characteristics:
| Resource Dimension | Resource Characteristics |
|---|---|
| Build-stage CPU | High utilization. Heavy CPU pressure during ingestion. |
| Build-stage memory | When a Segment is too large, building a single index may fail due to insufficient memory. |
| Query-stage memory | High-performance queries usually require the index to stay resident in memory as much as possible. |
| Query-stage CPU | High-QPS scenarios place a clear demand on the number of CPU cores. |
VeloDB Cloud supports three quantization modes, sq8, sq4, and pq, to reduce memory usage. The trade-offs of quantization are usually:
- Slower ingestion: extra encoding overhead.
- Possibly slower queries: extra decoding or reconstruction overhead.
- Possible recall drop: lossy encoding introduces error.
Estimation input checklist
Before starting the estimation, prepare the following inputs:
| Input | Description |
|---|---|
Vector dimension D | The float dimension of a single vector, for example 768. |
Total rows N | The total number of vectors to be indexed. |
| Index type | hnsw / ivf / ivf_on_disk |
| Quantization mode | flat / sq8 / sq4 / pq |
max_degree | HNSW only. Controls the number of graph neighbors. Default 32. |
| Target QPS and latency | Used for CPU core estimation. |
HNSW memory estimation
Empirical formula under default parameters
With the default max_degree=32:
HNSW_FLAT_Bytes ~= 1.3 * D * 4 * N
Where:
D * 4 * Nis the raw float32 vector memory.1.3represents the extra overhead from the HNSW graph structure (about0.3times).
Adjustment when tuning max_degree
The larger max_degree is, the higher the graph structure overhead. Scale proportionally:
HNSW_factor ~= 1 + 0.3 * (max_degree / 32)
HNSW_FLAT_Bytes ~= HNSW_factor * D * 4 * N
Approximate memory reduction from quantization
| Quantization mode | Encoded vector payload relative to float32 |
|---|---|
sq8 | About 1/4 |
sq4 | About 1/8 |
pq | Usually close to sq4 (for example, pq_m=D/2, pq_nbits=8) |
Notes on ivf_on_disk
ivf_on_disk reuses the training and query parameter model of IVF (nlist / ivf_nprobe), but stores the inverted list body on disk and serves queries through a cache. For capacity planning, you can first treat the IVF estimation below as the upper bound of "fully resident in memory", and discuss list-cache residency separately with VeloDB Cloud support. The cache does not bound total index or process memory.
Payload reference (D=768)
The values below are vector payload only, in decimal GB. They exclude the HNSW graph, row identifiers, allocator overhead, and build/query memory. The earlier FLAT formula is a separate rough total-index heuristic. Do not divide that total by four or eight when quantizing, because the graph does not shrink proportionally.
| Rows | FLAT payload | SQ8 payload | SQ4 payload | PQ payload (m=384, nbits=8) |
|---|---|---|---|---|
| 1M | 3.072 GB | 0.768 GB | 0.384 GB | 0.384 GB |
| 10M | 30.72 GB | 7.68 GB | 3.84 GB | 3.84 GB |
| 100M | 307.2 GB | 76.8 GB | 38.4 GB | 38.4 GB |
| 1B | 3072 GB | 768 GB | 384 GB | 384 GB |
| 10B | 30720 GB | 7680 GB | 3840 GB | 3840 GB |
IVF memory estimation
IVF has lower structural overhead than HNSW and can be approximated as:
IVF_FLAT_Bytes ~= D * 4 * N
The following ratios apply to encoded vector payload. Add IVF identifiers, centroids, codebooks, and allocator overhead to estimate index memory:
| Quantization mode | Encoded vector payload relative to float32 |
|---|---|
sq8 | About 1/4 |
sq4 | About 1/8 |
pq | Usually close to sq4 |
Quick reference (D=768)
These are vector payload estimates in decimal GB. Add identifiers, centroids, codebooks, and execution overhead.
| Rows | FLAT payload | SQ8 payload | SQ4 payload | PQ payload (m=384, nbits=8) |
|---|---|---|---|---|
| 1M | 3.072 GB | 0.768 GB | 0.384 GB | 0.384 GB |
| 10M | 30.72 GB | 7.68 GB | 3.84 GB | 3.84 GB |
| 100M | 307.2 GB | 76.8 GB | 38.4 GB | 38.4 GB |
| 1B | 3072 GB | 768 GB | 384 GB | 384 GB |
| 10B | 30720 GB | 7680 GB | 3840 GB | 3840 GB |
CPU core estimation
The upstream source suggests the following CPU-to-memory ratio as a sizing hypothesis. It is not a Cloud requirement or a throughput model. Measure your workload before choosing cluster capacity:
16 cores : 64 GB (about 1 core : 4 GB)
Note: even when quantization is enabled, CPU demand does not necessarily decrease at the same rate as index memory. In practice:
- First estimate CPU based on the FLAT-equivalent workload.
- Then gradually scale down to a reasonable level based on actual stress testing.
Production safety margin (do not design against 100% memory)
The formulas above estimate payload or index memory, not the full SQL execution overhead. The following query template illustrates projection overhead; replace the table, vector, and row-limit placeholders:
SELECT id, text, l2_distance_approximate(embedding, [...]) AS dist
FROM tbl
ORDER BY dist
LIMIT N;
Even with TopN late materialization, the execution layer still needs additional memory to handle non-vector columns and operator state. In production, the recommendations are:
- As an initial sizing hypothesis, reserve about 30% headroom and use at most about 70% for resident ANN indexes. Validate this against the cluster's effective memory limits and peak build/query workload.
- Use the remaining memory for query execution, Compaction, and other data access.
Scenario-based recommendations
| Scenario | Recommended Plan | Description |
|---|---|---|
| Performance-first with sufficient memory budget | HNSW + FLAT | Start here when memory allows, then measure recall and latency. |
| Memory-constrained | HNSW/IVF + PQ | Compare with SQ8/SQ4 using workload recall, latency, and memory. |
| Initial PQ parameter | pq_m = D / 2 | Fine-tune later based on recall and latency stress tests. |
| Low query performance requirement | Lower CPU configuration first | You can also adopt a "high CPU during ingestion, downsized after stabilization" strategy. |
FAQ
Q1: How much memory can be reduced after enabling quantization?
A: SQ8 vector payload is about one quarter of float32 payload, and SQ4 payload is about one eighth. PQ payload is approximately pq_m * pq_nbits / 8 bytes per vector, with byte rounding. Graphs, identifiers, centroids, codebooks, and execution overhead require additional memory and do not share those compression ratios.
Q2: Can CPU be scaled down at the same ratio as the quantized memory?
A: Not recommended. Quantization mainly reduces memory usage, and CPU demand does not decrease proportionally. It is recommended to first estimate CPU based on the FLAT-equivalent workload, and then scale down based on stress tests.
Q3: How does memory change when max_degree is increased?
A: The earlier heuristic estimates the total-index factor as 1 + 0.3 * (max_degree / 32). For example, when max_degree=64, the factor is about 1.6.
Q4: How much memory should be planned for ivf_on_disk?
A: Budget for cached inverted lists plus centroids, metadata, active queries, and construction. The cache limit bounds list-cache residency, not total process memory. VeloDB Cloud support manages the cache configuration.
Q5: Why should the design not target 100% memory?
A: In addition to the ANN index, the SQL execution layer (non-vector columns, operator state), Compaction, and other access also consume memory. It is recommended to reserve about 30% headroom and keep index memory within 70% of total memory.