Skip to content

Commit 8112682

Browse files
committed
Bug#31405780 Missing join pushdown for NDB due to not recognizing EQ_REF access path
In create_ref_for_key(), we determine whether to use eq_ref or ref access path based on null_rejecting property, among other things. However, null_rejecting is also determined by nullability of left-hand expression, which falsely makes us create a ref access path, and no pushdown to NDB is done (because the LHS fields where not recognized by NDB pushdown code). null_rejecting can be used to optimize both the left-hand and right-hand side of a predicate, as in left.field = right.keypart Not the assymmetry: Here, we have planned the join so that we know that fields from table "left" are read, and we want to lookup rows from table "right" based on a key field (keypart). null_rejecting is redefined so that it only depends on the predicate, and no longer using the nullability of the left-hand field. This means it can later be used to optimize both the left-hand and right-hand access paths. However, we also set null_rejecting to false when both operands are non-nullable, to avoid some redundant testing later. If null_rejecting is true and left-hand fields are nullable, we can safely filter out rows with such NULL values and skip reading rows from the right-hand side. We can also use null_rejecting property when determining access path for the right-hand table: If rows with NULL values in keypart columns can be filtered out, and there is a unique index on that column, then EQ_REF access path can be used. Due to this refactoring, we now correctly use EQ_REF instead of REF access in some tests, like in i_main.subquery_mat_cost_based_myisam. We also correctly add checks for IS NOT NULL in some tests, like in main.range_all. Finally, some IS NOT NULL conditions on non-nullable columns are eliminated from tests like main.subquery_sj_all. Another problem was redundant pushdown of equality condition involving parameter, when access path was already determined to be eq_ref. This was due to wrong implementation of Item_param:eq(). It now only returns true when compared to itself, it erroneously considered itself to be basic_const_item(). There are some test result changes due to these corrections: - A few redundant IS NOT NULL tests have been removed. - A few reasonable IS NOT NULL tests have been added. - In optimizer trace, a few "null_rejecting" are now "true" instead of "false", due to the changed semantics of the flag. - In main.partition_locking, there are a few more handler reads. This is due to a function call properly being recognized as nullable, and hence an extra "IS NULL" check is performed. (This could have been avoided by caching the function result the first time it was called.) Reviewed by: Ole John Aske <ole.john.aske@oracle.com>
1 parent ea81f5e commit 8112682

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+427
-410
lines changed

Diff for: mysql-test/r/group_by.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` USE INDE
18011801
EXPLAIN SELECT 1 FROM t1 WHERE a IN
18021802
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
18031803
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1804-
1 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using where; Using index
1804+
1 SIMPLE t1 NULL index PRIMARY,i2 PRIMARY 4 NULL 144 100.00 Using index
18051805
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.a 1 100.00 NULL
18061806
2 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 144 100.00 NULL
18071807
Warnings:

Diff for: mysql-test/r/group_min_max.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ explain select a1,a2,b,min(c),max(c) from t1
15271527
where exists ( select * from t2 where t2.c = t1.c )
15281528
group by a1,a2,b;
15291529
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1530-
1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using where; Using index
1530+
1 SIMPLE t1 NULL index idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 128 100.00 Using index
15311531
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 17 test.t1.c 1 100.00 NULL
15321532
2 MATERIALIZED t2 NULL index NULL idx_t2_1 163 NULL 164 100.00 Using index
15331533
Warnings:

Diff for: mysql-test/r/opt_costmodel_flush.result

+4-8
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ EXPLAIN
283283
"c2",
284284
"c3",
285285
"c4"
286-
],
287-
"attached_condition": "(`test`.`t1`.`i1` is not null)"
286+
]
288287
}
289288
},
290289
{
@@ -374,8 +373,7 @@ EXPLAIN
374373
"c2",
375374
"c3",
376375
"c4"
377-
],
378-
"attached_condition": "(`test`.`t1`.`i1` is not null)"
376+
]
379377
}
380378
},
381379
{
@@ -466,8 +464,7 @@ EXPLAIN
466464
"c2",
467465
"c3",
468466
"c4"
469-
],
470-
"attached_condition": "(`test`.`t1`.`i1` is not null)"
467+
]
471468
}
472469
},
473470
{
@@ -560,8 +557,7 @@ EXPLAIN
560557
"c2",
561558
"c3",
562559
"c4"
563-
],
564-
"attached_condition": "(`test`.`t1`.`i1` is not null)"
560+
]
565561
}
566562
},
567563
{

Diff for: mysql-test/r/opt_hints_join_order.result

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ WHERE t1.f1 IN (SELECT /*+ QB_NAME(subq1) */ f1 FROM t2) AND
3838
t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t2);
3939
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
4040
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL
41-
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (hash join)
41+
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join)
4242
1 SIMPLE <subquery3> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t2.f1 1 100.00 NULL
43-
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join)
43+
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
4444
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.f1 1 100.00 NULL
4545
3 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL
4646
2 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL
@@ -60,7 +60,7 @@ AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5);
6060
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
6161
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 NULL
6262
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join)
63-
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join)
63+
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
6464
1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index
6565
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.f1 1 100.00 NULL
6666
2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
@@ -381,7 +381,7 @@ count(*)
381381
explain SELECT /*+ JOIN_PREFIX(t1, t2, t3) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3
382382
WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5);
383383
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
384-
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where
384+
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
385385
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join)
386386
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join)
387387
1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index
@@ -397,7 +397,7 @@ count(*)
397397
explain SELECT /*+ JOIN_SUFFIX(t4, t5) */ count(*) FROM t1 JOIN t2 STRAIGHT_JOIN t3
398398
WHERE t1.f1 IN (SELECT f1 FROM t4) AND t2.f1 IN (SELECT f1 FROM t5);
399399
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
400-
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where
400+
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
401401
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (hash join)
402402
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join)
403403
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.f1 1 100.00 NULL
@@ -437,7 +437,7 @@ AND t2.f1 IN (SELECT /*+ QB_NAME(subq2) */ f1 FROM t5);
437437
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
438438
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 NULL
439439
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 5 100.00 Using join buffer (hash join)
440-
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (hash join)
440+
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
441441
1 SIMPLE t5 NULL eq_ref PRIMARY PRIMARY 4 test.t2.f1 1 100.00 Using index
442442
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.f1 1 100.00 NULL
443443
2 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 2 100.00 NULL

Diff for: mysql-test/r/opt_hints_subquery.result

+7-7
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ EXPLAIN
184184
SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH, LOOSESCAN) */ * FROM t2
185185
WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3);
186186
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
187-
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using where; Using index
187+
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index
188188
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t2.a 1 100.00 NULL
189189
2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index
190190
Warnings:
@@ -244,7 +244,7 @@ EXPLAIN
244244
SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t2
245245
WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3);
246246
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
247-
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using where; Using index
247+
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index
248248
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t2.a 1 100.00 NULL
249249
2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index
250250
Warnings:
@@ -298,7 +298,7 @@ EXPLAIN
298298
SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION, DUPSWEEDOUT) */ * FROM t2
299299
WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3);
300300
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
301-
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using where; Using index
301+
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index
302302
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t2.a 1 100.00 NULL
303303
2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index
304304
Warnings:
@@ -790,7 +790,7 @@ SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) NO_SEMIJOIN(@subq2) */ * FROM t1
790790
WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3
791791
WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2));
792792
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
793-
1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where
793+
1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL
794794
1 PRIMARY <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.a 1 100.00 NULL
795795
2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where
796796
3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index
@@ -827,7 +827,7 @@ NO_SEMIJOIN(@subq2) */ * FROM t1
827827
WHERE t1.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3
828828
WHERE t3.b IN (SELECT /*+ QB_NAME(subq2) */ a FROM t2));
829829
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
830-
1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 Using where
830+
1 PRIMARY t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL
831831
1 PRIMARY <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t1.a 1 100.00 NULL
832832
2 MATERIALIZED t3 NULL ALL a NULL NULL NULL 3 100.00 Using where
833833
3 DEPENDENT SUBQUERY t2 NULL index_subquery a a 4 func 1 100.00 Using index
@@ -1048,7 +1048,7 @@ EXPLAIN
10481048
SELECT /*+ NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * FROM t2
10491049
WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3);
10501050
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1051-
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using where; Using index
1051+
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index
10521052
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t2.a 1 100.00 NULL
10531053
2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index
10541054
Warnings:
@@ -1077,7 +1077,7 @@ EXPLAIN
10771077
SELECT /*+ SEMIJOIN(@subq1 MATERIALIZATION) */ * FROM t2
10781078
WHERE t2.a IN (SELECT /*+ QB_NAME(subq1) */ a FROM t3);
10791079
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1080-
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using where; Using index
1080+
1 SIMPLE t2 NULL index a a 4 NULL 4 100.00 Using index
10811081
1 SIMPLE <subquery2> NULL eq_ref <auto_distinct_key> <auto_distinct_key> 4 test.t2.a 1 100.00 NULL
10821082
2 MATERIALIZED t3 NULL index a a 4 NULL 3 100.00 Using index
10831083
Warnings:

Diff for: mysql-test/r/partition_locking.result

+16-16
Original file line numberDiff line numberDiff line change
@@ -5035,8 +5035,8 @@ a b
50355035
VARIABLE_NAME VARIABLE_VALUE
50365036
Handler_commit 1
50375037
Handler_external_lock 4
5038-
Handler_read_key 10
5039-
Handler_read_next 3
5038+
Handler_read_key 13
5039+
Handler_read_next 4
50405040
FLUSH STATUS;
50415041
SET autocommit = 0;
50425042
LOCK TABLES t1 read, t2 write;
@@ -5046,8 +5046,8 @@ a b
50465046
VARIABLE_NAME VARIABLE_VALUE
50475047
Handler_commit 8
50485048
Handler_external_lock 26
5049-
Handler_read_key 22
5050-
Handler_read_next 9
5049+
Handler_read_key 25
5050+
Handler_read_next 10
50515051
UNLOCK TABLES;
50525052
EXPLAIN SELECT * FROM t2 WHERE a = 7 + sf_a_from_t1b('1');
50535053
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
@@ -5091,8 +5091,8 @@ a b
50915091
VARIABLE_NAME VARIABLE_VALUE
50925092
Handler_commit 1
50935093
Handler_external_lock 4
5094-
Handler_read_key 10
5095-
Handler_read_next 3
5094+
Handler_read_key 13
5095+
Handler_read_next 4
50965096
FLUSH STATUS;
50975097
SET autocommit = 0;
50985098
LOCK TABLES t1 read, t2 write;
@@ -5102,8 +5102,8 @@ a b
51025102
VARIABLE_NAME VARIABLE_VALUE
51035103
Handler_commit 8
51045104
Handler_external_lock 26
5105-
Handler_read_key 22
5106-
Handler_read_next 9
5105+
Handler_read_key 25
5106+
Handler_read_next 10
51075107
UNLOCK TABLES;
51085108
EXPLAIN SELECT * FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2;
51095109
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
@@ -5327,8 +5327,8 @@ sf_add_1(a) - 1 sf_add_hello(b)
53275327
VARIABLE_NAME VARIABLE_VALUE
53285328
Handler_commit 1
53295329
Handler_external_lock 4
5330-
Handler_read_key 10
5331-
Handler_read_next 3
5330+
Handler_read_key 13
5331+
Handler_read_next 4
53325332
FLUSH STATUS;
53335333
SET autocommit = 0;
53345334
LOCK TABLES t1 read, t2 write;
@@ -5338,8 +5338,8 @@ sf_add_1(a) - 1 sf_add_hello(b)
53385338
VARIABLE_NAME VARIABLE_VALUE
53395339
Handler_commit 8
53405340
Handler_external_lock 26
5341-
Handler_read_key 22
5342-
Handler_read_next 9
5341+
Handler_read_key 25
5342+
Handler_read_next 10
53435343
UNLOCK TABLES;
53445344
EXPLAIN SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = 7 + sf_a_from_t1b('1');
53455345
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
@@ -5383,8 +5383,8 @@ sf_add_1(a) - 1 sf_add_hello(b)
53835383
VARIABLE_NAME VARIABLE_VALUE
53845384
Handler_commit 1
53855385
Handler_external_lock 4
5386-
Handler_read_key 10
5387-
Handler_read_next 3
5386+
Handler_read_key 13
5387+
Handler_read_next 4
53885388
FLUSH STATUS;
53895389
SET autocommit = 0;
53905390
LOCK TABLES t1 read, t2 write;
@@ -5394,8 +5394,8 @@ sf_add_1(a) - 1 sf_add_hello(b)
53945394
VARIABLE_NAME VARIABLE_VALUE
53955395
Handler_commit 8
53965396
Handler_external_lock 26
5397-
Handler_read_key 22
5398-
Handler_read_next 9
5397+
Handler_read_key 25
5398+
Handler_read_next 10
53995399
UNLOCK TABLES;
54005400
EXPLAIN SELECT sf_add_1(a) - 1, sf_add_hello(b) FROM t2 WHERE a = sf_a_from_t1b('1') AND a = 2;
54015401
id select_type table partitions type possible_keys key key_len ref rows filtered Extra

Diff for: mysql-test/r/range_all.result

+4-3
Original file line numberDiff line numberDiff line change
@@ -1961,23 +1961,24 @@ pk i4
19611961
EXPLAIN
19621962
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19631963
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1964-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1964+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19651965
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using index condition
19661966
Warnings:
19671967
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`)
19681968
EXPLAIN FORMAT=tree
19691969
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19701970
EXPLAIN
19711971
-> Nested loop inner join (cost=1.85 rows=3)
1972-
-> Table scan on t1 (cost=0.80 rows=3)
1972+
-> Filter: (t1.i4 is not null) (cost=0.80 rows=3)
1973+
-> Table scan on t1 (cost=0.80 rows=3)
19731974
-> Single-row index lookup on t2 using PRIMARY (pk=t1.i4), with index condition: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1)
19741975

19751976
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19761977
pk i4 pk i4
19771978
EXPLAIN
19781979
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
19791980
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1980-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1981+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19811982
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using index condition
19821983
Warnings:
19831984
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`)

Diff for: mysql-test/r/range_icp.result

+4-3
Original file line numberDiff line numberDiff line change
@@ -1961,23 +1961,24 @@ pk i4
19611961
EXPLAIN
19621962
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19631963
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1964-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1964+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19651965
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using index condition
19661966
Warnings:
19671967
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`)
19681968
EXPLAIN FORMAT=tree
19691969
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19701970
EXPLAIN
19711971
-> Nested loop inner join (cost=1.85 rows=3)
1972-
-> Table scan on t1 (cost=0.80 rows=3)
1972+
-> Filter: (t1.i4 is not null) (cost=0.80 rows=3)
1973+
-> Table scan on t1 (cost=0.80 rows=3)
19731974
-> Single-row index lookup on t2 using PRIMARY (pk=t1.i4), with index condition: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1)
19741975

19751976
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19761977
pk i4 pk i4
19771978
EXPLAIN
19781979
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
19791980
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1980-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1981+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19811982
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using index condition
19821983
Warnings:
19831984
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`)

Diff for: mysql-test/r/range_icp_mrr.result

+4-3
Original file line numberDiff line numberDiff line change
@@ -1961,23 +1961,24 @@ pk i4
19611961
EXPLAIN
19621962
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19631963
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1964-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1964+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19651965
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using index condition
19661966
Warnings:
19671967
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`)
19681968
EXPLAIN FORMAT=tree
19691969
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19701970
EXPLAIN
19711971
-> Nested loop inner join (cost=1.85 rows=3)
1972-
-> Table scan on t1 (cost=0.80 rows=3)
1972+
-> Filter: (t1.i4 is not null) (cost=0.80 rows=3)
1973+
-> Table scan on t1 (cost=0.80 rows=3)
19731974
-> Single-row index lookup on t2 using PRIMARY (pk=t1.i4), with index condition: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1)
19741975

19751976
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19761977
pk i4 pk i4
19771978
EXPLAIN
19781979
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
19791980
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1980-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1981+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19811982
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using index condition
19821983
Warnings:
19831984
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`)

Diff for: mysql-test/r/range_mrr.result

+4-3
Original file line numberDiff line numberDiff line change
@@ -1961,15 +1961,16 @@ pk i4
19611961
EXPLAIN
19621962
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19631963
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1964-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1964+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19651965
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where
19661966
Warnings:
19671967
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t2`.`pk` between `test`.`t1`.`i4` and `test`.`t1`.`i4`)
19681968
EXPLAIN FORMAT=tree
19691969
SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
19701970
EXPLAIN
19711971
-> Nested loop inner join (cost=1.85 rows=3)
1972-
-> Table scan on t1 (cost=0.80 rows=3)
1972+
-> Filter: (t1.i4 is not null) (cost=0.80 rows=3)
1973+
-> Table scan on t1 (cost=0.80 rows=3)
19731974
-> Filter: (t2.pk between t1.i4 and t1.i4) (cost=0.28 rows=1)
19741975
-> Single-row index lookup on t2 using PRIMARY (pk=t1.i4) (cost=0.28 rows=1)
19751976

@@ -1978,7 +1979,7 @@ pk i4 pk i4
19781979
EXPLAIN
19791980
SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
19801981
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1981-
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 NULL
1982+
1 SIMPLE t1 NULL ALL i4_uq NULL NULL NULL 3 100.00 Using where
19821983
1 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.i4 1 100.00 Using where
19831984
Warnings:
19841985
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i4` AS `i4`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`i4` AS `i4` from `test`.`t1` join `test`.`t1` `t2` where (`test`.`t1`.`i4` between `test`.`t2`.`pk` and `test`.`t2`.`pk`)

0 commit comments

Comments
 (0)