Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
76d03e7a
Commit
76d03e7a
authored
Nov 21, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
f8dbbc01
b2e5a3f6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
3 deletions
+99
-3
mysql-test/r/subselect_mat_cost_bugs.result
mysql-test/r/subselect_mat_cost_bugs.result
+2
-2
mysql-test/r/subselect_sj.result
mysql-test/r/subselect_sj.result
+33
-0
mysql-test/r/subselect_sj_jcl6.result
mysql-test/r/subselect_sj_jcl6.result
+33
-0
mysql-test/t/subselect_sj.test
mysql-test/t/subselect_sj.test
+30
-0
sql/opt_subselect.h
sql/opt_subselect.h
+1
-1
No files found.
mysql-test/r/subselect_mat_cost_bugs.result
View file @
76d03e7a
...
...
@@ -346,8 +346,8 @@ WHERE t4.a >= t3.b
AND a = SOME (SELECT b FROM t5));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t5 index c c 10 NULL 2 Using where; Using index;
LooseScan
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t5.b 1 Using index condition; Using where
2 DEPENDENT SUBQUERY t5 index c c 10 NULL 2 Using where; Using index;
Start temporary
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t5.b 1 Using index condition; Using where
; End temporary
SELECT *
FROM t3
WHERE t3.b > ALL (
...
...
mysql-test/r/subselect_sj.result
View file @
76d03e7a
...
...
@@ -2050,4 +2050,37 @@ a
3
set optimizer_switch= @tmp_otimizer_switch;
drop table t1,t2;
#
# Bug #887496: semijoin with IN equality for the second part of an index
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (9), (0), (8), (5);
CREATE TABLE t2 (a int, b varchar(1), INDEX idx (b,a));
INSERT INTO t2 VALUES (5,'r'), (5,'z');
CREATE TABLE t3 (a int, b varchar(1), INDEX idx (b,a));
INSERT INTO t3 VALUES (5,'r'), (5,'z');
set @tmp_otimizer_switch= @@optimizer_switch;
SET SESSION optimizer_switch='semijoin=on,firstmatch=on';
SET SESSION optimizer_switch='loosescan=off';
EXPLAIN
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary
1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
a
5
SET SESSION optimizer_switch='loosescan=on';
EXPLAIN
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary
1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
a
5
set optimizer_switch= @tmp_otimizer_switch;
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect_sj_tmp;
mysql-test/r/subselect_sj_jcl6.result
View file @
76d03e7a
...
...
@@ -2061,6 +2061,39 @@ a
3
set optimizer_switch= @tmp_otimizer_switch;
drop table t1,t2;
#
# Bug #887496: semijoin with IN equality for the second part of an index
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (9), (0), (8), (5);
CREATE TABLE t2 (a int, b varchar(1), INDEX idx (b,a));
INSERT INTO t2 VALUES (5,'r'), (5,'z');
CREATE TABLE t3 (a int, b varchar(1), INDEX idx (b,a));
INSERT INTO t3 VALUES (5,'r'), (5,'z');
set @tmp_otimizer_switch= @@optimizer_switch;
SET SESSION optimizer_switch='semijoin=on,firstmatch=on';
SET SESSION optimizer_switch='loosescan=off';
EXPLAIN
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary
1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
a
5
SET SESSION optimizer_switch='loosescan=on';
EXPLAIN
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index idx idx 9 NULL 2 Using where; Using index; Start temporary
1 PRIMARY t3 ref idx idx 4 test.t2.b 1 Using index
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; End temporary; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2,t3 WHERE t2.b = t3.b);
a
5
set optimizer_switch= @tmp_otimizer_switch;
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect_sj_tmp;
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
...
...
mysql-test/t/subselect_sj.test
View file @
76d03e7a
...
...
@@ -1880,5 +1880,35 @@ set optimizer_switch= @tmp_otimizer_switch;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# Bug #887496: semijoin with IN equality for the second part of an index
--
echo
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
9
),
(
0
),
(
8
),
(
5
);
CREATE
TABLE
t2
(
a
int
,
b
varchar
(
1
),
INDEX
idx
(
b
,
a
));
INSERT
INTO
t2
VALUES
(
5
,
'r'
),
(
5
,
'z'
);
CREATE
TABLE
t3
(
a
int
,
b
varchar
(
1
),
INDEX
idx
(
b
,
a
));
INSERT
INTO
t3
VALUES
(
5
,
'r'
),
(
5
,
'z'
);
set
@
tmp_otimizer_switch
=
@@
optimizer_switch
;
SET
SESSION
optimizer_switch
=
'semijoin=on,firstmatch=on'
;
SET
SESSION
optimizer_switch
=
'loosescan=off'
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
a
IN
(
SELECT
t2
.
a
FROM
t2
,
t3
WHERE
t2
.
b
=
t3
.
b
);
SELECT
*
FROM
t1
WHERE
a
IN
(
SELECT
t2
.
a
FROM
t2
,
t3
WHERE
t2
.
b
=
t3
.
b
);
SET
SESSION
optimizer_switch
=
'loosescan=on'
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
a
IN
(
SELECT
t2
.
a
FROM
t2
,
t3
WHERE
t2
.
b
=
t3
.
b
);
SELECT
*
FROM
t1
WHERE
a
IN
(
SELECT
t2
.
a
FROM
t2
,
t3
WHERE
t2
.
b
=
t3
.
b
);
set
optimizer_switch
=
@
tmp_otimizer_switch
;
DROP
TABLE
t1
,
t2
,
t3
;
# The following command must be the last one the file
set
optimizer_switch
=@
subselect_sj_tmp
;
sql/opt_subselect.h
View file @
76d03e7a
...
...
@@ -170,7 +170,7 @@ class Loose_scan_opt
PREV_BITS
(
ulonglong
,
s
->
emb_sj_nest
->
sj_in_exprs
)
&&
// (2)
(
PREV_BITS
(
key_part_map
,
max_loose_keypart
+
1
)
&
// (3)
(
found_part
|
loose_scan_keyparts
))
==
// (3)
(
found_part
|
loose_scan_keyparts
)
&&
// (3)
PREV_BITS
(
key_part_map
,
max_loose_keypart
+
1
)
&&
// (3)
!
key_uses_partial_cols
(
s
->
table
,
key
))
{
/* Ok, can use the strategy */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment