Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

Vector Search

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.

VeloDB Cloud supports approximate nearest neighbor (ANN) search with Faiss-based HNSW, IVF, and disk-backed IVF indexes. Use ANN to trade some recall for lower search cost. Latency and capacity depend on the dataset, index parameters, and cluster resources. Core 26.1 is in Public Preview.

Applicable scenarios​

Vector search is the core capability behind RAG (Retrieval-Augmented Generation) and multimodal retrieval. Typical applications include:

  • RAG retrieval: Retrieve the Top-K text snippets most relevant to a user query from a large knowledge base, and use them as the basis for LLM generation. This mitigates hallucination and knowledge-staleness issues.
  • Multimodal retrieval: Encode images, audio, video, and other data into vectors for semantic similarity queries. For example, in medical Q&A, retrieve case records and literature to assist diagnostic suggestions.
  • Recommendation systems: Use range search to retrieve "similar but not identical" candidate content, improving recommendation diversity.
  • Anomaly detection: Locate data points that deviate from normal patterns.

The essence of vector retrieval is: encode the query and documents into semantic vectors using the same scheme, then find the K vectors most similar to the query from a large vector collection.

Quick navigation​

ScenarioSection
Learn how to create a vector indexApproximate Nearest Neighbor Search
Implement Cosine similarity retrievalUse cosine similarity
Filter by distance thresholdApproximate Range Search
Combine TopN with range conditionsCompound Search
Filter by other columns before ANN retrievalANN Search with Filters
Tune query behavior parametersQuery Parameters
Save memory and reduce index sizeVector Quantization
Improve QPS and reduce latencyPerformance Tuning
Use the Python SDKPython SDK
Learn about usage limitationsUsage Limitations

VeloDB Cloud does not introduce a new data type. Vectors are stored as fixed-length Array<Float>, and a Faiss-based ANN index type is provided for distance retrieval.

Table creation example​

Create a table for 128-dimensional SIFT vectors

Take the common SIFT dataset as an example:

CREATE TABLE sift_1M (
id int NOT NULL,
embedding array<float> NOT NULL COMMENT "",
INDEX ann_index (embedding) USING ANN PROPERTIES(
"index_type"="hnsw",
"metric_type"="l2_distance",
"dim"="128",
"quantizer"="flat"
)
) ENGINE=OLAP
DUPLICATE KEY(id) COMMENT "OLAP"
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);

Meaning of each core parameter:

  • index_type: The index algorithm. Options are hnsw (Hierarchical Navigable Small World), ivf (Inverted File index), or ivf_on_disk (an IVF variant whose inverted lists are written to disk and served through a cache).
  • metric_type: The distance metric. l2_distance means using L2 distance as the distance function.
  • dim: The vector dimension. 128 means each vector in this column has length 128.
  • quantizer: The encoding scheme. flat means each dimension is stored as the original float32 value.

Full index parameters​

ParameterRequiredSupported / Optional ValuesDefaultDescription
index_typeYeshnsw, ivf, ivf_on_disk(none)Specifies the ANN index algorithm. Currently HNSW, in-memory IVF, and IVF On-Disk are supported.
metric_typeYesl2_distance, inner_product(none)Specifies the vector similarity / distance metric. l2_distance is Euclidean distance. inner_product can be used for cosine similarity scenarios, but the vectors must be normalized first.
dimYesPositive integer (> 0)(none)Specifies the vector dimension. All vectors loaded later must have the same dimension, otherwise an error is reported.
nlistYes for IVF variantsPositive integerNoneNumber of inverted buckets in IVF. Takes effect when index_type=ivf or ivf_on_disk. Tune it together with ivf_nprobe; a larger value alone does not guarantee higher recall.
max_degreeNoPositive integer32Maximum number of neighbors per node in the HNSW graph (M). Affects index memory usage and search performance.
ef_constructionNoPositive integer40Size of the candidate queue during HNSW construction (efConstruction). A larger value yields a higher-quality graph but slower build.
quantizerNoflat, sq8, sq4, pqflatVector encoding / quantization scheme. flat: original storage. sq8 / sq4: scalar quantization (8 / 4 bit). pq: product quantization.
pq_mRequired when quantizer=pqPositive integer(none)The number of sub-vectors the original high-dimensional vector is split into. dim must be divisible by pq_m.
pq_nbitsNoInteger from 1 to 248 in Core 26.1.3The number of bits used to quantize each sub-vector, which determines the codebook size of the subspace (k = 2 ^ pq_nbits). Core validates a positive value no greater than 24.

Load data​

Use a test database with table-creation, load, and query privileges. Loading data and building indexes consume compute and storage. Drop the example tables when finished.

The upstream example uses a copy of the SIFT dataset hosted in China. For use in your warehouse, obtain the SIFT dataset, prepare tab-separated id and 128-dimensional embedding columns, and place the file in object storage accessible to the warehouse. Replace <sift-data-url> below and add the authentication properties required for your storage:

INSERT INTO sift_1M
SELECT *
FROM S3(
"uri" = "<sift-data-url>",
"format" = "csv");

SELECT count(*) FROM sift_1M;

Expected count for the complete SIFT base dataset:

+----------+
| count(*) |
+----------+
| 1000000 |
+----------+

Query example​

Retrieve the ten nearest vectors

Calling l2_distance_approximate / inner_product_approximate triggers the ANN index path.

Calling rules:

  • The function name must exactly match the index metric_type:
    • metric_type=l2_distance → use l2_distance_approximate
    • metric_type=inner_product → use inner_product_approximate
  • Sort order:
    • L2 distance uses ascending order (ORDER BY dist ASC, smaller is closer).
    • Inner product uses descending order (ORDER BY dist DESC, larger is closer).
SELECT id,
l2_distance_approximate(
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
) AS distance
FROM sift_1M
ORDER BY distance
LIMIT 10;
--------------

+--------+----------+
| id | distance |
+--------+----------+
| 178811 | 210.1595 |
| 177646 | 217.0161 |
| 181997 | 218.5406 |
| 181605 | 219.2989 |
| 821938 | 221.7228 |
| 807785 | 226.7135 |
| 716433 | 227.3148 |
| 358802 | 230.7314 |
| 803100 | 230.9112 |
| 866737 | 231.6441 |
+--------+----------+
10 rows in set (0.02 sec)

To compare with exact results, use l2_distance / inner_product (without the _approximate suffix). The upstream example reported about 290 ms for exact search and about 20 ms with the ANN index. These are illustrative measurements, not predicted warehouse timings.

10 rows in set (0.29 sec)

Execution mechanism​

The ANN index is built at the segment granularity. In a distributed table:

  1. Each segment returns its local TopN results.
  2. The TopN operator merges results across tablets and segments to produce the global TopN.

Use cosine similarity​

The VeloDB Cloud ANN index metric_type currently supports only l2_distance and inner_product, and does not directly support cosine. When the business metric is cosine similarity, you can convert it equivalently to inner product through normalization.

Steps​

  1. Before writing: L2-normalize the vectors (normalize to unit length).
  2. When creating the index: Use metric_type="inner_product".
  3. When querying: Use inner_product_approximate(...), sorted by ORDER BY ... DESC.

Example:

CREATE INDEX idx_emb_cosine ON your_table (embedding) USING ANN PROPERTIES (
"index_type"="hnsw",
"metric_type"="inner_product",
"dim"="768"
);

Equivalence rationale​

  • Cosine similarity formula: cos(x, y) = (x · y) / (||x|| ||y||)
  • When the vectors are L2-normalized (||x|| = ||y|| = 1): cos(x, y) = x · y

Therefore, in unit-vector space, maximizing cosine similarity is equivalent to maximizing inner product. Without normalization, inner product and cosine are no longer equivalent.


Beyond TopN nearest-neighbor search, vector retrieval has another common query type: range search based on a distance threshold. Such a query does not return a fixed number of rows. Instead, it finds all data points whose distance to the target vector satisfies the condition.

Typical applications:

  • In recommendation systems, retrieve content that is "close but not identical" to increase diversity.
  • In anomaly detection, locate data points that deviate from normal patterns.

Example: count rows whose L2 distance to the target vector is greater than 300:

SELECT count(*)
FROM sift_1M
WHERE l2_distance_approximate(
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2])
> 300
--------------

+----------+
| count(*) |
+----------+
| 999271 |
+----------+
1 row in set (0.19 sec)

Range search is also accelerated by the ANN index: the system first quickly screens a candidate vector set, and then computes the precise approximate distance, significantly reducing overhead. The currently supported range conditions are: >, >=, <, <=.


Compound search refers to performing both ANN TopN and range filtering in the same SQL statement, returning the TopN that satisfies the range constraint.

SELECT id,
l2_distance_approximate(
embedding, [0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]) as dist
FROM sift_1M
WHERE l2_distance_approximate(
embedding, [0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2])
> 300
ORDER BY dist limit 10
--------------

+--------+----------+
| id | dist |
+--------+----------+
| 243590 | 300.005 |
| 549298 | 300.0317 |
| 429685 | 300.0533 |
| 690172 | 300.0916 |
| 123410 | 300.1333 |
| 232540 | 300.1649 |
| 547696 | 300.2066 |
| 855437 | 300.2782 |
| 589017 | 300.3048 |
| 930696 | 300.3381 |
+--------+----------+
10 rows in set (0.12 sec)

Pre-filter vs post-filter​

StrategyMeaningProsCons
Pre-filter (used by the query engine)Apply the predicate first, then take the TopN over the remaining setHigh recallRelatively slow
Post-filterTake the TopN first, then filterFastMay significantly reduce recall

In VeloDB Cloud, both stages of compound search can be accelerated by indexes. However, in some scenarios (for example, when the first-stage range filter is highly selective), using indexes for both stages may reduce recall. VeloDB Cloud adaptively decides whether to use indexes for both stages based on the predicate selectivity and the index type.


ANN search with filters​

ANN search with filters means: apply other predicates before performing ANN TopN, and return the TopN that satisfies the conditions.

The following 8-dimensional example illustrates the hybrid search workflow:

CREATE TABLE ann_with_fulltext (
id int NOT NULL,
embedding array<float> NOT NULL,
comment String NOT NULL,
value int NULL,
INDEX idx_comment(`comment`) USING INVERTED PROPERTIES("parser" = "english") COMMENT 'inverted index for comment',
INDEX ann_embedding(`embedding`) USING ANN PROPERTIES("index_type"="hnsw","metric_type"="l2_distance","dim"="8")
) DUPLICATE KEY (`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES("replication_num"="1");

INSERT INTO ann_with_fulltext VALUES
(1, [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8], 'this is about music', 10),
(2, [0.2,0.1,0.5,0.3,0.9,0.4,0.7,0.1], 'sports news today', 20),
(3, [0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2], 'latest music trend', 30),
(4, [0.05,0.06,0.07,0.08,0.09,0.1,0.2,0.3], 'politics update',40)

Given a user query vector [0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4], retrieve the top 2 most similar documents only among those whose comment contains "music":

SELECT id, comment,
l2_distance_approximate(embedding, [0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4]) AS dist
FROM ann_with_fulltext
WHERE comment MATCH_ANY 'music' -- Filter using the inverted index first
ORDER BY dist ASC -- Then perform ANN TopN over the filtered result set
LIMIT 2;

+------+---------------------+----------+
| id | comment | dist |
+------+---------------------+----------+
| 1 | this is about music | 0.663325 |
| 3 | latest music trend | 1.280625 |
+------+---------------------+----------+
2 rows in set (0.04 sec)

Tip:

For ANN search with filters to leverage the vector index for TopN acceleration, the filter columns involved must have a secondary index such as an inverted index.


Query parameters​

In addition to the parameters specified when building the HNSW index, the query stage can also adjust behavior through session variables:

Session variableDefaultDescription
hnsw_ef_search32The EF search parameter of the HNSW index. Controls the maximum length of the candidates queue during search. A larger value yields higher accuracy at the cost of higher latency.
hnsw_check_relative_distancetrueWhether to enable the relative distance check mechanism to improve HNSW search accuracy.
hnsw_bounded_queuetrueWhether to use a bounded priority queue to optimize HNSW search performance.

Vector quantization​

With FLAT encoding, an HNSW index (original vectors plus the graph structure) can consume a large amount of memory. HNSW must be fully resident in memory to work, so it easily becomes a bottleneck on very large datasets.

VeloDB Cloud provides two categories of quantization schemes:

QuantizationPrincipleSupported encoding
Scalar Quantization (SQ)Compresses each FLOAT32 dimension to reduce memory overheadsq8 (INT8), sq4 (INT4)
Product Quantization (PQ)Decomposes a high-dimensional vector and quantizes each sub-vector separatelypq

Scalar quantization (SQ) example​

Scalar quantization (SQ) example
CREATE TABLE sift_1M (
id int NOT NULL,
embedding array<float> NOT NULL COMMENT "",
INDEX ann_index (embedding) USING ANN PROPERTIES(
"index_type"="hnsw",
"metric_type"="l2_distance",
"dim"="128",
"quantizer"="sq8" -- Use INT8 for quantization
)
) ENGINE=OLAP
DUPLICATE KEY(id) COMMENT "OLAP"
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);

In tests on the 768-dimensional Cohere-MEDIUM-1M and Cohere-LARGE-10M datasets, SQ8 compresses the index size to about 1/3 of FLAT.

Quantization comparison​

DatasetVector DimensionStorage / Index SchemeTotal Disk UsageData PartIndex PartNotes
Cohere-MEDIUM-1M768DDoris (FLAT)5.647 GB (2.533 + 3.114)2.533 GB3.114 GB1M vectors, raw + HNSW FLAT index
Cohere-MEDIUM-1M768DDoris SQ INT83.501 GB (2.533 + 0.992)2.533 GB0.992 GBINT8 symmetric quantization
Cohere-MEDIUM-1M768DDoris PQ (pq_m=384, pq_nbits=8)3.149 GB (2.535 + 0.614)2.535 GB0.614 GBProduct quantization
Cohere-LARGE-10M768DDoris (FLAT)56.472 GB (25.328 + 31.145)25.328 GB31.145 GB10M vectors
Cohere-LARGE-10M768DDoris SQ INT835.016 GB (25.329 + 9.687)25.329 GB9.687 GBINT8 quantization, index significantly smaller

Product quantization (PQ)​

VeloDB Cloud also supports product quantization, but using PQ requires extra parameters:

  • pq_m: The number of sub-vectors the original high-dimensional vector is split into. The vector dimension dim must be divisible by pq_m.
  • pq_nbits: The number of bits used to quantize each sub-vector, which determines the codebook size of the subspace. Core validates a positive value no greater than 24.

Note:

PQ quantization has training-data requirements during the training phase: at least as many points as there are cluster centers. That is, the number of training points n >= 2 ^ pq_nbits.

CREATE TABLE sift_1M (
id int NOT NULL,
embedding array<float> NOT NULL COMMENT "",
INDEX ann_index (embedding) USING ANN PROPERTIES(
"index_type"="hnsw",
"metric_type"="l2_distance",
"dim"="128",
"quantizer"="pq", -- Use PQ for quantization
"pq_m"="2", -- Required when using PQ. Number of low-dim sub-vectors the high-dim vector is split into
"pq_nbits"="2" -- Bits per subspace codebook (defaults to 8)
)
) ENGINE=OLAP
DUPLICATE KEY(id) COMMENT "OLAP"
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);

Cost of quantization​

The build-time chart is an upstream observation. The full source environment is not provided, and the relative cost must be measured on your workload.

Quantization introduces extra build overhead: the build phase requires many distance computations, and each computation must decode the quantized values. For 128-dimensional vectors, build time grows with the row count, and SQ may introduce roughly 10x build cost compared to FLAT.

ANN-SQ-BUILD_COSTS


Tune performance​

The following upstream Apache Doris measurements use the Cohere-MEDIUM-1M dataset with 32-core, 64-GB frontend and backend machines. They are workload-specific observations, not VeloDB Cloud performance targets. Use your warehouse workload to evaluate tuning changes.

Query performance benchmarks​

ConcurrencySchemeQPSAvg Latency (s)P99 Latency (s)CPU UsageRecall
240Doris3340.43990.0713681680.16339982540%91.00%
240Doris SQ INT83188.63590.0747288520.16037019540%88.26%
240Doris SQ INT42818.22910.0846638680.17482681543%80.38%
240Doris brute-force3.678725.55487882629.363227973100%100.00%
480Doris4155.72200.1133872710.26108607560%91.00%
480Doris SQ INT83833.11300.1230402140.27691286750%88.26%
480Doris SQ INT43431.05380.1376369950.28163124957%80.38%
480Doris brute-force3.678725.55487882629.363227973100%100.00%

Use prepared statements​

Common embedding-model outputs are typically 768 dimensions or higher. If you embed such a vector as a literal directly in SQL, parsing time may exceed actual execution time. Therefore, prepared statements are recommended. Use a client that supports server-side prepared statements, such as JDBC.

  1. Enable server-side prepared statements in the JDBC URL. Replace the host, MySQL port, and database with the values for your warehouse. Use its documented TLS connection settings.

    jdbc:mysql://<warehouse-host>:<mysql-port>/<database-name>?useServerPrepStmts=true&sslMode=VERIFY_IDENTITY
  2. Use the prepared statement.

    String sql = "SELECT id, l2_distance_approximate(embedding, "
    + "CAST(? AS ARRAY<FLOAT>)) AS distance FROM sift_1M "
    + "ORDER BY distance LIMIT 10";
    PreparedStatement statement = conn.prepareStatement(sql);
    // queryVectorJson must contain 128 numeric values for this table.
    statement.setString(1, queryVectorJson);
    ResultSet resultSet = statement.executeQuery();

Reduce the number of segments​

The VeloDB Cloud ANN index is built on segments. Too many segments introduce extra overhead.

Smaller ingestion batches can create more segments and increase query overhead. Compare representative batch sizes and inspect query profiles. Segment sizing and compaction are managed by the service. Contact VeloDB Cloud support for changes to write_buffer_size or vertical_compaction_max_segment_size; there is no universal five-segment or 10-GB setting for every workload.

Reduce the number of rowsets​

Each load creates one rowset, and too many rowsets also increase scheduling overhead. Use Stream Load or INSERT INTO SELECT for batch loading.

Keep ANN indexes resident in memory​

HNSW and in-memory IVF need memory for the queried index. Disk-backed IVF loads inverted lists through a cache. Choose cluster capacity and quantization using measured memory, recall, and latency. Cache retention is managed by the service; contact VeloDB Cloud support rather than editing be.conf.

parallel_pipeline_task_num = 1​

ANN TopN queries return very few rows and do not need high parallelism. Test a value of 1 against the effective setting and compare latency and throughput:

SET parallel_pipeline_task_num = 1;

enable_profile = false​

If latency is extremely sensitive, disable the query profile:

SET enable_profile = false;

Python SDK​

The Apache Doris community provides a Python vector-search library:

  • doris_vector_search: Optimized for vector distance retrieval. A community-maintained library, not an official VeloDB Cloud SDK. Review compatibility and connection security before using it.

Usage limitations​

When using the VeloDB Cloud vector index, note the following limitations:

  1. Data type limitation: The column on which an ANN Index is built must be a NOT NULLABLE Array<Float>. During data load, the length of every vector in this column must equal the dimension specified in the index property (dim), otherwise an error is reported.

  2. Table model limitation: ANN Index can only be used on the DUPLICATE KEY table model, or on a UNIQUE KEY table with merge-on-write enabled (enable_unique_key_merge_on_write = true). Support for UNIQUE KEY merge-on-write tables was added in Core 26.1.3. Merge-on-read UNIQUE KEY tables and AGGREGATE KEY tables are still unsupported; creating an index on them reports: ANN index can only be used in DUP_KEYS table or UNIQUE_KEYS table with merge-on-write enabled.

  3. Predicate columns must have a secondary index: VeloDB Cloud uses pre-filter semantics (predicates are evaluated before AnnTopN). When the columns referenced by predicates in the SQL do not have a secondary index, VeloDB Cloud falls back to brute-force computation to ensure correctness. For example:

    SELECT id, l2_distance_approximate(embedding, array_repeat(0.1, 128)) AS distance
    FROM sift_1M
    WHERE round(id) > 100
    ORDER BY distance limit 10;

    Although id is a sort-key column, no secondary index (such as inverted) that can precisely locate row numbers has been built on this column. Such predicates are evaluated after index analysis. To preserve the pre-filter semantics of ANN TopN, the system falls back to brute-force computation.

  4. The distance function must match the metric type: If the distance function used in the SQL does not match the metric_type of the index defined in the DDL, VeloDB Cloud cannot use the ANN index for TopN computation (even when you use l2_distance_approximate / inner_product_approximate).

  5. inner_product must use DESC sorting: When metric_type is inner_product, only ORDER BY inner_product_approximate() DESC LIMIT N (DESC cannot be omitted) can be accelerated by the ANN index.

  6. Function argument order: The xxx_approximate() function triggers index analysis only when the first argument is a ColumnArray and the second argument is a CAST or ArrayLiteral. Swapping the order causes a fallback to brute-force search.


FAQ​

Q1: Which distance metrics does the VeloDB Cloud ANN index support?​

Currently l2_distance (Euclidean distance) and inner_product are supported. For cosine similarity, see the Use cosine similarity section.

Q2: Why does my ANN query not use the index?​

Possible reasons:

  • The distance function does not match the metric_type.
  • When using inner_product, ORDER BY ... DESC was not used.
  • Function argument order is reversed (ColumnArray must be the first argument).
  • The filter columns lack a secondary index such as an inverted index, triggering a brute-force fallback.

Q3: How do I choose between HNSW, IVF, and IVF on-disk?​

IndexMemory UsageQuery PerformanceApplicable Scenarios
HNSWHigh (must be fully resident in memory)HighSmall-to-medium scale, strong low-latency requirements
IVFMediumMediumLarge-scale data
IVF On-DiskLow (on-disk + cache)MediumVery large-scale data, memory-constrained

Q4: What if I do not have enough memory?​

Reduce memory usage through quantization:

  • Try sq8 (INT8 scalar quantization) first. It typically compresses the index to about 1/3 of the original size with limited recall impact.
  • When memory is very tight, use sq4 or pq, but recall will drop somewhat.

Q5: How do I combine keyword filtering with vector retrieval?​

Build an inverted index on the filter columns, then use an ANN query with a WHERE clause. See ANN Search with Filters.

Q6: How do I improve QPS?​

See the Performance Tuning section. Key points:

  • Use prepared statements to avoid SQL parsing overhead.
  • Reduce the number of segments and rowsets.
  • Keep the ANN index resident in memory.
  • parallel_pipeline_task_num = 1.
  • Disable query profiling after diagnostics if measuring shows material overhead.