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
431ded10
Commit
431ded10
authored
Nov 22, 2012
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
13ba0dd2
db1db8fa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
5 deletions
+84
-5
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+41
-0
mysql-test/r/subselect_sj_jcl6.result
mysql-test/r/subselect_sj_jcl6.result
+2
-2
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+35
-0
sql/sql_select.cc
sql/sql_select.cc
+6
-3
No files found.
mysql-test/r/group_by.result
View file @
431ded10
...
...
@@ -2122,4 +2122,45 @@ the value below *must* be 1
show status like 'Created_tmp_disk_tables';
Variable_name Value
Created_tmp_disk_tables 1
#
# Bug #1002146: Unneeded filesort if usage of join buffer is not allowed
# (bug mdev-645)
#
CREATE TABLE t1 (pk int PRIMARY KEY, a int, INDEX idx(a));
INSERT INTO t1 VALUES (3,2), (2,3), (5,3), (6,4);
CREATE TABLE t2 (pk int PRIMARY KEY, a int, INDEX idx(a));
INSERT INTO t2 VALUES (9,0), (10,3), (6,4), (1,6), (3,100), (5,200);
set join_cache_level=0;
EXPLAIN
SELECT t2.a FROM t2 STRAIGHT_JOIN t1 ON t2.a <> 0 WHERE t2.a <> 6
GROUP BY t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx idx 5 NULL 5 Using where; Using index
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
SELECT t2.a FROM t2 STRAIGHT_JOIN t1 ON t2.a <> 0 WHERE t2.a <> 6
GROUP BY t2.a;
a
3
4
100
200
set join_cache_level=default;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='outer_join_with_cache=off';
EXPLAIN
SELECT t2.a FROM t2 LEFT JOIN t1 ON t2.a <> 0 WHERE t2.a <> 6
GROUP BY t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx idx 5 NULL 5 Using where; Using index
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using where; Using index
SELECT t2.a FROM t2 LEFT JOIN t1 ON t2.a <> 0 WHERE t2.a <> 6
GROUP BY t2.a;
a
0
3
4
100
200
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2;
# End of 5.3 tests
mysql-test/r/subselect_sj_jcl6.result
View file @
431ded10
...
...
@@ -2978,7 +2978,7 @@ EXPLAIN
SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
GROUP BY a HAVING a != 'z';
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t index idx_a idx_a 4 NULL
3 Using index; Using temporary; Using filesort
1 PRIMARY t index idx_a idx_a 4 NULL
1 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where
2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index
...
...
@@ -2992,7 +2992,7 @@ EXPLAIN
SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
GROUP BY a HAVING a != 'z';
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t index idx_a idx_a 4 NULL
3 Using index; Using temporary; Using filesort
1 PRIMARY t index idx_a idx_a 4 NULL
1 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where
2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index
...
...
mysql-test/t/group_by.test
View file @
431ded10
...
...
@@ -1486,4 +1486,39 @@ DROP TABLE t1;
--
echo
the
value
below
*
must
*
be
1
show
status
like
'Created_tmp_disk_tables'
;
--
echo
#
--
echo
# Bug #1002146: Unneeded filesort if usage of join buffer is not allowed
--
echo
# (bug mdev-645)
--
echo
#
CREATE
TABLE
t1
(
pk
int
PRIMARY
KEY
,
a
int
,
INDEX
idx
(
a
));
INSERT
INTO
t1
VALUES
(
3
,
2
),
(
2
,
3
),
(
5
,
3
),
(
6
,
4
);
CREATE
TABLE
t2
(
pk
int
PRIMARY
KEY
,
a
int
,
INDEX
idx
(
a
));
INSERT
INTO
t2
VALUES
(
9
,
0
),
(
10
,
3
),
(
6
,
4
),
(
1
,
6
),
(
3
,
100
),
(
5
,
200
);
set
join_cache_level
=
0
;
EXPLAIN
SELECT
t2
.
a
FROM
t2
STRAIGHT_JOIN
t1
ON
t2
.
a
<>
0
WHERE
t2
.
a
<>
6
GROUP
BY
t2
.
a
;
SELECT
t2
.
a
FROM
t2
STRAIGHT_JOIN
t1
ON
t2
.
a
<>
0
WHERE
t2
.
a
<>
6
GROUP
BY
t2
.
a
;
set
join_cache_level
=
default
;
set
@
save_optimizer_switch
=@@
optimizer_switch
;
set
optimizer_switch
=
'outer_join_with_cache=off'
;
EXPLAIN
SELECT
t2
.
a
FROM
t2
LEFT
JOIN
t1
ON
t2
.
a
<>
0
WHERE
t2
.
a
<>
6
GROUP
BY
t2
.
a
;
SELECT
t2
.
a
FROM
t2
LEFT
JOIN
t1
ON
t2
.
a
<>
0
WHERE
t2
.
a
<>
6
GROUP
BY
t2
.
a
;
set
optimizer_switch
=@
save_optimizer_switch
;
DROP
TABLE
t1
,
t2
;
--
echo
# End of 5.3 tests
sql/sql_select.cc
View file @
431ded10
...
...
@@ -7422,8 +7422,9 @@ get_best_combination(JOIN *join)
if
(
!
(
keyuse
=
join
->
best_positions
[
tablenr
].
key
))
{
j
->
type
=
JT_ALL
;
if
(
tablenr
!=
join
->
const_tables
)
join
->
full_join
=
1
;
if
(
join
->
best_positions
[
tablenr
].
use_join_buffer
&&
tablenr
!=
join
->
const_tables
)
join
->
full_join
=
1
;
}
/*if (join->best_positions[tablenr].sj_strategy == SJ_OPT_LOOSE_SCAN)
...
...
@@ -8436,7 +8437,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
We will use join cache here : prevent sorting of the first
table only and sort at the end.
*/
if
(
i
!=
join
->
const_tables
&&
join
->
table_count
>
join
->
const_tables
+
1
)
if
(
i
!=
join
->
const_tables
&&
join
->
table_count
>
join
->
const_tables
+
1
&&
join
->
best_positions
[
i
].
use_join_buffer
)
join
->
full_join
=
1
;
}
...
...
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