2 rows in set (0.00 sec) 

This includes cases in which the columns used in the partitioning function are defined implicitly as those in the table’s primary key by employing an empty PARTITION BY KEY()  clause. 

In MySQL 8.0.21 and later, if all columns specified for the partitioning key employ prefixes, the CREATE TABLE  statement used fails with an error message that identifies the issue correctly: 

mysql> CREATE TABLE t1 ( -> a VARCHAR(10000), -> b VARCHAR(25), -> c VARCHAR(10), -> PRIMARY KEY (a(10), b(5), c(2)) -> ) PARTITION BY KEY() PARTITIONS 2; ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table’s partitioning function (prefixed columns are not considered). 

For general information about partitioning tables by key, see Section 24.2.5, “KEY Partitioning” . 

## Issues with subpartitions. 

Subpartitions must use HASH  or KEY  partitioning. Only RANGE  and LIST  partitions may be subpartitioned; HASH  and KEY  partitions cannot be subpartitioned. 

SUBPARTITION BY KEY  requires that the subpartitioning column or columns be specified explicitly, unlike the case with PARTITION BY KEY , where it can be omitted (in which case the table’s primary key column is used by default). Consider the table created by this statement: 

CREATE TABLE ts ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) ); 

You can create a table having the same columns, partitioned by KEY , using a statement such as this one: 

CREATE TABLE ts ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) ) PARTITION BY KEY() PARTITIONS 4; 

The previous statement is treated as though it had been written like this, with the table’s primary key column used as the partitioning column: 

CREATE TABLE ts ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) ) PARTITION BY KEY(id) PARTITIONS 4; 

However, the following statement that attempts to create a subpartitioned table using the default column as the subpartitioning column fails, and the column must be specified for the statement to succeed, as shown here: 

mysql> CREATE TABLE ts ( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> name VARCHAR(30) -> ) -> PARTITION BY RANGE(id) -> SUBPARTITION BY KEY() 

