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
bb15b9e2
Commit
bb15b9e2
authored
May 19, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
parent
bac6bbab
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
309 additions
and
217 deletions
+309
-217
sql/item.h
sql/item.h
+10
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+47
-0
sql/item_geofunc.h
sql/item_geofunc.h
+7
-3
sql/sql_select.cc
sql/sql_select.cc
+245
-214
No files found.
sql/item.h
View file @
bb15b9e2
...
...
@@ -59,6 +59,9 @@ struct TABLE_LIST;
void
item_init
(
void
);
/* Init item functions */
class
Item_field
;
class
user_var_entry
;
class
JOIN
;
struct
KEY_FIELD
;
struct
SARGABLE_PARAM
;
static
inline
uint32
...
...
@@ -1137,6 +1140,13 @@ class Item: public Type_std_attributes
}
virtual
COND
*
remove_eq_conds
(
THD
*
thd
,
Item
::
cond_result
*
cond_value
,
bool
top_level
);
virtual
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
{
return
;
}
/*
Checks whether the item is:
- a simple equality (field=field_item or field=constant_item), or
...
...
sql/item_cmpfunc.h
View file @
bb15b9e2
...
...
@@ -122,6 +122,10 @@ class Arg_comparator: public Sql_alloc
class
Item_bool_func
:
public
Item_int_func
{
protected:
void
add_key_fields_optimize_op
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
,
bool
equal_func
);
public:
Item_bool_func
()
:
Item_int_func
()
{}
Item_bool_func
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
...
...
@@ -434,6 +438,13 @@ class Item_bool_rowready_func2 :public Item_bool_func2
return
min_max_arg_item
->
field
->
can_optimize_group_min_max
(
this
,
const_item
);
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
{
return
add_key_fields_optimize_op
(
join
,
key_fields
,
and_level
,
usable_tables
,
sargables
,
false
);
}
};
/**
...
...
@@ -512,6 +523,9 @@ class Item_func_trig_cond: public Item_bool_func
const
char
*
func_name
()
const
{
return
"trigcond"
;
};
bool
const_item
()
const
{
return
FALSE
;
}
bool
*
get_trig_var
()
{
return
trig_var
;
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
};
class
Item_func_not_all
:
public
Item_func_not
...
...
@@ -567,6 +581,13 @@ class Item_func_eq :public Item_bool_rowready_func2
COND
*
build_equal_items
(
THD
*
thd
,
COND_EQUAL
*
inherited
,
bool
link_item_fields
,
COND_EQUAL
**
cond_equal_ref
);
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
{
return
add_key_fields_optimize_op
(
join
,
key_fields
,
and_level
,
usable_tables
,
sargables
,
true
);
}
bool
check_equality
(
THD
*
thd
,
COND_EQUAL
*
cond
,
List
<
Item
>
*
eq_list
);
/*
- If this equality is created from the subquery's IN-equality:
...
...
@@ -591,6 +612,13 @@ class Item_func_equal :public Item_bool_rowready_func2
cond_result
eq_cmp_result
()
const
{
return
COND_TRUE
;
}
const
char
*
func_name
()
const
{
return
"<=>"
;
}
Item
*
neg_transformer
(
THD
*
thd
)
{
return
0
;
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
{
return
add_key_fields_optimize_op
(
join
,
key_fields
,
and_level
,
usable_tables
,
sargables
,
true
);
}
};
...
...
@@ -656,6 +684,8 @@ class Item_func_ne :public Item_bool_rowready_func2
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_KEY
;
}
const
char
*
func_name
()
const
{
return
"<>"
;
}
Item
*
negated_item
();
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
};
...
...
@@ -712,6 +742,9 @@ class Item_func_between :public Item_func_opt_neg
bool
eval_not_null_tables
(
uchar
*
opt_arg
);
void
fix_after_pullout
(
st_select_lex
*
new_parent
,
Item
**
ref
);
bool
count_sargable_conds
(
uchar
*
arg
);
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
};
...
...
@@ -1392,6 +1425,8 @@ class Item_func_in :public Item_func_opt_neg
}
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_KEY
;
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
enum
Functype
functype
()
const
{
return
IN_FUNC
;
}
const
char
*
func_name
()
const
{
return
" IN "
;
}
...
...
@@ -1436,6 +1471,8 @@ class Item_func_null_predicate :public Item_bool_func
public:
Item_func_null_predicate
(
Item
*
a
)
:
Item_bool_func
(
a
)
{
sargable
=
true
;
}
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_NULL
;
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
CHARSET_INFO
*
compare_collation
()
const
{
return
args
[
0
]
->
collation
.
collation
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
1
;
maybe_null
=
0
;
}
...
...
@@ -1587,6 +1624,8 @@ class Item_func_like :public Item_bool_func2
*/
return
compare_collation
()
==
&
my_charset_bin
?
COND_TRUE
:
COND_OK
;
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
const
char
*
func_name
()
const
{
return
"like"
;
}
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
void
cleanup
();
...
...
@@ -1781,6 +1820,9 @@ class Item_cond :public Item_bool_func
COND_EQUAL
**
cond_equal_ref
);
COND
*
remove_eq_conds
(
THD
*
thd
,
Item
::
cond_result
*
cond_value
,
bool
top_level
);
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
void
split_sum_func
(
THD
*
thd
,
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
);
friend
int
setup_conds
(
THD
*
thd
,
TABLE_LIST
*
tables
,
TABLE_LIST
*
leaves
,
...
...
@@ -1971,6 +2013,9 @@ class Item_equal: public Item_bool_func
COND
*
build_equal_items
(
THD
*
thd
,
COND_EQUAL
*
inherited
,
bool
link_item_fields
,
COND_EQUAL
**
cond_equal_ref
);
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
bool
walk
(
Item_processor
processor
,
bool
walk_subquery
,
uchar
*
arg
);
Item
*
transform
(
Item_transformer
transformer
,
uchar
*
arg
);
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
);
...
...
@@ -2125,6 +2170,8 @@ class Item_cond_and :public Item_cond
COND
*
build_equal_items
(
THD
*
thd
,
COND_EQUAL
*
inherited
,
bool
link_item_fields
,
COND_EQUAL
**
cond_equal_ref
);
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
);
};
inline
bool
is_cond_and
(
Item
*
item
)
...
...
sql/item_geofunc.h
View file @
bb15b9e2
...
...
@@ -288,6 +288,13 @@ class Item_func_spatial_rel: public Item_bool_func
enum
Functype
rev_functype
()
const
{
return
spatial_rel
;
}
bool
is_null
()
{
(
void
)
val_int
();
return
null_value
;
}
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_OP
;
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
{
return
add_key_fields_optimize_op
(
join
,
key_fields
,
and_level
,
usable_tables
,
sargables
,
false
);
}
};
...
...
@@ -404,7 +411,6 @@ class Item_func_isempty: public Item_bool_func
public:
Item_func_isempty
(
Item
*
a
)
:
Item_bool_func
(
a
)
{}
longlong
val_int
();
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_NONE
;
}
const
char
*
func_name
()
const
{
return
"st_isempty"
;
}
void
fix_length_and_dec
()
{
maybe_null
=
1
;
}
};
...
...
@@ -418,7 +424,6 @@ class Item_func_issimple: public Item_bool_func
public:
Item_func_issimple
(
Item
*
a
)
:
Item_bool_func
(
a
)
{}
longlong
val_int
();
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_NONE
;
}
const
char
*
func_name
()
const
{
return
"st_issimple"
;
}
void
fix_length_and_dec
()
{
maybe_null
=
1
;
}
};
...
...
@@ -428,7 +433,6 @@ class Item_func_isclosed: public Item_bool_func
public:
Item_func_isclosed
(
Item
*
a
)
:
Item_bool_func
(
a
)
{}
longlong
val_int
();
optimize_type
select_optimize
()
const
{
return
OPTIMIZE_NONE
;
}
const
char
*
func_name
()
const
{
return
"st_isclosed"
;
}
void
fix_length_and_dec
()
{
maybe_null
=
1
;
}
};
...
...
sql/sql_select.cc
View file @
bb15b9e2
This diff is collapsed.
Click to expand it.
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