Skip to main content
Performs an approximate nearest neighbor (ANN) search using a vector search index created with CREATE INDEX ... USING HNSW. VECTOR_SEARCH is a table‑valued function that returns up to top_k rows from the indexed table that are closest to a target vector according to the distance metric configured on the index. Read more about Vector Search Indexes in general and how to create vector indexes.

Syntax

Parameters

The ef_search parameter defines the breadth of exploration during query‑time search.
  • Higher values improve recall; latency increases approximately with ef_search.
  • Set ef_search >= top_k. While this is not strictly required, it is generally recommended to achieve good recall.
  • Typical range: 50200; recommended starting range: 64100.
  • Tune per workload; you can override per query without rebuilding the index.

Return type

A rowset with the same columns as the indexed base table. Returns up to top_k rows.

Notes

  • When using load_strategy => 'in_memory' (the default), you might want to adjust your engine configuraton to allow the in-memory vector index cache to use more memory using VECTOR_INDEX_CACHE_MEMORY_FRACTION. Otherwise, vector indexes need to be loaded into memory in every query leading to slow perfomance. See Performance & observability for more information.
  • You must create and populate a vector search index before using VECTOR_SEARCH.
  • VECTOR_SEARCH uses the distance metric defined on the index (for example, vector_cosine_ops).
  • If the index was created on a populated table without reindexing, Firebolt combines results from indexed tablets with full scans of unindexed tablets. For best performance, run VACUUM ( REINDEX = TRUE ) on the table after creating the index.
  • To tune recall at query time, increase ef_search.

Examples

Create a table with embeddings, create a vector search index, then run VECTOR_SEARCH() .
Returns: