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
| Parameter | Description | Supported input types |
|---|---|---|
<index_name> | The vector search index to use. The index must exist on the target table. | Index name (identifier) |
target_vector | The target vector to search for. Must be provided as a scalar (literal array or scalar subquery). Must not be NULL and must not contain NULL elements. | ARRAY(DOUBLE) |
top_k | The maximum number of nearest rows to return. | INTEGER |
ef_search | Optional. Search‑time candidate list size. Higher values improve recall with higher latency. Default 64. Set ef_search >= top_k. | INTEGER |
load_strategy | Optional. Index serving mode: 'in_memory' (default) loads and caches the index in RAM; 'disk' uses memory‑mapped, on‑demand loading which may increase latency under memory pressure. | TEXT ('in_memory' or 'disk') |
EF_SEARCH
Theef_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:
50–200; recommended starting range:64–100. - 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 totop_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 usingVECTOR_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_SEARCHuses 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 runVECTOR_SEARCH() .
| id | title |
|---|---|
| 42 | Firebolt flames through sub‑second analytics |
| 73 | Firebolt sparks low‑latency BI dashboards |
| 105 | Firebolt ignites real‑time recommendations |