Querying a Table using a Vector Index
The Vector index is used automatically when all the following conditions are true:
• An SQL query selects from a table which has a Vector index.
• The query performs an ORDER BY on the result of a Vector_DISTANCE() call between an indexed Vector-typed column in that table and a constant Vector value.
• The distance metric passed to the Vector_DISTANCE() call is compatible with the distance metric with which the Vector index was created. This means either the query’s distance metric must match the Vector index’s distance metric, or if the Vector index’s metric is EUCLIDEAN_SQUARED the query’s metric may be EUCLIDEAN_SQUARED or EUCLIDEAN.
• The SQL query asks for the top N results with FETCH APPROX FIRST <n> ROWS ONLY.
If any of the above conditions are not met, the Vector index is not used and an exact search is performed instead.
The results from the Vector index search will internally be joined to the table to perform a final reordering step and to project any additional table columns the query asks for. For this reason, creating a secondary index on the table's primary key, in addition to the vector index, may improve “FETCH APPROX” query performance.
Last modified date: 09/11/2026