Capturing and importing plans

実装済み

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 比較します them later.

Capturing from a connection

キャプチャ場所何ができるかクエリを実行しますか?
実際⌘L, the plan button in the query bar, or クエリの説明 (Actual、クエリを実行) in the command paletteRuns the statement and records the plan with real row counts and timings.はい
推定Query menu or command palette: クエリの説明 (Estimated プラン、実行なし)Asks the optimizer for its plan. Row counts and costs are its guesses.いいえ
プロファイルCommand palette: プロファイリング付きで説明 (SELECT のみ)An actual capture with the extra detail switched on (buffers, verbose output). Refused for anything that is not a SELECT.Yes, SELECT only
再キャプチャButton 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 クエリインサイト for the rows, bytes and memory a run used.

How each engine is captured

エンジン実際推定
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、各インデックスで除外されたパートとグラニュールの数付き
OracleSTATISTICS_LEVEL = ALL、次から読み戻す V$SQL_PLAN_STATISTICS_ALLEXPLAIN PLAN FOR、次から読み戻す 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).
  • デフォルトに戻す puts the connection back to SQLly's default options.

Importing a plan from another tool

クリップボードからプランを貼り付け そして プランを開く… (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.

エンジンFormats that open
SQL ServerShowPlan XML (.sqlplan files, XML copied out of a results grid or Query Store), SHOWPLAN_TEXT, SHOWPLAN_ALL そして STATISTICS PROFILE text, with STATISTICS IO そして 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、そして EXPLAIN json = 1
CockroachDBEXPLAIN そして 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 なし 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.