1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fixed randomly failing test main.order_by_optimizer_innodb

The problem was that sometimes InnoDB returned sligtly wrong record count
for table, which causes the optimizer to disregard the result from
the range optimizer. The end result was that the optimizer choosed a
ref access instead of a range access which caused errors in buildbot.

Fixed by adding more rows to the table to ensure that table scan is
more costly than range scan of the given interval.
This commit is contained in:
Monty
2023-10-06 18:18:37 +03:00
parent 6e9b421f77
commit 424a7a2620
2 changed files with 13 additions and 20 deletions

View File

@ -1,4 +1,5 @@
--source include/have_innodb.inc
--source include/have_sequence.inc
--disable_warnings
drop table if exists t0,t1,t2,t3;
@ -7,11 +8,6 @@ drop table if exists t0,t1,t2,t3;
--echo #
--echo # MDEV-6402: Optimizer doesn't choose best execution plan when composite key is used
--echo #
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(a int);
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
CREATE TABLE t2 (
pk1 int(11) NOT NULL,
@ -25,13 +21,13 @@ CREATE TABLE t2 (
insert into t2
select
round(log(2,t1.a+1)),
t1.a,
t1.a,
round(log(2,seq+1)),
seq,
seq,
REPEAT('filler-data-', 10),
REPEAT('filler-data-', 10)
from
t1;
seq_0_to_1999;
select pk1, count(*) from t2 group by pk1;
@ -40,7 +36,7 @@ EXPLAIN SELECT * FROM t2 USE INDEX(ux_pk1_fd5) WHERE pk1=9 AND fd5 < 500 ORDER B
--echo # This also must use range, not ref. key_len must be 13
EXPLAIN SELECT * FROM t2 WHERE pk1=9 AND fd5 < 500 ORDER BY fd5 DESC LIMIT 10;
drop table t0,t1, t2;
drop table t2;
--echo #
--echo # MDEV-6814: Server crashes in calculate_key_len on query with ORDER BY