Skip to content

Commit 422774b

Browse files
committed
MDEV-10683: main.order_by_optimizer_innodb fails in buildbot
Fix order_by_optimizer_innodb and order_by_innodb tests. The problem was that the query could be ran before InnoDB was ready to provide a realistic statistic for #records in the table. It provided a number that was too low, which caused the optimizer to decide that range access plan wasn't advantageous and discard it.
1 parent e4ce61a commit 422774b

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

mysql-test/main/order_by_innodb.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ insert into t2 values
159159
(1,2,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
160160
(2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
161161
(3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00');
162+
analyze table t1,t2 persistent for all;
163+
Table Op Msg_type Msg_text
164+
test.t1 analyze status Engine-independent statistics collected
165+
test.t1 analyze status OK
166+
test.t2 analyze status Engine-independent statistics collected
167+
test.t2 analyze status OK
162168
select
163169
t1.id,t2.id
164170
from
@@ -177,6 +183,10 @@ id id
177183
2 1
178184
3 3
179185
create index for_latest_sort on t2 (d1 desc, d2 desc, id desc);
186+
analyze table t2 persistent for all;
187+
Table Op Msg_type Msg_text
188+
test.t2 analyze status Engine-independent statistics collected
189+
test.t2 analyze status OK
180190
select
181191
t1.id,t2.id
182192
from

mysql-test/main/order_by_innodb.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ insert into t2 values
148148
(2,3,'2019-03-05 00:00:00','2019-03-06 00:00:00'),
149149
(3,3,'2019-03-06 00:00:00','2019-03-05 00:00:00');
150150

151+
analyze table t1,t2 persistent for all;
151152
select
152153
t1.id,t2.id
153154
from
@@ -163,6 +164,7 @@ from
163164
);
164165

165166
create index for_latest_sort on t2 (d1 desc, d2 desc, id desc);
167+
analyze table t2 persistent for all;
166168

167169
select
168170
t1.id,t2.id

mysql-test/main/order_by_optimizer_innodb.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ REPEAT('filler-data-', 10),
2424
REPEAT('filler-data-', 10)
2525
from
2626
t1;
27+
analyze table t2 persistent for all;
28+
Table Op Msg_type Msg_text
29+
test.t2 analyze status Engine-independent statistics collected
30+
test.t2 analyze status OK
2731
select pk1, count(*) from t2 group by pk1;
2832
pk1 count(*)
2933
0 1

mysql-test/main/order_by_optimizer_innodb.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ select
3333
from
3434
t1;
3535

36+
analyze table t2 persistent for all;
3637
select pk1, count(*) from t2 group by pk1;
3738

3839
--echo # The following should use range(ux_pk1_fd5), two key parts (key_len=5+8=13)

0 commit comments

Comments
 (0)