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
38bc3bba
Commit
38bc3bba
authored
Feb 09, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
777b6b8c
4b24105d
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
43 deletions
+62
-43
mysql-test/r/optimizer_switch.result
mysql-test/r/optimizer_switch.result
+18
-18
sql/mysql_priv.h
sql/mysql_priv.h
+8
-5
sql/mysqld.cc
sql/mysqld.cc
+5
-2
sql/sql_join_cache.cc
sql/sql_join_cache.cc
+30
-17
sql/sql_join_cache.h
sql/sql_join_cache.h
+1
-1
No files found.
mysql-test/r/optimizer_switch.result
View file @
38bc3bba
This diff is collapsed.
Click to expand it.
sql/mysql_priv.h
View file @
38bc3bba
...
...
@@ -580,11 +580,12 @@ protected:
#define OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL (1<<16)
#define OPTIMIZER_SWITCH_JOIN_CACHE_HASHED (1<<17)
#define OPTIMIZER_SWITCH_JOIN_CACHE_BKA (1<<18)
#define OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE (1<<19)
#ifdef DBUG_OFF
# define OPTIMIZER_SWITCH_LAST (1<<19)
#else
# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<19)
# define OPTIMIZER_SWITCH_LAST (1<<20)
#else
# define OPTIMIZER_SWITCH_TABLE_ELIMINATION (1<<20)
# define OPTIMIZER_SWITCH_LAST (1<<21)
#endif
#ifdef DBUG_OFF
...
...
@@ -605,7 +606,8 @@ protected:
OPTIMIZER_SWITCH_SUBQUERY_CACHE | \
OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL | \
OPTIMIZER_SWITCH_JOIN_CACHE_HASHED | \
OPTIMIZER_SWITCH_JOIN_CACHE_BKA)
OPTIMIZER_SWITCH_JOIN_CACHE_BKA | \
OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE)
#else
# define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
...
...
@@ -623,7 +625,8 @@ protected:
OPTIMIZER_SWITCH_MRR_SORT_KEYS|\
OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL | \
OPTIMIZER_SWITCH_JOIN_CACHE_HASHED | \
OPTIMIZER_SWITCH_JOIN_CACHE_BKA)
OPTIMIZER_SWITCH_JOIN_CACHE_BKA | \
OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE)
#endif
/*
...
...
sql/mysqld.cc
View file @
38bc3bba
...
...
@@ -351,6 +351,7 @@ static const char *optimizer_switch_names[]=
"join_cache_incremental"
,
"join_cache_hashed"
,
"join_cache_bka"
,
"optimize_join_buffer_size"
,
#ifndef DBUG_OFF
"table_elimination"
,
#endif
...
...
@@ -379,6 +380,7 @@ static const unsigned int optimizer_switch_names_len[]=
sizeof
(
"join_cache_incremental"
)
-
1
,
sizeof
(
"join_cache_hashed"
)
-
1
,
sizeof
(
"join_cache_bka"
)
-
1
,
sizeof
(
"optimize_join_buffer_size"
)
-
1
,
#ifndef DBUG_OFF
sizeof
(
"table_elimination"
)
-
1
,
#endif
...
...
@@ -482,7 +484,8 @@ static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
"mrr_sort_keys=on,"
"join_cache_incremental=on,"
"join_cache_hashed=on,"
"join_cache_bka=on"
"join_cache_bka=on,"
"optimize_join_buffer_size=on"
#ifndef DBUG_OFF
",table_elimination=on"
;
#else
...
...
@@ -7115,7 +7118,7 @@ thread is in the relay logs.",
"The limit of the space for all join buffers used by a query."
,
&
global_system_variables
.
join_buff_space_limit
,
&
max_system_variables
.
join_buff_space_limit
,
0
,
GET_ULL
,
REQUIRED_ARG
,
8
*
128
*
1024L
,
2048
+
MALLOC_OVERHEAD
,
(
longlong
)
ULONGLONG_MAX
,
REQUIRED_ARG
,
16
*
128
*
1024L
,
2048
+
MALLOC_OVERHEAD
,
(
longlong
)
ULONGLONG_MAX
,
MALLOC_OVERHEAD
,
2048
,
0
},
{
"join_cache_level"
,
OPT_JOIN_CACHE_LEVEL
,
"Controls what join operations can be executed with join buffers. Odd numbers are used for plain join buffers while even numbers are used for linked buffers"
,
...
...
sql/sql_join_cache.cc
View file @
38bc3bba
...
...
@@ -747,6 +747,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size()
avg_aux_buffer_incr
=
add_sz
/
min_records
;
min_sz
+=
add_sz
;
min_sz
+=
pack_length_with_blob_ptrs
;
set_if_bigger
(
min_sz
,
1
);
min_buff_size
=
min_sz
;
}
return
min_buff_size
;
...
...
@@ -759,16 +760,20 @@ ulong JOIN_CACHE::get_min_join_buffer_size()
SYNOPSIS
get_max_join_buffer_size()
optimize_buff_size FALSE <-> do not take more memory than needed for
the estimated number of records in the partial join
DESCRIPTION
At the first its invocation for the cache the function calculates the
maximum possible size of join buffer for the cache. This value does not
exceed the estimate of the number of records 'max_records' in the partial
join that joins tables from the first one through join_tab. This value
is also capped off by the value of join_tab->join_buffer_size_limit, if it
has been set a to non-zero value, and by the value of the system parameter
join_buffer_size - otherwise. After the calculation of the interesting size
the function saves the value in the field 'max_buff_size' in order to use
it directly at the next invocations of the function.
maximum possible size of join buffer for the cache. If the parameter
optimize_buff_size true then this value does not exceed the size of the
space needed for the estimated number of records 'max_records' in the
partial join that joins tables from the first one through join_tab. This
value is also capped off by the value of join_tab->join_buffer_size_limit,
if it has been set a to non-zero value, and by the value of the system
parameter join_buffer_size - otherwise. After the calculation of the
interesting size the function saves the value in the field 'max_buff_size'
in order to use it directly at the next invocations of the function.
NOTES
Currently the value of join_tab->join_buffer_size_limit is initialized
...
...
@@ -778,7 +783,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size()
The maximum possible size of the join buffer of this cache
*/
ulong
JOIN_CACHE
::
get_max_join_buffer_size
()
ulong
JOIN_CACHE
::
get_max_join_buffer_size
(
bool
optimize_buff_size
)
{
if
(
!
max_buff_size
)
{
...
...
@@ -795,12 +800,17 @@ ulong JOIN_CACHE::get_max_join_buffer_size()
ulong
limit_sz
=
join
->
thd
->
variables
.
join_buff_size
;
if
(
join_tab
->
join_buffer_size_limit
)
set_if_smaller
(
limit_sz
,
join_tab
->
join_buffer_size_limit
);
if
(
!
optimize_buff_size
)
max_sz
=
limit_sz
;
else
{
if
(
limit_sz
/
max_records
>
space_per_record
)
max_sz
=
space_per_record
*
max_records
;
else
max_sz
=
limit_sz
;
max_sz
+=
pack_length_with_blob_ptrs
;
set_if_smaller
(
max_sz
,
limit_sz
);
}
set_if_bigger
(
max_sz
,
min_sz
);
max_buff_size
=
max_sz
;
}
...
...
@@ -843,6 +853,8 @@ int JOIN_CACHE::alloc_buffer()
ulonglong
curr_min_buff_space_sz
=
0
;
ulonglong
join_buff_space_limit
=
join
->
thd
->
variables
.
join_buff_space_limit
;
bool
optimize_buff_size
=
optimizer_flag
(
join
->
thd
,
OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE
);
double
partial_join_cardinality
=
(
join_tab
-
1
)
->
get_partial_join_cardinality
();
buff
=
NULL
;
min_buff_size
=
0
;
...
...
@@ -852,7 +864,7 @@ int JOIN_CACHE::alloc_buffer()
(
ulonglong
)
partial_join_cardinality
:
join_buff_space_limit
;
set_if_bigger
(
max_records
,
10
);
min_buff_size
=
get_min_join_buffer_size
();
buff_size
=
get_max_join_buffer_size
();
buff_size
=
get_max_join_buffer_size
(
optimize_buff_size
);
for
(
tab
=
join
->
join_tab
+
join
->
const_tables
;
tab
<=
join_tab
;
tab
++
)
{
cache
=
tab
->
cache
;
...
...
@@ -865,8 +877,9 @@ int JOIN_CACHE::alloc_buffer()
if
(
curr_min_buff_space_sz
>
join_buff_space_limit
||
(
curr_buff_space_sz
>
join_buff_space_limit
&&
(
!
optimize_buff_size
||
join
->
shrink_join_buffers
(
join_tab
,
curr_buff_space_sz
,
join_buff_space_limit
)))
join_buff_space_limit
)
)))
goto
fail
;
for
(
ulong
buff_size_decr
=
(
buff_size
-
min_buff_size
)
/
4
+
1
;
;
)
...
...
sql/sql_join_cache.h
View file @
38bc3bba
...
...
@@ -583,7 +583,7 @@ public:
/* Get the minimum possible size of the cache join buffer */
virtual
ulong
get_min_join_buffer_size
();
/* Get the maximum possible size of the cache join buffer */
virtual
ulong
get_max_join_buffer_size
();
virtual
ulong
get_max_join_buffer_size
(
bool
optimize_buff_size
);
/* Shrink the size if the cache join buffer in a given ratio */
bool
shrink_join_buffer_in_ratio
(
ulonglong
n
,
ulonglong
d
);
...
...
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