FREE STUDY NOTES · DP-800

Exact (KNN) vs approximate (ANN) vector search and vector indexes in Azure SQL

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.

When to use each

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

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:

Earlier versus latest index versions

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_DISTANCE in ORDER BY to use a new vector index - VECTOR_DISTANCE is always exact and never uses a vector index; only VECTOR_SEARCH performs 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.

Get the whole book

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.

Amazon.co.ukKindle: coming soonPaperback: coming soon
Amazon.comKindle: coming soonPaperback: coming soon

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

More DP-800 study notes