| 1 |
# |
| 2 |
# Test to cause merge of the pages (by updating to smaller) |
| 3 |
# test/tab1 should be created already with innodb_file_per_table=ON |
| 4 |
# The definition is intended to be based on |
| 5 |
# "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;" |
| 6 |
# |
| 7 |
|
| 8 |
--echo # check MERGE_THRESHOLD |
| 9 |
select t.NAME as TABLE_NAME, i.NAME as INDEX_NAME, i.MERGE_THRESHOLD |
| 10 |
from INFORMATION_SCHEMA.INNODB_TABLES t, INFORMATION_SCHEMA.INNODB_INDEXES i |
| 11 |
where t.TABLE_ID = i.TABLE_ID and t.NAME like 'test/tab1%' ORDER BY i.NAME; |
| 12 |
|
| 13 |
insert into tab1 values (1, repeat('a',2048)); |
| 14 |
insert into tab1 values (2, repeat('a',2048)); |
| 15 |
insert into tab1 values (3, repeat('a',2048)); |
| 16 |
insert into tab1 values (8, repeat('a',2048)); |
| 17 |
insert into tab1 values (9, repeat('a',2048)); |
| 18 |
insert into tab1 values (10, repeat('a',2048)); |
| 19 |
insert into tab1 values (11, repeat('a',2048)); |
| 20 |
insert into tab1 values (12, repeat('a',2048)); |
| 21 |
insert into tab1 values (4, repeat('a',2048)); |
| 22 |
insert into tab1 values (5, repeat('a',2048)); |
| 23 |
insert into tab1 values (6, repeat('a',2048)); |
| 24 |
insert into tab1 values (7, repeat('a',2048)); |
| 25 |
insert into tab1 values (13, repeat('a',2048)); |
| 26 |
insert into tab1 values (14, repeat('a',2048)); |
| 27 |
|
| 28 |
# filled 2 leaf pages have been prepared |
| 29 |
# | 1,..,7 | 8,..,14 | |
| 30 |
|
| 31 |
select PAGE_NUMBER, NUMBER_RECORDS |
| 32 |
from INFORMATION_SCHEMA.INNODB_TABLESPACES s1, |
| 33 |
INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2, |
| 34 |
INFORMATION_SCHEMA.INNODB_TABLES s3 |
| 35 |
where s1.SPACE = s2.SPACE AND s1.SPACE = s3.SPACE AND s3.NAME like 'test/tab1%' |
| 36 |
and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS; |
| 37 |
|
| 38 |
# turn on flags |
| 39 |
--disable_query_log |
| 40 |
SET GLOBAL innodb_monitor_enable=index_page_merge_attempts; |
| 41 |
SET GLOBAL innodb_monitor_reset=index_page_merge_attempts; |
| 42 |
SET GLOBAL innodb_monitor_enable=index_page_merge_successful; |
| 43 |
SET GLOBAL innodb_monitor_reset=index_page_merge_successful; |
| 44 |
--enable_query_log |
| 45 |
|
| 46 |
update tab1 set b='' where a = 12; |
| 47 |
update tab1 set b='' where a = 13; |
| 48 |
update tab1 set b='' where a = 14; |
| 49 |
update tab1 set b='' where a = 5; |
| 50 |
update tab1 set b='' where a = 6; |
| 51 |
update tab1 set b='' where a = 7; |
| 52 |
|
| 53 |
# not merged yet |
| 54 |
# | 1,2,3,4 | 8,9,10,11 | |
| 55 |
|
| 56 |
--echo # check page merge happens (nothing is expected) |
| 57 |
SELECT name,count_reset FROM information_schema.innodb_metrics |
| 58 |
WHERE name like 'index_page_merge_%'; |
| 59 |
|
| 60 |
select PAGE_NUMBER, NUMBER_RECORDS |
| 61 |
from INFORMATION_SCHEMA.INNODB_TABLESPACES s1, |
| 62 |
INFORMATION_SCHEMA.INNODB_BUFFER_PAGE s2, |
| 63 |
INFORMATION_SCHEMA.INNODB_TABLES s3 |
| 64 |
where s1.SPACE = s2.SPACE AND s1.SPACE = s3.SPACE AND s3.NAME like 'test/tab1%' |
| 65 |
and PAGE_TYPE = "INDEX" order by PAGE_NUMBER, NUMBER_RECORDS; |
| 66 |
|
| 67 |
update tab1 set b='' where a = 11; |
| 68 |
|
| 69 |
--echo # check page merge happens (MERGE_THRESHOLD=50 causes merge here) |
| 70 |
SELECT name,count_reset FROM information_schema.innodb_metrics |
| 71 |
WHERE name like 'index_page_merge_%'; |
| 72 |
|
| 73 |
|
| 74 |
update tab1 set b='' where a = 10; |
| 75 |
|
| 76 |
--echo # check page merge happens (MERGE_THRESHOLD=35 causes merge here) |
| 77 |
SELECT name,count_reset FROM information_schema.innodb_metrics |
| 78 |
WHERE name like 'index_page_merge_%'; |
| 79 |
|
| 80 |
|
| 81 |
update tab1 set b='' where a = 9; |
| 82 |
|
| 83 |
--echo # check page merge happens (MERGE_THRESHOLD=25 causes merge here) |
| 84 |
SELECT name,count_reset FROM information_schema.innodb_metrics |
| 85 |
WHERE name like 'index_page_merge_%'; |
| 86 |
|
| 87 |
--disable_query_log |
| 88 |
# Reset flags |
| 89 |
SET GLOBAL innodb_monitor_disable=index_page_merge_attempts; |
| 90 |
SET GLOBAL innodb_monitor_disable=index_page_merge_successful; |
| 91 |
|
| 92 |
--disable_warnings |
| 93 |
set global innodb_monitor_enable = default; |
| 94 |
set global innodb_monitor_disable = default; |
| 95 |
set global innodb_monitor_reset = default; |
| 96 |
set global innodb_monitor_reset_all = default; |
| 97 |
--enable_warnings |
| 98 |
--enable_query_log |