Skip to content

Commit

Permalink
make the heap.heap test portable
Browse files Browse the repository at this point in the history
in HEAP btree indexes, the address of a record in memory is part of the
key. So, when inserting many identical keys, the actual btree
shape is defined by how and where records in memory are allocated.

records_in_range uses floats to estimate the size of the chunk of the
btree between min and max records, it depends on the btree shape and,
thus, is not portable either. As are optimizer decisions that are based
on records_in_range estimations, if the number happens to be close
to a tipping point.

as a fix, reduce the number of matching rows, so that even with
system-specific variations the optimizer would still pick the
expected plan.

Fixes heap.heap failure (range vs ALL) on ppc64
  • Loading branch information
vuvova committed Jun 17, 2019
1 parent 13e8f72 commit 20bb4ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
21 changes: 9 additions & 12 deletions mysql-test/suite/heap/heap.result
Original file line number Diff line number Diff line change
Expand Up @@ -563,32 +563,32 @@ t1 CREATE TABLE `t1` (
) ENGINE=MEMORY DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
270
267
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
select count(*) from t1 where v='a';
count(*)
10
7
select count(*) from t1 where c='a';
count(*)
10
7
select count(*) from t1 where t='a';
count(*)
10
7
select count(*) from t1 where v='a ';
count(*)
10
7
select count(*) from t1 where c='a ';
count(*)
10
7
select count(*) from t1 where t='a ';
count(*)
10
7
select count(*) from t1 where v between 'a' and 'a ';
count(*)
10
7
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
count(*)
10
7
explain select count(*) from t1 where v='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const # Using where
Expand Down Expand Up @@ -618,9 +618,6 @@ qq
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
*a *a*a *
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v v 13 const # Using where
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/heap/heap.test
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ while ($1)
}
dec $1;
}
delete from t1 where v like 'a%' and length(v) > 7;
commit;
--enable_query_log
select count(*) from t1;
Expand Down

0 comments on commit 20bb4ed

Please sign in to comment.