microsoft / microsoft/vscode-mssql

Execution plan using a vector index seek does not render with Actual Execution Plan

Open
#22,146 1 comment 0 reactions 1 assignee Claimed by @laurenastrid1 View on GitHub
Area - Query Plan Bug User-filed
Dominant language
TypeScript
Stars
1.9k
Forks
610
Avg merge
2d 3h
Merged PRs (30d)
97

Description

### Description

A visual query plan cannot be displayed for a query that contains a vector index seek. The visual plan does not appear. A resulting showplan XML is returned and if select it the following error is returned "There is an error in XML document (1, 6200). ---> Instance validation error: 'Vector Index Seek' is not a valid value for PhysicalOpType."

### Steps to Reproduce

1. Deploy an Azure SQL Database
2. Run the following commands to create a table, fill in embeddings, and create a vector index
-- Latest-version vector indexes require >= 100 rows before index creation.
-- Use a uniquely-named table so we don't collide with demo objects.
IF OBJECT_ID(N'dbo.repro_vec_showplan', N'U') IS NOT NULL
DROP TABLE dbo.repro_vec_showplan;
GO

CREATE TABLE dbo.repro_vec_showplan
(
Id int NOT NULL PRIMARY KEY,
Label nvarchar(50) NOT NULL,
Embedding vector(4) NOT NULL -- tiny dimension for clarity
);
GO

-- 100 rows of mock embeddings (required minimum for latest vector index).
INSERT dbo.repro_vec_showplan (Id, Label, Embedding)
SELECT value,
CONCAT(N'row_', value),
CAST(CONCAT(
N'[',
CAST(value * 0.01 AS nvarchar(20)), N',',
CAST(value * 0.02 AS nvarchar(20)), N',',
CAST(value * 0.03 AS nvarchar(20)), N',',
CAST(value * 0.04 AS nvarchar(20)),
N']') AS vector(4))
FROM GENERATE_SERIES(1, 100);
GO

-- Build the vector index. The showplan has to describe this in XML
-- using its IndexKind enum value.
CREATE VECTOR INDEX ix_repro_vec_showplan_emb
ON dbo.repro_vec_showplan (Embedding)
WITH (METRIC = 'cosine', TYPE = 'diskann');
GO

3. Select Actual Execution Plan from the query editor and run this query

DECLARE @q vector(4) = CAST('[0.95, 0.05, 0.0, 0.0]' AS vector(4));

SELECT TOP 3 WITH APPROXIMATE
v.Id, v.Label, r.distance
FROM VECTOR_SEARCH(
TABLE = dbo.repro_vec_showplan AS v,
COLUMN = Embedding,
SIMILAR_TO = @q,
METRIC = 'cosine') AS r
ORDER BY r.distance;
GO

### Affected Area

- [ ] Connection dialog (SQL Server | Azure browse/Fabric browse)
- [ ] Query editor
- [ ] Query results panel
- [ ] Object Explorer
- [ ] GitHub Copilot integration
- [ ] Preview/Edit data
- [ ] Table Designer
- [ ] Schema Designer
- [ ] Schema Compare
- [ ] Local SQL Server Container provisioning
- [ ] SQL database in Fabric provisioning
- [ ] DACPAC/BACPAC export/import
- [ ] SQL Database projects
- [x] Query Plan Visualizer
- [ ] Other (please describe below)

### If you selected "Other", please describe the affected area

_No response_

### Environment Information

VS Code: 1.121.0
MSSQL extension (ms-mssql.mssql): 1.42.2
Windows 11

### Confirmation

- [x] I have searched existing issues and couldn't find a match
- [ ] I want to work on this issue

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.