Repository navigation
Description
Problem
Query > Explain Query is dimmed on SQL Server. The plan viewer draws diagrams and trees for PostgreSQL, MySQL, MariaDB, SQLite, ClickHouse, DuckDB, Spanner, SAP HANA and others, and SQL Server is not in its support table (features/explain-visualization.mdx:134-155). The plugin declares no plan variants (the SQL Server plugin sets no explainVariants, so it gets the empty default at apple/Plugins/TableProPluginKit/DriverPlugin.swift:179).
Reading a SQL Server plan today means running SET SHOWPLAN_XML ON by hand and reading the XML in a cell. The missing index hints and warnings the server puts in that XML go unseen.
A variant today is a SQL prefix run with the statement (apple/Plugins/TableProPluginKit/ExplainVariant.swift). SQL Server takes SET SHOWPLAN_XML ON in a batch of its own, so the driver needs its own step to collect the plan.
Proposed solution
- Two variants under Explain: Estimated Plan (
SET SHOWPLAN_XML ON, the query does not run) and Actual Plan (SET STATISTICS XML ON, the query runs, with the same Safe Mode prompt as EXPLAIN ANALYZE). The setting is turned off again on the same session afterwards, also when the plan fails. - A parser for the showplan XML that maps each
RelOpto a plan node: physical and logical operator, object and index, estimated rows, estimated subtree cost, and, on an actual plan, actual rows, executions and elapsed time. MissingIndexesfrom the XML shown in the detail pane, with aCREATE INDEXstatement to copy.- Plan warnings (implicit conversion, spill to tempdb, no join predicate) shown as a badge on the node.
- A login without the
SHOWPLANpermission gets that reason in the error, not an empty plan.
Done when: both variants draw the diagram and tree for a join over three tables on SQL Server 2019 and 2022 and on Azure SQL Database, and a query on an unindexed filter column shows its missing index hint.
Alternatives considered
Run SET SHOWPLAN_XML ON in a query tab, copy the XML out of the result cell and open it in another tool.
Platform
macOS
Related database type
SQL Server
Activity