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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1eb21dc4
Commit
1eb21dc4
authored
Dec 25, 2010
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
1eb5e0e6
d9a81475
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
3 deletions
+82
-3
mysql-test/r/join_cache.result
mysql-test/r/join_cache.result
+35
-0
mysql-test/t/join_cache.test
mysql-test/t/join_cache.test
+37
-1
sql/opt_index_cond_pushdown.cc
sql/opt_index_cond_pushdown.cc
+10
-2
No files found.
mysql-test/r/join_cache.result
View file @
1eb21dc4
...
...
@@ -6087,4 +6087,39 @@ pk a pk a
50 ee 14 ee
SET SESSION join_cache_level = DEFAULT;
DROP TABLE t1,t2;
#
# Bug #694092: incorrect detection of index only pushdown conditions
#
CREATE TABLE t1 (
f1 varchar(10), f3 int(11), PRIMARY KEY (f3)
);
INSERT INTO t1 VALUES ('y',1),('or',5);
CREATE TABLE t2 (
f3 int(11), f2 varchar(1024), f4 varchar(10), PRIMARY KEY (f3)
);
INSERT INTO t2 VALUES (6,'RPOYT','y'),(10,'JINQE','m');
SET SESSION join_cache_level = 1;
SET SESSION optimizer_switch = 'index_condition_pushdown=off';
EXPLAIN
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using MRR
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using MRR; Using join buffer (flat, BNL join)
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
f1 f3 f3 f2 f4
SET SESSION optimizer_switch = 'index_condition_pushdown=on';
EXPLAIN
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using MRR
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using MRR; Using join buffer (flat, BNL join)
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
f1 f3 f3 f2 f4
SET SESSION join_cache_level = DEFAULT;
SET SESSION optimizer_switch = DEFAULT;
DROP TABLE t1,t2;
set @@optimizer_switch=@save_optimizer_switch;
mysql-test/t/join_cache.test
View file @
1eb21dc4
...
...
@@ -2704,6 +2704,7 @@ DROP TABLE t1,t2,t3,t4,t5;
--
echo
# Bug #670380: hash join for non-binary collation
--
echo
#
CREATE
TABLE
t1
(
pk
int
PRIMARY
KEY
,
a
varchar
(
32
));
CREATE
TABLE
t2
(
pk
int
PRIMARY
KEY
,
a
varchar
(
32
),
INDEX
idx
(
a
));
INSERT
INTO
t1
VALUES
...
...
@@ -2722,6 +2723,41 @@ SELECT * FROM t1,t2 WHERE t1.a=t2.a;
SET
SESSION
join_cache_level
=
DEFAULT
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Bug #694092: incorrect detection of index only pushdown conditions
--
echo
#
CREATE
TABLE
t1
(
f1
varchar
(
10
),
f3
int
(
11
),
PRIMARY
KEY
(
f3
)
);
INSERT
INTO
t1
VALUES
(
'y'
,
1
),(
'or'
,
5
);
CREATE
TABLE
t2
(
f3
int
(
11
),
f2
varchar
(
1024
),
f4
varchar
(
10
),
PRIMARY
KEY
(
f3
)
);
INSERT
INTO
t2
VALUES
(
6
,
'RPOYT'
,
'y'
),(
10
,
'JINQE'
,
'm'
);
SET
SESSION
join_cache_level
=
1
;
SET
SESSION
optimizer_switch
=
'index_condition_pushdown=off'
;
EXPLAIN
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
f1
=
t2
.
f4
AND
(
t1
.
f3
=
1
AND
t2
.
f3
=
4
OR
t1
.
f3
=
2
AND
t2
.
f3
=
6
);
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
f1
=
t2
.
f4
AND
(
t1
.
f3
=
1
AND
t2
.
f3
=
4
OR
t1
.
f3
=
2
AND
t2
.
f3
=
6
);
SET
SESSION
optimizer_switch
=
'index_condition_pushdown=on'
;
EXPLAIN
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
f1
=
t2
.
f4
AND
(
t1
.
f3
=
1
AND
t2
.
f3
=
4
OR
t1
.
f3
=
2
AND
t2
.
f3
=
6
);
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
f1
=
t2
.
f4
AND
(
t1
.
f3
=
1
AND
t2
.
f3
=
4
OR
t1
.
f3
=
2
AND
t2
.
f3
=
6
);
SET
SESSION
join_cache_level
=
DEFAULT
;
SET
SESSION
optimizer_switch
=
DEFAULT
;
DROP
TABLE
t1
,
t2
;
# this must be the last command in the file
set
@@
optimizer_switch
=@
save_optimizer_switch
;
sql/opt_index_cond_pushdown.cc
View file @
1eb21dc4
...
...
@@ -155,7 +155,11 @@ Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno,
new_cond
->
argument_list
()
->
push_back
(
fix
);
used_tables
|=
fix
->
used_tables
();
}
n_marked
+=
test
(
item
->
marker
==
ICP_COND_USES_INDEX_ONLY
);
if
(
test
(
item
->
marker
==
ICP_COND_USES_INDEX_ONLY
))
{
n_marked
++
;
item
->
marker
=
0
;
}
}
if
(
n_marked
==
((
Item_cond
*
)
cond
)
->
argument_list
()
->
elements
)
cond
->
marker
=
ICP_COND_USES_INDEX_ONLY
;
...
...
@@ -184,7 +188,11 @@ Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno,
if
(
!
fix
)
return
(
COND
*
)
0
;
new_cond
->
argument_list
()
->
push_back
(
fix
);
n_marked
+=
test
(
item
->
marker
==
ICP_COND_USES_INDEX_ONLY
);
if
(
test
(
item
->
marker
==
ICP_COND_USES_INDEX_ONLY
))
{
n_marked
++
;
item
->
marker
=
0
;
}
}
if
(
n_marked
==
((
Item_cond
*
)
cond
)
->
argument_list
()
->
elements
)
cond
->
marker
=
ICP_COND_USES_INDEX_ONLY
;
...
...
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