Partition selection

Partition pruning is automatic selection based on the WHERE clause. You can explicitly specify the partitions to scan in the query. The queries can be SELECT, DELETE, INSERT, REPLACE, UPDATE, LOAD DATA, and LOAD XML. The PARTITION option is used to select partitions from a given table, you should specify the keyword PARTITION <partition name> immediately following the name of the table, before all other options, including any table alias, for example:

mysql> SELECT emp_no,hire_date FROM employees PARTITION (p1990) LIMIT 10;+--------+------------+| emp_no | hire_date  |+--------+------------+| 413688 | 1989-12-10 || 242368 | 1989-08-06 || 283280 | 1985-11-22 || 405098 | 1985-11-16 ||  30404 | 1985-07-17 || 419259 | 1988-03-21 ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.