Engine Atlas

Composite Index Anatomy

Read column order, range boundaries, ICP, and covering from real plans and rows
MySQL 8.4.102026-07-12
한국어
Learning guide

Question for this Lab

With the same composite-index columns, how does order change the equality prefix, first range, ICP, and row materialization?

Execution engine: MySQL 8.4.10
Who runs it?

One session executes the same SELECT with three index-order variants.

What stays controlled?

The same orders fixture with customer_id, status, ordered_at, and total_cents plus the same result checksum is fixed across all variants.

Executed SQL
SELECT id, customer_id, status, ordered_at, total_cents
FROM orders
WHERE customer_id = 412
  AND status = 'PAID'
  AND ordered_at >= '2025-01-01 00:00:00'
ORDER BY ordered_at DESC, id DESC
LIMIT 20;
What changes?

B-tree bounds, range candidates, ICP rejections, and whether base-row lookups are needed change with index order.

What stays fixed?

WHERE, ORDER BY, LIMIT 20, returned rows, and checksum remain identical across all three variants.

Predict before tracing

What happens when customer_id and status precede the ordered_at range?

What happens when customer_id and status precede the ordered_at range?

Evidence mission

Open the range-candidate step of the misordered variant and check how many fixture-derived candidates enter M_RANGE and how the predicate classifies them.

Where do you look?
Compare the range evidence in the composite-index lens with its candidate, pass, and reject classification.
Screen to open
Misordered · range candidates
What should you see?
Expected observation

M_RANGE is the exact set of 31,348 fixture-derived candidates satisfying status='PAID' and the ordered_at lower bound; 31 candidates with customer_id=412 pass and 31,317 are rejected. These counts are not physical pages or entries visited by the engine.

Evidence boundary
Derived · fixture
M_RANGE candidate 31,348 with pass 31 and reject 31,317 classification
Checkpoint · explain from evidenceWhat do 31,348 candidates, 31 pass, and 31,317 reject mean for the misordered fixture?Reveal answer and basis

They classify candidate entries formed by the misordered range in the fixed fixture. They are not a claim about physical pages or entries visited by the captured engine.

Evidence boundary
Derived · fixture
candidate, pass, and reject entry classification
Core takeaway

For a composite index, equality-prefix and first-range order plus entry coverage matter more than merely including every column.

Next connection

The next Lab compares how accurately statistics estimate the actual row distribution behind an access path.

Review terms
B-treeIntroduced in Lab 02
An index structure that stores ordered keys hierarchically to support equality and range lookups.
equality prefixIntroduced in Lab 02
The consecutive key parts fixed by equality predicates from the left edge of a composite index.
first rangeIntroduced in Lab 02
The first range key part that forms composite-index bounds; later parts may still contribute through filtering or ICP.
Index Condition Pushdown (ICP)Introduced in Lab 02
An optimization that evaluates eligible predicates from index-entry columns before fetching the base row.
covering indexIntroduced in Lab 02
An index that contains the columns needed by a query so a base-row lookup can be avoided.

01 · SOURCE

SQL

1 active fragmentMySQLLIMIT 20
SELECT id, customer_id, status, ordered_at, total_cents
FROM orders
WHERE customer_id = 412
  AND status = 'PAID'
  AND ordered_at >= '2025-01-01 00:00:00'
ORDER BY ordered_at DESC, id DESC
LIMIT 20;
02 · FLOW

Native Plan

01 / 12
01/ 12