Repository navigation
Description
Problem
Query > Explain Query is dimmed on Oracle. The plan viewer draws diagrams and trees for PostgreSQL, MySQL, SQLite, ClickHouse, DuckDB, Spanner, SAP HANA and others, and Oracle is not in its support table (features/explain-visualization.mdx:134-155). The Oracle plugin declares no plan variants, so it gets the empty default at apple/Plugins/TableProPluginKit/DriverPlugin.swift:179.
Reading an Oracle plan today means running EXPLAIN PLAN FOR ... and then SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY) by hand, and reading the indented text in a grid.
A variant today is a SQL prefix run with the statement (apple/Plugins/TableProPluginKit/ExplainVariant.swift). Oracle writes the plan to PLAN_TABLE and needs a second query to read it back, so the driver needs its own step.
Proposed solution
- Estimated Plan:
EXPLAIN PLAN SET STATEMENT_ID = ... FOR <query>, then read that statement's rows fromPLAN_TABLE(id, parent id, operation, options, object, cost, cardinality, bytes, access and filter predicates) and build the tree fromIDandPARENT_ID. Delete the rows afterwards. - Actual Plan: run the query with the
GATHER_PLAN_STATISTICShint, then readV$SQL_PLAN_STATISTICS_ALLfor that cursor, giving actual rows, starts and elapsed time per step. Safe Mode prompts for it the same way it does for EXPLAIN ANALYZE. - Access and filter predicates shown in the detail pane, since they say why an index was or was not used.
- When the account cannot read
V$SQL_PLAN_STATISTICS_ALL, the actual variant says which grant is missing, and the estimated variant still works.
Done when: both variants draw the diagram and tree for a join over three tables on Oracle 19c and 23ai, and the estimated plan works for an account with no extra grants.
Alternatives considered
Run EXPLAIN PLAN FOR and DBMS_XPLAN.DISPLAY in a query tab and read the text output.
Platform
macOS
Related database type
Oracle
Activity