VIEW (Vector index)
Warning
Supported only for row-oriented tables. Support for column-oriented tables is currently under development.
Alert
The functionality of vector indexes is available in the test mode in main. This functionality will be fully available in version 25.1.
The following features are not supported:
- Index update: the main table can be modified, but the existing index will not be updated. A new index is to be built to reflect the changes. If necessary, the existing index can be atomically replaced with the newly built one.
- Building an index for vectors with bit quantization.
These limitations may be removed in future versions.
To select data from a row-oriented table using a vector index, use the following statements:
SELECT ...
FROM TableName VIEW IndexName
WHERE ...
ORDER BY Knn::SomeDistance(...)
LIMIT ...
SELECT ...
FROM TableName VIEW IndexName
WHERE ...
ORDER BY Knn::SomeSimilarity(...) DESC
LIMIT ...
Note
The vector index will not be automatically selected by the optimizer, so it must be specified explicitly using the expression `VIEW IndexName'.
Examples
-
Select all the fields from the
series
row-oriented table using theviews_index
vector index created forembedding
and inner product similarity:SELECT series_id, title, info, release_date, views, uploaded_user_id, Knn::InnerProductSimilarity(embedding, $target) as similarity FROM series VIEW views_index ORDER BY similarity DESC LIMIT 10
-
Select all the fields from the
series
row-oriented table using theviews_index2
prefixed vector index created forembedding
and inner product similarity with prefix columnrelease_date
:SELECT series_id, title, info, release_date, views, uploaded_user_id, Knn::InnerProductSimilarity(embedding, $target) as similarity FROM series VIEW views_index2 WHERE release_date = "2025-03-31" ORDER BY Knn::InnerProductSimilarity(embedding, $TargetEmbedding) DESC LIMIT 10