We are trying to move data from one table that currently has over 1B rows to a partitioned table. But as we started to do so we notice that half of the partitions are empty, why is that? Table is partitioned by the column that has UUIDv4 values.
Our table definition:
CREATE TABLE table1 (
`col1` varchar(36) NOT NULL DEFAULT '',
`col2` varchar(256) NOT NULL DEFAULT '',
`col3` datetime NOT NULL DEFAULT NOW(),
UNIQUE KEY `unq_col1_col2 (`col1`,`col2`),
KEY `idx_col3` (`col3`)
)
ENGINE=InnoDB
PARTITION BY KEY(col1)
PARTITIONS 100;
INFORMATION_SCHEMA.PARTITIONS
output:
PARTITION_NAME TABLE_ROWS
p0 136532
p1 0
p2 339523
p3 0
p4 156955
p5 0
p6 305700
p7 0
p8 209548
p9 0
p10 329291
p11 0
p12 152995
p13 0
p14 388600
p15 0
p16 251903
p17 0
p18 364532
p19 0
p20 200799
p21 0
......
p89 0
p90 303628
p91 0
p92 215546
p93 0
p94 399165
p95 0
p96 210364
p97 0
p98 318675
p99 0
We are using Google Cloud SQL (MySQL) which is currently on version 5.7.32-google-log
.
INSERT ... ON DUPLICATE KEY UPDATE ...
) records and deleting records by thecol1
+col2
. This table currently has 1B of records and they are overwritten every 7 days, but by the end of the year with current growth, we will be doing this with over 20B of records every 7 days. Is there a better way to deal with this?SHOW ENGINE=InnoDB STATUS
(at least the deadlock part), so we can see more details.col1
values in it. Here is the example of how we do it currently: dbfiddle.uk/… I can't send you the output of theSHOW ENGINE=InnoDB STATUS
as we are no longer using the old table and do not have the deadlocks. I'll try to see if I can replicate the same behavior on our staging environment to send you that.