|
| 1 | +# |
| 2 | +# Bug#67718: InnoDB drastically under-fills pages in certain conditions |
| 3 | +# |
| 4 | +SET @old_innodb_file_per_table = @@GLOBAL.innodb_file_per_table; |
| 5 | +SET GLOBAL innodb_file_per_table = ON; |
| 6 | +SET @old_innodb_index_page_split_mode = @@GLOBAL.innodb_index_page_split_mode; |
| 7 | +SET GLOBAL innodb_index_page_split_mode = "symmetric,lower,upper"; |
| 8 | +CREATE TABLE page_split_test |
| 9 | +( |
| 10 | +id BIGINT UNSIGNED NOT NULL, |
| 11 | +payload1 CHAR(255) NOT NULL, |
| 12 | +payload2 CHAR(255) NOT NULL, |
| 13 | +payload3 CHAR(255) NOT NULL, |
| 14 | +payload4 CHAR(255) NOT NULL, |
| 15 | +PRIMARY KEY (`id`) |
| 16 | +) ENGINE=INNODB; |
| 17 | +# Fill up the root page, but don't split it. |
| 18 | +INSERT INTO page_split_test VALUES (1, REPEAT("A", 255), REPEAT("B", 255), |
| 19 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 20 | +INSERT INTO page_split_test VALUES (2, REPEAT("A", 255), REPEAT("B", 255), |
| 21 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 22 | +INSERT INTO page_split_test VALUES (3, REPEAT("A", 255), REPEAT("B", 255), |
| 23 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 24 | +INSERT INTO page_split_test VALUES (4, REPEAT("A", 255), REPEAT("B", 255), |
| 25 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 26 | +INSERT INTO page_split_test VALUES (5, REPEAT("A", 255), REPEAT("B", 255), |
| 27 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 28 | +INSERT INTO page_split_test VALUES (6, REPEAT("A", 255), REPEAT("B", 255), |
| 29 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 30 | +INSERT INTO page_split_test VALUES (7, REPEAT("A", 255), REPEAT("B", 255), |
| 31 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 32 | +INSERT INTO page_split_test VALUES (8, REPEAT("A", 255), REPEAT("B", 255), |
| 33 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 34 | +INSERT INTO page_split_test VALUES (9, REPEAT("A", 255), REPEAT("B", 255), |
| 35 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 36 | +INSERT INTO page_split_test VALUES (10, REPEAT("A", 255), REPEAT("B", 255), |
| 37 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 38 | +INSERT INTO page_split_test VALUES (11, REPEAT("A", 255), REPEAT("B", 255), |
| 39 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 40 | +INSERT INTO page_split_test VALUES (12, REPEAT("A", 255), REPEAT("B", 255), |
| 41 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 42 | +INSERT INTO page_split_test VALUES (13, REPEAT("A", 255), REPEAT("B", 255), |
| 43 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 44 | +INSERT INTO page_split_test VALUES (14, REPEAT("A", 255), REPEAT("B", 255), |
| 45 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 46 | +# The next insert will trigger the root page to be split into a root |
| 47 | +# non-leaf page and two leaf pages, both about half full. |
| 48 | +INSERT INTO page_split_test VALUES (15, REPEAT("A", 255), REPEAT("B", 255), |
| 49 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 50 | +# Insert enough records to fill up the right-most leaf page, but don't |
| 51 | +# split it. |
| 52 | +INSERT INTO page_split_test VALUES (16, REPEAT("A", 255), REPEAT("B", 255), |
| 53 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 54 | +INSERT INTO page_split_test VALUES (17, REPEAT("A", 255), REPEAT("B", 255), |
| 55 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 56 | +INSERT INTO page_split_test VALUES (18, REPEAT("A", 255), REPEAT("B", 255), |
| 57 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 58 | +INSERT INTO page_split_test VALUES (19, REPEAT("A", 255), REPEAT("B", 255), |
| 59 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 60 | +INSERT INTO page_split_test VALUES (20, REPEAT("A", 255), REPEAT("B", 255), |
| 61 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 62 | +INSERT INTO page_split_test VALUES (21, REPEAT("A", 255), REPEAT("B", 255), |
| 63 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 64 | +# Increase the id by some amount, and insert a few records in descending |
| 65 | +# order from that point. Each row inserted would split the "full" page |
| 66 | +# from above, and create a new page for the single record. |
| 67 | +INSERT INTO page_split_test VALUES (30, REPEAT("A", 255), REPEAT("B", 255), |
| 68 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 69 | +INSERT INTO page_split_test VALUES (29, REPEAT("A", 255), REPEAT("B", 255), |
| 70 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 71 | +INSERT INTO page_split_test VALUES (28, REPEAT("A", 255), REPEAT("B", 255), |
| 72 | +REPEAT("C", 255), REPEAT("D", 255)); |
| 73 | +# Dump the page information about the test table. The right-most page |
| 74 | +# has only one record as the record (key 30) was inserted in ascending |
| 75 | +# order. The remaining nodes are split in half and filled by the later |
| 76 | +# inserts. |
| 77 | +SELECT page_number, page_type, number_records |
| 78 | +FROM information_schema.innodb_buffer_page |
| 79 | +WHERE table_name = "test/page_split_test" AND index_name = "PRIMARY" |
| 80 | + ORDER BY page_number; |
| 81 | +page_number page_type number_records |
| 82 | +3 INDEX 4 |
| 83 | +4 INDEX 7 |
| 84 | +5 INDEX 7 |
| 85 | +6 INDEX 1 |
| 86 | +7 INDEX 9 |
| 87 | +DROP TABLE page_split_test; |
| 88 | +# |
| 89 | +# Test page split behavior when keys are being inserted in order. |
| 90 | +# |
| 91 | +CREATE TABLE page_split_test |
| 92 | +( |
| 93 | +id BIGINT UNSIGNED NOT NULL, |
| 94 | +payload CHAR(255) NOT NULL, |
| 95 | +PRIMARY KEY (`id`) |
| 96 | +) ENGINE=INNODB; |
| 97 | +# Populate table with 300 rows in ascending key order. |
| 98 | + |
| 99 | +# Space utilization is the same across leaf pages, except at the end |
| 100 | +# since it wasn't completely filled up. |
| 101 | +SELECT page_number, page_type, number_records |
| 102 | +FROM information_schema.innodb_buffer_page |
| 103 | +WHERE table_name = "test/page_split_test" AND index_name = "PRIMARY" |
| 104 | + ORDER BY page_number; |
| 105 | +page_number page_type number_records |
| 106 | +3 INDEX 7 |
| 107 | +4 INDEX 27 |
| 108 | +5 INDEX 54 |
| 109 | +6 INDEX 54 |
| 110 | +7 INDEX 54 |
| 111 | +8 INDEX 54 |
| 112 | +9 INDEX 54 |
| 113 | +10 INDEX 3 |
| 114 | +TRUNCATE TABLE page_split_test; |
| 115 | +# Populate table with 300 rows in descending key order. |
| 116 | + |
| 117 | +# Space utilization is the same across leaf pages, except at the end |
| 118 | +# since it wasn't completely filled up. |
| 119 | +SELECT page_number, page_type, number_records |
| 120 | +FROM information_schema.innodb_buffer_page |
| 121 | +WHERE table_name = "test/page_split_test" AND index_name = "PRIMARY" |
| 122 | + ORDER BY page_number; |
| 123 | +page_number page_type number_records |
| 124 | +3 INDEX 7 |
| 125 | +4 INDEX 54 |
| 126 | +5 INDEX 27 |
| 127 | +6 INDEX 54 |
| 128 | +7 INDEX 54 |
| 129 | +8 INDEX 54 |
| 130 | +9 INDEX 54 |
| 131 | +10 INDEX 3 |
| 132 | +DROP TABLE page_split_test; |
| 133 | +SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; |
| 134 | +SET GLOBAL innodb_index_page_split_mode = @old_innodb_index_page_split_mode; |
0 commit comments