Filter operator: WHERE predicate row-by-rowMySQL 8.4 • MariaDB 11.4

Understand the internal execution loop of a Filter stage: evaluate every input row, then keep or discard.

Lesson familyFilter operator

Parameters (filter stage)

About this example
Ready: press Next step, or Play to run it all
0.0s 0.0s

About this example

Example query this animation executes

SELECT order_id, total FROM orders WHERE total > 500;

No index on orders(total), so the child is a table scan that returns every row. The Filter node above it evaluates WHERE total > 500 on each row before passing the row upward.

What you'll see in the animation

  • Left: the rows the child operator (a table scan of orders) returns, one at a time.
  • Each row travels as a pill labelled with its order_id and total into the Filter box (middle), which tests total > 500 on every incoming row and shows the answer.
  • Green rows satisfy the predicate and continue to the parent operator (right).
  • Red rows drop out below the Filter: they were read and tested, then thrown away.
  • Next step tests one row at a time; the simplified code beside the drawing highlights the lines each step runs.

Cost readout (filter operator)

Input rows ?Rows entering the filter stage from its child operator.

—

Output rows ?Rows that satisfy the WHERE predicate and continue upward in the plan.

—

Dropped rows ?Rows evaluated but rejected by the predicate.

—

Selectivity ?Percentage of input rows that survive the predicate.

—

Rows evaluated vs rows returned (log–log)

Learn more — why filter nodes still matter

A Filter node is not always bad — it is normal in many plans. The key question is how many rows arrive at this stage.

If a selective predicate is pushed down into an index access path, far fewer rows reach this filter stage.

When you see large input rows and tiny output rows, consider adding/adjusting indexes so filtering happens earlier.