This is called Partition pruning:
The optimizer can perform pruning whenever a
WHERE
condition can be reduced to either one of the following two cases:
partition_column = constant
partition_column IN (constant1, constant2, ..., constantN)
In the first case, the optimizer simply evaluates the partitioning expression for the value given, determines which partition contains that value, and scans only this partition. (...)
In the second case, the optimizer evaluates the partitioning expression for each value in the list, creates a list of matching partitions, and then scans only the partitions in this partition list. (...)
MySQL can apply partition pruning to
SELECT
,DELETE
, andUPDATE
statements.INSERT
statements currently cannot be pruned.Pruning can also be applied to short ranges, which the optimizer can convert into equivalent lists of values. (...)