Skip to content

Commit

Permalink
Speed up innodb_gis.rtree_split
Browse files Browse the repository at this point in the history
INSERT...SELECT reading from an InnoDB table is slow due to
creating explicit record locks. Use the sequence engine instead.

Also, remove the space before rtr_page_need_second_split
to actually make the debug injection work.
  • Loading branch information
dr-m committed Apr 28, 2020
1 parent fae70d6 commit 5a1d931
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 90 deletions.
56 changes: 14 additions & 42 deletions mysql-test/suite/innodb_gis/r/rtree_split.result
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
begin;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_576;
SET @saved_dbug = @@SESSION.debug_dbug;
SET debug_dbug = '+d, rtr_page_need_second_split';
insert into t1 select * from t1;
SET debug_dbug = '+d,rtr_page_need_second_split';
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_576;
SET debug_dbug = @saved_dbug;
delete from t1;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
rollback;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_2304;
begin;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_2304;
rollback;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_71424;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
Expand Down
64 changes: 16 additions & 48 deletions mysql-test/suite/innodb_gis/t/rtree_split.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split, mostly on duplciate records.
# This test case will test R-tree split, mostly on duplicate records.

# Not supported in embedded
--source include/not_embedded.inc
Expand All @@ -8,65 +8,33 @@
--source include/big_test.inc
--source include/not_valgrind.inc
--source include/have_debug.inc
--source include/have_sequence.inc

# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;

begin;
# Insert enough values to let R-tree split.
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));

insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_576;

#Check second round spliting.
SET @saved_dbug = @@SESSION.debug_dbug;
SET debug_dbug = '+d, rtr_page_need_second_split';
insert into t1 select * from t1;
SET debug_dbug = '+d,rtr_page_need_second_split';
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_576;
SET debug_dbug = @saved_dbug;
rollback;

delete from t1;

insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));

insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;

insert into t1 select * from t1;
insert into t1 select * from t1;

insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_2304;
begin;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_2304;
rollback;
check table t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
from seq_1_to_71424;
check table t1;

select count(*) from t1;
Expand Down

0 comments on commit 5a1d931

Please sign in to comment.