-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Defragmentation support for partitioned InnoDB table
Summary: Add defragmentation of partitioned innodb table to Facebook defragmentation feature. You can specify some partition name for defragmentation with PARTITION phrase. Without PARTITION phrase, InnoDB will defragment all partition of the table. And running defragmentation on partition table with async_commit option, InnoDB will defragment all partitioned table in parallel (Not parallel threads, just one thread will defragment all indexes). Defragmentation of several indexes (at the same time) need a lot of disk reads and this cause the latency increasing of user query processing. ** Usage ** ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P1SP1) INDEX PRIMARY; ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P1SP1); ALTER TABLE t1 DEFRAGMENT INDEX ix_lname; ALTER TABLE t1 DEFRAGMENT; ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P1SP1) INDEX PRIMARY async_commit; ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P1SP1) async_commit; ALTER TABLE t1 DEFRAGMENT INDEX ix_lname async_commit; ALTER TABLE t1 DEFRAGMENT async_commit; This was contributed as: #10 Test Plan: TBA Reviewers: steaphan, over, pengt Reviewed By: pengt
- Loading branch information
1 parent
cdeb012
commit 4c2b5e8
Showing
12 changed files
with
254 additions
and
9 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
mysql-test/suite/parts/r/partition_alter_table_defragment.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
DROP TABLE if exists t1; | ||
call mtr.add_suppression("InnoDB: Warning: MySQL is trying to drop table "); | ||
## Create test table | ||
CREATE TABLE t1 ( | ||
id INT NOT NULL AUTO_INCREMENT, | ||
fname CHAR(30) DEFAULT NULL, | ||
lname CHAR(30) NOT NULL DEFAULT '', | ||
PRIMARY KEY (id, lname), | ||
INDEX ix_lname (lname) | ||
) ENGINE=InnoDB | ||
PARTITION BY RANGE (id) | ||
SUBPARTITION BY KEY (lname) | ||
SUBPARTITIONS 2 | ||
(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB, | ||
PARTITION p1 VALUES LESS THAN (300) ENGINE = InnoDB, | ||
PARTITION p2 VALUES LESS THAN (600) ENGINE = InnoDB, | ||
PARTITION p3 VALUES LESS THAN MAXVALUE ENGINE = InnoDB); | ||
CREATE TABLE t2 ( | ||
id INT NOT NULL AUTO_INCREMENT, | ||
fname CHAR(30) DEFAULT NULL, | ||
lname CHAR(30) NOT NULL DEFAULT '', | ||
PRIMARY KEY (id, lname), | ||
INDEX ix_lname (lname) | ||
) ENGINE=InnoDB | ||
PARTITION BY RANGE (id) | ||
(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB, | ||
PARTITION p1 VALUES LESS THAN (300) ENGINE = InnoDB, | ||
PARTITION p2 VALUES LESS THAN (600) ENGINE = InnoDB, | ||
PARTITION p3 VALUES LESS THAN MAXVALUE ENGINE = InnoDB); | ||
## Populate test table | ||
## Delete hole rows | ||
## Test-1 defragment specific sub-partition and index | ||
ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P0sp1, P1SP1) INDEX PRIMARY; | ||
## Test-2 defragment specific sub-partition without index | ||
ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P1SP1); | ||
## Test-3 defragment specific partition and index | ||
ALTER TABLE t2 DEFRAGMENT PARTITION (p2, P3) INDEX PRIMARY; | ||
## Test-4 defragment specific partition without index | ||
ALTER TABLE t2 DEFRAGMENT PARTITION (p1); | ||
## Test-5 defragment specific index without partition | ||
ALTER TABLE t1 DEFRAGMENT INDEX ix_lname; | ||
## Test-6 defragment whole partitioned table | ||
ALTER TABLE t2 DEFRAGMENT; | ||
## Clean test table | ||
DROP TABLE t1; | ||
DROP TABLE t2; |
82 changes: 82 additions & 0 deletions
82
mysql-test/suite/parts/t/partition_alter_table_defragment.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--source include/have_innodb.inc | ||
|
||
--disable_warnings | ||
DROP TABLE if exists t1; | ||
--enable_warnings | ||
|
||
call mtr.add_suppression("InnoDB: Warning: MySQL is trying to drop table "); | ||
|
||
--echo ## Create test table | ||
CREATE TABLE t1 ( | ||
id INT NOT NULL AUTO_INCREMENT, | ||
fname CHAR(30) DEFAULT NULL, | ||
lname CHAR(30) NOT NULL DEFAULT '', | ||
PRIMARY KEY (id, lname), | ||
INDEX ix_lname (lname) | ||
) ENGINE=InnoDB | ||
PARTITION BY RANGE (id) | ||
SUBPARTITION BY KEY (lname) | ||
SUBPARTITIONS 2 | ||
(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB, | ||
PARTITION p1 VALUES LESS THAN (300) ENGINE = InnoDB, | ||
PARTITION p2 VALUES LESS THAN (600) ENGINE = InnoDB, | ||
PARTITION p3 VALUES LESS THAN MAXVALUE ENGINE = InnoDB); | ||
|
||
CREATE TABLE t2 ( | ||
id INT NOT NULL AUTO_INCREMENT, | ||
fname CHAR(30) DEFAULT NULL, | ||
lname CHAR(30) NOT NULL DEFAULT '', | ||
PRIMARY KEY (id, lname), | ||
INDEX ix_lname (lname) | ||
) ENGINE=InnoDB | ||
PARTITION BY RANGE (id) | ||
(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB, | ||
PARTITION p1 VALUES LESS THAN (300) ENGINE = InnoDB, | ||
PARTITION p2 VALUES LESS THAN (600) ENGINE = InnoDB, | ||
PARTITION p3 VALUES LESS THAN MAXVALUE ENGINE = InnoDB); | ||
|
||
--echo ## Populate test table | ||
--disable_query_log | ||
INSERT INTO t1 VALUES (NULL, 'matt', 'lee'), (NULL, 'lara', 'kim'), (NULL, 'seonguck', 'ryu'); | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
INSERT INTO t1 SELECT NULL, fname, lname FROM t1; | ||
|
||
INSERT INTO t2 SELECT * FROM t1; | ||
|
||
--echo ## Delete hole rows | ||
let $delete_rows = 150; | ||
while($delete_rows) | ||
{ | ||
DELETE FROM t1 WHERE id = ROUND(RAND()*1000) % 768; | ||
DELETE FROM t2 WHERE id = ROUND(RAND()*1000) % 768; | ||
dec $delete_rows; | ||
} | ||
--enable_query_log | ||
|
||
--echo ## Test-1 defragment specific sub-partition and index | ||
ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P0sp1, P1SP1) INDEX PRIMARY; | ||
|
||
--echo ## Test-2 defragment specific sub-partition without index | ||
ALTER TABLE t1 DEFRAGMENT PARTITION (p0sp0, P1SP1); | ||
|
||
-- echo ## Test-3 defragment specific partition and index | ||
ALTER TABLE t2 DEFRAGMENT PARTITION (p2, P3) INDEX PRIMARY; | ||
|
||
-- echo ## Test-4 defragment specific partition without index | ||
ALTER TABLE t2 DEFRAGMENT PARTITION (p1); | ||
|
||
--echo ## Test-5 defragment specific index without partition | ||
ALTER TABLE t1 DEFRAGMENT INDEX ix_lname; | ||
|
||
--echo ## Test-6 defragment whole partitioned table | ||
ALTER TABLE t2 DEFRAGMENT; | ||
|
||
--echo ## Clean test table | ||
DROP TABLE t1; | ||
DROP TABLE t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters