Capturing and importing plans

funktional

Actual, estimated and profile captures on each engine, EXPLAIN options per connection, and the 23 plan formats that open from a file or the clipboard.

There are two ways to get a plan into SQLly: capture one from a live connection, or bring one in from somewhere else. Either way it lands in the plan pane under the query tab, and every capture in the tab is kept so you can vergleichen them later.

Capturing from a connection

ErfassenWoWas es bewirktFührt die Abfrage aus?
Tatsächlich⌘L, the plan button in the query bar, or Abfrage erklären (Tatsächlich, führt Abfrage aus) in the command paletteRuns the statement and records the plan with real row counts and timings.Ja
GeschätztQuery menu or command palette: Abfrage erklären (Geschätzter Plan, keine Ausführung)Asks the optimizer for its plan. Row counts and costs are its guesses.Nein
ProfilCommand palette: Mit Profil erklären (nur SELECT)An actual capture with the extra detail switched on (buffers, verbose output). Refused for anything that is not a SELECT.Yes, SELECT only
Erneut erfassenButton on the plan paneCaptures the same kind of plan again, for example after adding an index.Same as the original

When a connection cannot produce the kind of plan you asked for, the plan button stays visible but disabled and its tooltip says why. On SQLite, libSQL and ClickHouse, which have no executed-plan form here, the Actual command points you at Estimated; on ClickHouse it also points at Abfrageanalysen for the rows, bytes and memory a run used.

How each engine is captured

EngineTatsächlichGeschätzt
SQL Server, Azure SQLSET STATISTICS XML ONSET SHOWPLAN_XML ON
PostgreSQLEXPLAIN (ANALYZE, FORMAT JSON) plus the options you chooseEXPLAIN (FORMAT JSON)
MySQL 8EXPLAIN ANALYZEEXPLAIN FORMAT=JSON
MariaDBANALYZE FORMAT=JSONEXPLAIN FORMAT=JSON
SQLiteEXPLAIN QUERY PLAN, estimated only, never executes
libSQL / TursoEXPLAIN QUERY PLAN, estimated only (SQLite's plan over the network)
DuckDBEXPLAIN ANALYZEEXPLAIN
ClickHouseNone (no EXPLAIN ANALYZE)EXPLAIN json = 1, mit den Teilen und Granulen, bei denen jeder Index beschnitten wird
OracleSTATISTICS_LEVEL = ALL, zurückgelesen von V$SQL_PLAN_STATISTICS_ALLEXPLAIN PLAN FOR, zurückgelesen von PLAN_TABLE

EXPLAIN options

The small chevron beside the plan button opens Explain options for the current connection. Choices are saved per connection, so a production server can keep a lighter capture than your laptop's database. The plan button's tooltip lists what is on.

  • PostgreSQL: Analyze, Verbose, Costs, Buffers, Timing, Summary, Settings, WAL, Generic plan and Memory. Options the connected server's version does not support are greyed out with the version they need (Settings 12, WAL 13, Generic plan 16, Memory 17), and the panel shows the version it detected.
  • MySQL and MariaDB: Analyze (runs the statement).
  • Auf Standard zurücksetzen puts the connection back to SQLly's default options.

Importing a plan from another tool

Plan aus Zwischenablage einfügen und Plan öffnen… (command palette, or the Paste and Open buttons on the pane) read the output each engine actually prints, not only the formats SQLly captures. You do not need a connection, and the plan does not have to come from the same machine.

EngineFormats that open
SQL ServerShowPlan XML (.sqlplan files, XML copied out of a results grid or Query Store), SHOWPLAN_TEXT, SHOWPLAN_ALL und STATISTICS PROFILE text, with STATISTICS IO und TIME messages attached to their statement
PostgreSQLEXPLAIN as text (including psql and pgAdmin borders, BUFFERS, WAL, Settings and JIT sections), JSON, YAML or XML
MySQLThe classic table, \G output, tab-separated rows, FORMAT=TREE, EXPLAIN ANALYZE, and both JSON versions
MariaDBThe classic table and ANALYZE FORMAT=JSON
OracleDBMS_XPLAN output (including ALLSTATS LAST), AUTOTRACE, and rows read from PLAN_TABLE
SQLiteEXPLAIN QUERY PLAN
DuckDBEXPLAIN ANALYZE as box-drawing text or JSON
ClickHouseEXPLAIN indexes = 1, actions = 1 text, EXPLAIN PIPELINE, und EXPLAIN json = 1
CockroachDBEXPLAIN und EXPLAIN ANALYZE
TrinoEXPLAIN ANALYZE
Spark SQLEXPLAIN FORMATTED

Format detection

The engine and format are recognised from the text itself, not the file extension. Shell prompts, Markdown code fences, line numbers, log prefixes and a plan pasted as a quoted JSON string are stripped first, so a plan copied out of a terminal, a chat or a ticket usually opens as it is. A file with several statements opens all of them, with a tab per statement.

When something cannot be read, the pane says what it looks like (“This looks like SQLite bytecode”, a truncated XML file) with the line and column where reading stopped, and shows How to get a plan that can be read for that engine. SQLite's EXPLAIN ohne QUERY PLAN, for example, is bytecode rather than a plan.

Large plans

Plans with more than 500 operators are analysed in the background so the app stays responsive. The pane says it is analysing, and the status bar and the finding count are filled in when it finishes. If the analysis fails, the pane says so plainly and the raw operators are still there.