Skip to main content

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​

Estimation overview​

The general estimation order is:

  1. Estimate index memory: derive the resident index memory from data scale, index type, and quantization mode.
  2. Estimate CPU cores: match the CPU count to the memory ratio based on target QPS and latency.
  3. 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 DimensionResource Characteristics
Build-stage CPUHigh utilization. Heavy CPU pressure during ingestion.
Build-stage memoryWhen a Segment is too large, building a single index may fail due to insufficient memory.
Query-stage memoryHigh-performance queries usually require the index to stay resident in memory as much as possible.
Query-stage CPUHigh-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:

InputDescription
Vector dimension DThe float dimension of a single vector, for example 768.
Total rows NThe total number of vectors to be indexed.
Index typehnsw / ivf / ivf_on_disk
Quantization modeflat / sq8 / sq4 / pq
max_degreeHNSW only. Controls the number of graph neighbors. Default 32.
Target QPS and latencyUsed 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 * N is the raw float32 vector memory.
  • 1.3 represents the extra overhead from the HNSW graph structure (about 0.3 times).

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 modeEncoded vector payload relative to float32
sq8About 1/4
sq4About 1/8
pqUsually 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.

RowsFLAT payloadSQ8 payloadSQ4 payloadPQ payload (m=384, nbits=8)
1M3.072 GB0.768 GB0.384 GB0.384 GB
10M30.72 GB7.68 GB3.84 GB3.84 GB
100M307.2 GB76.8 GB38.4 GB38.4 GB
1B3072 GB768 GB384 GB384 GB
10B30720 GB7680 GB3840 GB3840 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 modeEncoded vector payload relative to float32
sq8About 1/4
sq4About 1/8
pqUsually close to sq4

Quick reference (D=768)​

These are vector payload estimates in decimal GB. Add identifiers, centroids, codebooks, and execution overhead.

RowsFLAT payloadSQ8 payloadSQ4 payloadPQ payload (m=384, nbits=8)
1M3.072 GB0.768 GB0.384 GB0.384 GB
10M30.72 GB7.68 GB3.84 GB3.84 GB
100M307.2 GB76.8 GB38.4 GB38.4 GB
1B3072 GB768 GB384 GB384 GB
10B30720 GB7680 GB3840 GB3840 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:

  1. First estimate CPU based on the FLAT-equivalent workload.
  2. 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​

ScenarioRecommended PlanDescription
Performance-first with sufficient memory budgetHNSW + FLATStart here when memory allows, then measure recall and latency.
Memory-constrainedHNSW/IVF + PQCompare with SQ8/SQ4 using workload recall, latency, and memory.
Initial PQ parameterpq_m = D / 2Fine-tune later based on recall and latency stress tests.
Low query performance requirementLower CPU configuration firstYou 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.