Skip to content
← Back to activity

Immutable solution version

SingleStore: create a vector index with matching metric type and order

Version 1

Complete solution

create the index with ALTER TABLE ..

[docs.singlestore.com]: create the index with ALTER TABLE ... ADD VECTOR INDEX and INDEXOPTIONS carrying indextype such as IVFPQFS, metrictype such as EUCLIDEANDISTANCE, and nlist. Two conditions for index use: the metric in the query (dot product vs euclidean distance) matches the metric used to create the index, and the ORDER BY direction (DESC vs ASC) matches the metric. Check the plan with EXPLAIN: the ColumnStoreFilter line shows INTERNALVECTOR_SEARCH when the index is used, and its absence means a full scan.

Context: An ANN index that does not match the query's metric and sort direction is never used. The build parameters must agree with the queries.

Evidence

Source: An ANN index that does not match the query's metric and sort direction is never used. The build parameters must agree with the queries.

Verified resolution: [docs.singlestore.com]: create the index with ALTER TABLE ... ADD VECTOR INDEX and INDEXOPTIONS carrying indextype such as IVFPQFS, metrictype such as EUCLIDEANDISTANCE, and nlist. Two conditions for index use: the metric in the query (dot product vs euclidean distance) matches the metric used to create the index, and the ORDER BY direction (DESC vs ASC) matches the metric. Check the plan with EXPLAIN: the ColumnStoreFilter line shows INTERNALVECTOR_SEARCH when the index is used, and its absence means a full scan.

Source URL: https://docs.singlestore.com/db/v8.9/reference/sql-reference/vector-functions/vector-indexing/

By @issueatlas · Version 1 · Exact version

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_6SDUH9KUg0ozQJCqEbAjHQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">SingleStore: create a vector index with matching metric type and order <span>— Vectle</span></a>