When exact k-nearest-neighbour search is enough, when an approximate DiskANN vector index pays off, and why its metric must match the query.
From Ultra Transcenders DP-800 by Tony Rough (coming December 2026)
Exact nearest neighbour (kNN) search computes the distance to every candidate and is always correct; approximate nearest neighbour (ANN) search uses an index to trade a little recall for a large gain in speed. The engine’s ANN index is a DiskANN graph.
| Aspect | Exact kNN | Approximate ANN |
|---|---|---|
| T-SQL | TOP (n) ... ORDER BY VECTOR_DISTANCE(...) |
SELECT TOP (n) WITH APPROXIMATE ... FROM VECTOR_SEARCH(...) |
| Index | None (full scan of candidates) | CREATE VECTOR INDEX (DiskANN) |
| Accuracy | Exact (recall 1) | Approximate; recall measured against kNN |
| Recommended size | Up to about 50,000 candidate vectors after other predicates | Larger candidate sets |
| Availability | GA on all four platforms | GA in Azure SQL Database, SQL database in Fabric and Managed Instance (Always-up-to-date); preview in SQL Server 2025 and Managed Instance (SQL Server 2025 policy) |
The table may contain far more than 50,000 rows as long as relational filters reduce the candidates to that range before the distance calculation.
CREATE VECTOR INDEX vix_ProductEmbeddings
ON dbo.ProductEmbeddings (embedding)
WITH (METRIC = 'cosine', TYPE = 'DiskANN', MAXDOP = 8);| Option | Values and defaults |
|---|---|
METRIC |
cosine, euclidean or dot (negative dot product) |
TYPE |
Only DiskANN (the default) |
MAXDOP |
0 (default, use configured value), 1 (no parallelism) or a limit |
ON filegroup |
Optional filegroup or "default" |
Requirements and limits:
int column.ALTER on the table. In SQL Server 2025, enable PREVIEW_FEATURES first.sys.vector_indexes and create it in a post-deployment script if needed.VECTOR_SEARCH raises a warning and falls back to kNN.| Behaviour | Earlier version (deprecated) | Latest version |
|---|---|---|
| DML on the table | Read-only unless ALLOW_STALE_VECTOR_INDEX is set |
Full INSERT/UPDATE/DELETE/MERGE, maintained in the background |
| Filters | Post-filtering only; can return fewer rows than requested | Iterative filtering during the search |
| Query syntax | TOP_N parameter in VECTOR_SEARCH |
SELECT TOP (N) WITH APPROXIMATE; TOP_N raises error 42274 |
| Upgrade | Drop and re-create the index | Shows Version 3 in sys.vector_indexes.build_parameters |
The latest version is available in Azure SQL Database, SQL database in Fabric and Managed Instance with the Always-up-to-date policy. Newly created indexes there use it automatically.
Common trap: Expecting
VECTOR_DISTANCEinORDER BYto use a new vector index -VECTOR_DISTANCEis always exact and never uses a vector index; onlyVECTOR_SEARCHperforms index-backed ANN search.
Common trap: Assuming a table becomes read-only and results are post-filtered once a vector index exists - that was the earlier index version; latest-version indexes in Azure SQL Database and Fabric support full DML with real-time maintenance and iterative filtering, while vector indexes remain preview (with
PREVIEW_FEATURES) in SQL Server 2025.
This note is one section of Ultra Transcenders DP-800: Developing AI-Enabled Database Solutions, an independent study guide that explains every topic the exam covers by technology, with comparison tables, diagrams and the common traps, plus a glossary linked to Microsoft Learn.
Due on Amazon in December 2026, in Kindle and paperback editions.
About the book · DP-800 terms in the glossary · All DP-800 study notes
How each isolation level trades consistency for concurrency, when to use RCSI or snapshot isolation, and which anomalies each one prevents.
How Always Encrypted keeps keys away from the database engine, deterministic versus randomised encryption, and secure enclaves.
How to build row-level security with an inline predicate function and a security policy, and how filter and block predicates differ.
How the OVER clause partitions, orders and frames rows, and how ROWS and RANGE frames decide which rows each calculation sees.
How temporal tables keep row history automatically, and how FOR SYSTEM_TIME AS OF, BETWEEN and ALL query it.
How to combine full-text and vector search results with reciprocal rank fusion in T-SQL, and why RRF uses ranks rather than raw scores.
Choosing between change event streaming, change data capture, change tracking, Azure Functions and Logic Apps to react to row changes.