Bug #72428 | Partition by KEY() results in uneven data distribution | ||
---|---|---|---|
Submitted: | 23 Apr 2014 0:12 | Modified: | 9 Jun 2014 15:17 |
Reporter: | Justin Swanhart | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S2 (Serious) |
Version: | 5.6.16,5.5.37 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | partitioning |
[23 Apr 2014 0:12]
Justin Swanhart
[23 Apr 2014 2:26]
Justin Swanhart
There are 2406 LO_OrderDateKey values (and it is an integer) so that should have definitely resulted in more than one partition being utilized.
[24 Apr 2014 20:40]
Justin Swanhart
Here is an easy to reproduce simple test case from 5.5.37: mysql> create table t1(c1 int, c2 date) partition by key(c2) partitions 8; Query OK, 0 rows affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-22'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-23'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-24'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-25'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-26'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-27'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-28'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-29'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-30'); Query OK, 1 row affected (0.00 sec) mysql> select partition_name, table_rows from information_schema.partitions where table_name='t1'\G *************************** 1. row *************************** partition_name: p0 table_rows: 3 *************************** 2. row *************************** partition_name: p1 table_rows: 0 *************************** 3. row *************************** partition_name: p2 table_rows: 0 *************************** 4. row *************************** partition_name: p3 table_rows: 0 *************************** 5. row *************************** partition_name: p4 table_rows: 2 *************************** 6. row *************************** partition_name: p5 table_rows: 0 *************************** 7. row *************************** partition_name: p6 table_rows: 4 *************************** 8. row *************************** partition_name: p7 table_rows: 0 8 rows in set (0.00 sec)
[28 Apr 2014 13:02]
MySQL Verification Team
Hello Justin, Thank you for the bug report and simplified test case. Verified as described. Thanks, Umesh
[28 Apr 2014 13:04]
MySQL Verification Team
/// Latest builds of 5.5/5.6 mysql> use test Database changed mysql> create table t1(c1 int, c2 date) partition by key(c2) partitions 8; Query OK, 0 rows affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-22'); Query OK, 1 row affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-23'); Query OK, 1 row affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-24'); Query OK, 1 row affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-25'); Query OK, 1 row affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-27'); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 values (1, '2014-04-28'); Query OK, 1 row affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-29'); Query OK, 1 row affected (0.01 sec) mysql> insert into t1 values (1, '2014-04-30'); Query OK, 1 row affected (0.00 sec) mysql> select partition_name, table_rows from information_schema.partitions where table_name='t1'\G *************************** 1. row *************************** partition_name: p0 table_rows: 2 *************************** 2. row *************************** partition_name: p1 table_rows: 0 *************************** 3. row *************************** partition_name: p2 table_rows: 0 *************************** 4. row *************************** partition_name: p3 table_rows: 0 *************************** 5. row *************************** partition_name: p4 table_rows: 2 *************************** 6. row *************************** partition_name: p5 table_rows: 0 *************************** 7. row *************************** partition_name: p6 table_rows: 4 *************************** 8. row *************************** partition_name: p7 table_rows: 0 8 rows in set (0.00 sec) mysql> select version(); +------------------+ | version() | +------------------+ | 5.5.38-debug-log | +------------------+ 1 row in set (0.00 sec) // 5.6.18 mysql> select version(); +---------------------------------------+ | version() | +---------------------------------------+ | 5.6.18-enterprise-commercial-advanced | +---------------------------------------+ 1 row in set (0.00 sec) mysql> create table t1(c1 int, c2 date) partition by key(c2) partitions 8; Query OK, 0 rows affected (2.31 sec) mysql> insert into t1 values (1, '2014-04-22'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values (1, '2014-04-23'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values (1, '2014-04-24'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values (1, '2014-04-25'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values (1, '2014-04-26'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values (1, '2014-04-27'); Query OK, 1 row affected (0.04 sec) mysql> insert into t1 values (1, '2014-04-28'); Query OK, 1 row affected (0.03 sec) mysql> insert into t1 values (1, '2014-04-29'); Query OK, 1 row affected (0.04 sec) mysql> insert into t1 values (1, '2014-04-30'); Query OK, 1 row affected (0.02 sec) mysql> select partition_name, table_rows from information_schema.partitions where table_name='t1'\G *************************** 1. row *************************** partition_name: p0 table_rows: 3 *************************** 2. row *************************** partition_name: p1 table_rows: 0 *************************** 3. row *************************** partition_name: p2 table_rows: 0 *************************** 4. row *************************** partition_name: p3 table_rows: 0 *************************** 5. row *************************** partition_name: p4 table_rows: 2 *************************** 6. row *************************** partition_name: p5 table_rows: 0 *************************** 7. row *************************** partition_name: p6 table_rows: 4 *************************** 8. row *************************** partition_name: p7 table_rows: 0 8 rows in set (0.00 sec)
[9 Jun 2014 15:17]
Mattias Jonsson
This is a duplicate of bug#65112. Notice that the behavior is due to the KEY hashing algorithm, which will not be changed since it will need current KEY partitioned tables to be rebuilt. But what can be done is to implement another KEY hashing algorithm that has a better distribution (such as MD5, which is used by NDB).
[29 Jun 2021 18:25]
Shreya Gupta
I am also facing the same bug. Is there any possible solution for it?