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
f4484dfd
Commit
f4484dfd
authored
Mar 21, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-19008 Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery))
parent
482710b2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
1 deletion
+49
-1
mysql-test/main/func_debug.result
mysql-test/main/func_debug.result
+19
-0
mysql-test/main/func_debug.test
mysql-test/main/func_debug.test
+13
-0
sql/item.h
sql/item.h
+10
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+1
-1
sql/item_subselect.cc
sql/item_subselect.cc
+6
-0
No files found.
mysql-test/main/func_debug.result
View file @
f4484dfd
...
@@ -1655,3 +1655,22 @@ Note 1105 DBUG: [1] arg=2 handler=0 (time)
...
@@ -1655,3 +1655,22 @@ Note 1105 DBUG: [1] arg=2 handler=0 (time)
Note 1105 DBUG: [2] arg=3 handler=2 (datetime)
Note 1105 DBUG: [2] arg=3 handler=2 (datetime)
SET SESSION debug_dbug="-d,Predicant_to_list_comparator";
SET SESSION debug_dbug="-d,Predicant_to_list_comparator";
SET SESSION debug_dbug="-d,Item_func_in";
SET SESSION debug_dbug="-d,Item_func_in";
#
# MDEV-19008 Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery))
#
SET SESSION debug_dbug="+d,Item_subselect";
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
EXPLAIN SELECT * FROM t1 WHERE a IN (1,2,(SELECT MAX(a) FROM t1));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
2 SUBQUERY t1 ALL NULL NULL NULL NULL 10
SELECT * FROM t1 WHERE a IN (1,2,(SELECT MAX(a) FROM t1));
a
1
2
9
Warnings:
Note 1105 DBUG: Item_subselect::exec (select max(`test`.`t1`.`a`) from `test`.`t1`)
DROP TABLE t1;
SET SESSION debug_dbug="-d,Item_subselect";
mysql-test/main/func_debug.test
View file @
f4484dfd
...
@@ -475,3 +475,16 @@ SELECT
...
@@ -475,3 +475,16 @@ SELECT
SET
SESSION
debug_dbug
=
"-d,Predicant_to_list_comparator"
;
SET
SESSION
debug_dbug
=
"-d,Predicant_to_list_comparator"
;
SET
SESSION
debug_dbug
=
"-d,Item_func_in"
;
SET
SESSION
debug_dbug
=
"-d,Item_func_in"
;
--
echo
#
--
echo
# MDEV-19008 Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery))
--
echo
#
SET
SESSION
debug_dbug
=
"+d,Item_subselect"
;
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
a
IN
(
1
,
2
,(
SELECT
MAX
(
a
)
FROM
t1
));
SELECT
*
FROM
t1
WHERE
a
IN
(
1
,
2
,(
SELECT
MAX
(
a
)
FROM
t1
));
DROP
TABLE
t1
;
SET
SESSION
debug_dbug
=
"-d,Item_subselect"
;
sql/item.h
View file @
f4484dfd
...
@@ -1409,6 +1409,16 @@ class Item: public Value_source,
...
@@ -1409,6 +1409,16 @@ class Item: public Value_source,
LOWEST_PRECEDENCE
);
LOWEST_PRECEDENCE
);
}
}
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
class
Print
:
public
String
{
public:
Print
(
Item
*
item
,
enum_query_type
type
)
{
item
->
print
(
this
,
type
);
}
};
void
print_item_w_name
(
String
*
str
,
enum_query_type
query_type
);
void
print_item_w_name
(
String
*
str
,
enum_query_type
query_type
);
void
print_value
(
String
*
str
);
void
print_value
(
String
*
str
);
...
...
sql/item_cmpfunc.h
View file @
f4484dfd
...
@@ -2281,7 +2281,7 @@ class Item_func_in :public Item_func_opt_neg,
...
@@ -2281,7 +2281,7 @@ class Item_func_in :public Item_func_opt_neg,
{
{
for
(
uint
i
=
0
;
i
<
nitems
;
i
++
)
for
(
uint
i
=
0
;
i
<
nitems
;
i
++
)
{
{
if
(
!
items
[
i
]
->
const_item
())
if
(
!
items
[
i
]
->
const_item
()
||
items
[
i
]
->
is_expensive
()
)
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
sql/item_subselect.cc
View file @
f4484dfd
...
@@ -710,6 +710,12 @@ bool Item_subselect::exec()
...
@@ -710,6 +710,12 @@ bool Item_subselect::exec()
DBUG_ENTER
(
"Item_subselect::exec"
);
DBUG_ENTER
(
"Item_subselect::exec"
);
DBUG_ASSERT
(
fixed
);
DBUG_ASSERT
(
fixed
);
DBUG_EXECUTE_IF
(
"Item_subselect"
,
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_NOTE
,
ER_UNKNOWN_ERROR
,
"DBUG: Item_subselect::exec %s"
,
Item
::
Print
(
this
,
enum_query_type
(
QT_TO_SYSTEM_CHARSET
|
QT_WITHOUT_INTRODUCERS
)).
ptr
()););
/*
/*
Do not execute subselect in case of a fatal error
Do not execute subselect in case of a fatal error
or if the query has been killed.
or if the query has been killed.
...
...
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