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 palette | Runs 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 pane | Captures 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 SQL | SET STATISTICS XML ON | SET SHOWPLAN_XML ON |
| PostgreSQL | EXPLAIN (ANALYZE, FORMAT JSON) plus the options you choose | EXPLAIN (FORMAT JSON) |
| MySQL 8 | EXPLAIN ANALYZE | EXPLAIN FORMAT=JSON |
| MariaDB | ANALYZE FORMAT=JSON | EXPLAIN FORMAT=JSON |
| SQLite | EXPLAIN QUERY PLAN, estimated only, never executes | |
| libSQL / Turso | EXPLAIN QUERY PLAN, estimated only (SQLite's plan over the network) | |
| DuckDB | EXPLAIN ANALYZE | EXPLAIN |
| ClickHouse | None (no EXPLAIN ANALYZE) | EXPLAIN json = 1、各インデックスで除外されたパートとグラニュールの数付き |
| Oracle | STATISTICS_LEVEL = ALL、次から読み戻す V$SQL_PLAN_STATISTICS_ALL | EXPLAIN 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 Server | ShowPlan 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 |
| PostgreSQL | EXPLAIN as text (including psql and pgAdmin borders, BUFFERS, WAL, Settings and JIT sections), JSON, YAML or XML |
| MySQL | The classic table, \G output, tab-separated rows, FORMAT=TREE, EXPLAIN ANALYZE, and both JSON versions |
| MariaDB | The classic table and ANALYZE FORMAT=JSON |
| Oracle | DBMS_XPLAN output (including ALLSTATS LAST), AUTOTRACE, and rows read from PLAN_TABLE |
| SQLite | EXPLAIN QUERY PLAN |
| DuckDB | EXPLAIN ANALYZE as box-drawing text or JSON |
| ClickHouse | EXPLAIN indexes = 1, actions = 1 text, EXPLAIN PIPELINE、そして EXPLAIN json = 1 |
| CockroachDB | EXPLAIN そして EXPLAIN ANALYZE |
| Trino | EXPLAIN ANALYZE |
| Spark SQL | EXPLAIN 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.