content_image/806465.jpg
It is also possible to partition a table by linear key. Here is a simple example: 

CREATE TABLE tk ( col1 INT NOT NULL, col2 CHAR(5), col3 DATE ) PARTITION BY LINEAR KEY (col1) PARTITIONS 3; 

The LINEAR  keyword has the same effect on KEY  partitioning as it does on HASH  partitioning, with the partition number being derived using a powers-of-two algorithm rather than modulo arithmetic. See Section 24.2.4.1, “LINEAR HASH Partitioning” , for a description of this algorithm and its implications. 

## 24.2.6 Subpartitioning 

Subpartitioning—also known as composite partitioning —is the further division of each partition in a partitioned table. Consider the following CREATE TABLE  statement: 

CREATE TABLE ts (id INT, purchased DATE) PARTITION BY RANGE( YEAR(purchased) ) SUBPARTITION BY HASH( TO_DAYS(purchased) ) SUBPARTITIONS 2 ( PARTITION p0 VALUES LESS THAN (1990), PARTITION p1 VALUES LESS THAN (2000), PARTITION p2 VALUES LESS THAN MAXVALUE ); 

Table ts  has 3 RANGE  partitions. Each of these partitions— p0 , p1 , and p2 —is further divided into 2 subpartitions. In effect, the entire table is divided into 3 * 2 = 6  partitions. However, due to the action of the PARTITION BY RANGE  clause, the first 2 of these store only those records with a value less than 1990 in the purchased  column. 

It is possible to subpartition tables that are partitioned by RANGE  or LIST . Subpartitions may use either HASH  or KEY  partitioning. This is also known as composite partitioning . 

<img src='content_image/806465.jpg'>

## Note 

SUBPARTITION BY HASH  and SUBPARTITION BY KEY  generally follow the same syntax rules as PARTITION BY HASH  and PARTITION BY KEY , respectively. An exception to this is that SUBPARTITION BY KEY  (unlike PARTITION BY KEY ) does not currently support a default column, so the column used for this purpose must be specified, even if the table has an explicit primary key. This is a known issue which we are working to address; see Issues with subpartitions, for more information and an example. 

It is also possible to define subpartitions explicitly using SUBPARTITION  clauses to specify options for individual subpartitions. For example, a more verbose fashion of creating the same table ts  as shown in the previous example would be: 

CREATE TABLE ts (id INT, purchased DATE) PARTITION BY RANGE( YEAR(purchased) ) SUBPARTITION BY HASH( TO_DAYS(purchased) ) ( PARTITION p0 VALUES LESS THAN (1990) ( SUBPARTITION s0, SUBPARTITION s1 ), 

