If you insert a record into t1  whose col3  value is ’2005-09-15’ , then the partition in which it is stored is determined as follows: 

MOD(YEAR(’2005-09-01’),4) = MOD(2005,4) = 1 

MySQL 8.0 also supports a variant of HASH  partitioning known as linear hashing  which employs a more complex algorithm for determining the placement of new rows inserted into the partitioned table. See Section 24.2.4.1, “LINEAR HASH Partitioning” , for a description of this algorithm. 

The user-supplied expression is evaluated each time a record is inserted or updated. It may also— depending on the circumstances—be evaluated when records are deleted. 

## 24.2.4.1 LINEAR HASH Partitioning 

MySQL also supports linear hashing, which differs from regular hashing in that linear hashing utilizes a linear powers-of-two algorithm whereas regular hashing employs the modulus of the hashing function’s value. 

Syntactically, the only difference between linear-hash partitioning and regular hashing is the addition of the LINEAR  keyword in the PARTITION BY  clause, as shown here: 

CREATE TABLE employees ( id INT NOT NULL, fname VARCHAR(30), lname VARCHAR(30), hired DATE NOT NULL DEFAULT ’1970-01-01’, separated DATE NOT NULL DEFAULT ’9999-12-31’, job_code INT, store_id INT ) PARTITION BY LINEAR HASH( YEAR(hired) ) PARTITIONS 4; 

Given an expression expr , the partition in which the record is stored when linear hashing is used is partition number N  from among num  partitions, where N  is derived according to the following algorithm: 

1. Find the next power of 2 greater than num . We call this value V ; it can be calculated as: 

V  = POWER(2, CEILING(LOG(2, num ))) 

(Suppose that num  is 13. Then LOG(2,13)  is 3.7004397181411. CEILING(3.7004397181411)  is 4, and V  = POWER(2,4) , which is 16.) 

2. Set N  = F ( column_list ) & ( V  - 1). 

3. While N  >= num : 

•Set V  = V  / 2 

•Set N  = N  & ( V  - 1) 

Suppose that the table t1 , using linear hash partitioning and having 6 partitions, is created using this statement: 

CREATE TABLE t1 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY LINEAR HASH( YEAR(col3) ) PARTITIONS 6; 

Now assume that you want to insert two records into t1  having the col3  column values ’2003-04-14’ and ’1998-10-19’ . The partition number for the first of these is determined as follows: 

