CoolCode.caReading a plan

QUERY PLAN LAB · LOCAL BROWSER TOOL

MySQL EXPLAIN JSON example: table scan and index lookup

Follow the tables, indexes and estimates behind your query. Compare two plans to see what the optimizer changed.

MySQL & MariaDB JSONNo database connectionYour plans stay in this browser

Worked example · Query Plan Lab

What this example shows

The example joins customers and orders. It illustrates how an execution plan records chosen indexes and estimated rows examined per scan.

2 table accesses are compared. The customers illustration changes from 50,000 to 1,000 estimated rows per scan.

Hand-written illustrative plans bundled with Query Plan Lab. No query was executed and these figures are not benchmark measurements.

TableAccess before → afterIndex before → afterEstimated rows per scan
customers #1ALL → refNone chosen → region50,000 → 1,000
orders #1ref → refcustomer_id → customer_status12 → 3

The customers access changes from ALL to ref in this illustration. Estimated rows are optimizer estimates, not elapsed time or proof of a speedup.

Filesort remains present in both plans. Its name alone does not establish disk activity. Query Plan Lab does not connect to a database or execute SQL.

Try it with your own input

  1. Inspect the customers and orders nodes in the prefilled comparison.
  2. Paste your own EXPLAIN FORMAT=JSON output into Before, and optionally After.
  3. Choose Visualize plan, then inspect the chosen index and estimated rows for each table.

Edit the prefilled example · Open the main tool

Sources and related tools

01 / INPUT

Bring your execution plan

Run EXPLAIN FORMAT=JSON SELECT … in your database and paste its JSON output. Add a second plan to compare. The example is hand-written to demonstrate the interface.

Maximum 2 MB per plan

Paste a plan or explore the illustrative comparison.

METHOD & LIMITS

A plan is a hypothesis. Measure it.

Read access paths

ALL means a full table scan; index means a full index scan. Compare the chosen key with possible keys, filter estimates and table size before deciding whether an index is missing.

Keep costs comparable

Optimizer cost is not milliseconds. Root cost is shown separately and never summed with child costs. Compare the same query, engine version, data and settings. MySQL and MariaDB costs are not interchangeable.

Separate actual measurements

MariaDB ANALYZE FORMAT=JSON may include r_rows and r_loops; these are displayed separately. ANALYZE executes the query. MySQL TREE output and JSON format version 2 are not supported here.

Inputs are held only in memory. No plan, SQL or file is uploaded or saved automatically. CoolCode's aggregate visit counter runs independently and does not receive your plan. Downloaded reports contain your plan details.

References: MySQL EXPLAIN · MariaDB JSON plans

Related tools: Rack Recipes · Rack Expiry