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
d56e74eb
Commit
d56e74eb
authored
Mar 21, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MWL#90: Address review feedback part #2
parent
792c67ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
15 deletions
+24
-15
sql/sql_join_cache.cc
sql/sql_join_cache.cc
+8
-0
sql/sql_select.cc
sql/sql_select.cc
+13
-13
sql/sql_test.cc
sql/sql_test.cc
+3
-2
No files found.
sql/sql_join_cache.cc
View file @
d56e74eb
...
@@ -3235,6 +3235,13 @@ int JOIN_TAB_SCAN::next()
...
@@ -3235,6 +3235,13 @@ int JOIN_TAB_SCAN::next()
}
}
/*
Walk back in join order from join_tab until we encounter a join tab with
tab->cache!=NULL, and save/restore tab->table->status along the way.
@param save TRUE save
FALSE restore
*/
void
save_or_restore_used_tabs
(
JOIN_TAB
*
join_tab
,
bool
save
)
void
save_or_restore_used_tabs
(
JOIN_TAB
*
join_tab
,
bool
save
)
{
{
JOIN_TAB
*
first
=
join_tab
->
bush_root_tab
?
JOIN_TAB
*
first
=
join_tab
->
bush_root_tab
?
...
@@ -3251,6 +3258,7 @@ void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save)
...
@@ -3251,6 +3258,7 @@ void save_or_restore_used_tabs(JOIN_TAB *join_tab, bool save)
{
{
if
(
save
)
if
(
save
)
child
->
table
->
status
=
child
->
status
;
child
->
table
->
status
=
child
->
status
;
else
{
{
tab
->
status
=
tab
->
table
->
status
;
tab
->
status
=
tab
->
table
->
status
;
tab
->
table
->
status
=
0
;
tab
->
table
->
status
=
0
;
...
...
sql/sql_select.cc
View file @
d56e74eb
...
@@ -1039,6 +1039,7 @@ JOIN::optimize()
...
@@ -1039,6 +1039,7 @@ JOIN::optimize()
{
{
List_iterator
<
JOIN_TAB_RANGE
>
it
(
join_tab_ranges
);
List_iterator
<
JOIN_TAB_RANGE
>
it
(
join_tab_ranges
);
JOIN_TAB_RANGE
*
jt_range
;
JOIN_TAB_RANGE
*
jt_range
;
/* For upper level JOIN_TABs, we need to skip the const tables: */
uint
first_tab_offs
=
const_tables
;
uint
first_tab_offs
=
const_tables
;
while
((
jt_range
=
it
++
))
while
((
jt_range
=
it
++
))
{
{
...
@@ -1053,6 +1054,11 @@ JOIN::optimize()
...
@@ -1053,6 +1054,11 @@ JOIN::optimize()
(
*
tab
->
on_expr_ref
)
->
update_used_tables
();
(
*
tab
->
on_expr_ref
)
->
update_used_tables
();
}
}
}
}
/*
Next jt_range will refer to SJM nest (and not the top-level range).
Inside SJM nests, we dont have const tables, so should start from the
first table:
*/
first_tab_offs
=
0
;
first_tab_offs
=
0
;
}
}
}
}
...
@@ -2865,13 +2871,10 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
...
@@ -2865,13 +2871,10 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
table
->
reginfo
.
join_tab
=
s
;
table
->
reginfo
.
join_tab
=
s
;
table
->
reginfo
.
not_exists_optimize
=
0
;
table
->
reginfo
.
not_exists_optimize
=
0
;
bzero
((
char
*
)
table
->
const_key_parts
,
sizeof
(
key_part_map
)
*
table
->
s
->
keys
);
bzero
((
char
*
)
table
->
const_key_parts
,
sizeof
(
key_part_map
)
*
table
->
s
->
keys
);
all_table_map
|=
s
->
table
->
map
;
all_table_map
|=
table
->
map
;
s
->
join
=
join
;
s
->
join
=
join
;
s
->
info
=
0
;
// For describe
s
->
bush_root_tab
=
NULL
;
s
->
dependent
=
tables
->
dep_tables
;
s
->
dependent
=
tables
->
dep_tables
;
s
->
key_dependent
=
0
;
if
(
tables
->
schema_table
)
if
(
tables
->
schema_table
)
table
->
file
->
stats
.
records
=
2
;
table
->
file
->
stats
.
records
=
2
;
table
->
quick_condition_rows
=
table
->
file
->
stats
.
records
;
table
->
quick_condition_rows
=
table
->
file
->
stats
.
records
;
...
@@ -6395,7 +6398,7 @@ JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables)
...
@@ -6395,7 +6398,7 @@ JOIN_TAB *first_linear_tab(JOIN *join, bool after_const_tables)
first
+=
join
->
const_tables
;
first
+=
join
->
const_tables
;
if
(
first
<
join
->
join_tab
+
join
->
top_jtrange_tables
)
if
(
first
<
join
->
join_tab
+
join
->
top_jtrange_tables
)
return
first
;
return
first
;
return
NULL
;
return
NULL
;
/* All tables were const tables */
}
}
...
@@ -6471,8 +6474,11 @@ JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab)
...
@@ -6471,8 +6474,11 @@ JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab)
/* Move to next tab in the array we're traversing*/
/* Move to next tab in the array we're traversing*/
if
(
!
start
)
if
(
!
start
)
tab
++
;
tab
++
;
if
(
tab
==
join
->
join_tab_ranges
.
head
()
->
end
)
//psergey-remove: check:
DBUG_ASSERT
(
join
->
join_tab_ranges
.
head
()
->
end
==
join
->
join_tab
+
join
->
top_jtrange_tables
);
if
(
tab
==
join
->
join_tab
+
join
->
top_jtrange_tables
)
return
NULL
;
/* End */
return
NULL
;
/* End */
if
(
tab
->
bush_children
)
if
(
tab
->
bush_children
)
...
@@ -6580,17 +6586,13 @@ get_best_combination(JOIN *join)
...
@@ -6580,17 +6586,13 @@ get_best_combination(JOIN *join)
JOIN_TAB_RANGE
*
jt_range
=
new
JOIN_TAB_RANGE
;
JOIN_TAB_RANGE
*
jt_range
=
new
JOIN_TAB_RANGE
;
jt_range
->
start
=
jt
;
jt_range
->
start
=
jt
;
jt_range
->
end
=
jt
+
sjm
->
tables
;
jt_range
->
end
=
jt
+
sjm
->
tables
;
//sjm->jt_range= jt_range;
join
->
join_tab_ranges
.
push_back
(
jt_range
);
join
->
join_tab_ranges
.
push_back
(
jt_range
);
j
->
bush_children
=
jt_range
;
j
->
bush_children
=
jt_range
;
j
->
bush_root_tab
=
NULL
;
//note: a lot of code depends on bush nodes not containing one another
j
->
quick
=
NULL
;
sjm_nest_end
=
jt
+
sjm
->
tables
;
sjm_nest_end
=
jt
+
sjm
->
tables
;
sjm_saved_tab
=
j
;
sjm_saved_tab
=
j
;
root_range
->
end
=
j
+
1
;
root_range
->
end
=
j
+
1
;
j
=
jt
;
j
=
jt
;
//goto loop_end_not_table;
}
}
*
j
=
*
join
->
best_positions
[
tablenr
].
table
;
*
j
=
*
join
->
best_positions
[
tablenr
].
table
;
...
@@ -8546,12 +8548,10 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
...
@@ -8546,12 +8548,10 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
check_join_cache_usage_for_tables
(
join
,
options
,
no_jbuf_after
);
check_join_cache_usage_for_tables
(
join
,
options
,
no_jbuf_after
);
//for (i=join->const_tables ; i < join->tables ; i++)
for
(
tab
=
first_linear_tab
(
join
,
TRUE
),
i
=
join
->
const_tables
;
for
(
tab
=
first_linear_tab
(
join
,
TRUE
),
i
=
join
->
const_tables
;
tab
;
tab
;
tab
=
next_linear_tab
(
join
,
tab
,
TRUE
),
i
++
)
tab
=
next_linear_tab
(
join
,
tab
,
TRUE
),
i
++
)
{
{
//JOIN_TAB *tab=join->join_tab+i;
if
(
tab
->
bush_children
)
if
(
tab
->
bush_children
)
{
{
if
(
setup_sj_materialization
(
tab
))
if
(
setup_sj_materialization
(
tab
))
...
...
sql/sql_test.cc
View file @
d56e74eb
...
@@ -182,7 +182,8 @@ TEST_join(JOIN *join)
...
@@ -182,7 +182,8 @@ TEST_join(JOIN *join)
in order not to garble the tabular output below.
in order not to garble the tabular output below.
*/
*/
String
ref_key_parts
[
MAX_TABLES
];
String
ref_key_parts
[
MAX_TABLES
];
for
(
i
=
0
;
i
<
(
jt_range
->
end
-
jt_range
->
start
);
i
++
)
int
tables_in_range
=
jt_range
->
end
-
jt_range
->
start
;
for
(
i
=
0
;
i
<
tables_in_range
;
i
++
)
{
{
JOIN_TAB
*
tab
=
jt_range
->
start
+
i
;
JOIN_TAB
*
tab
=
jt_range
->
start
+
i
;
for
(
ref
=
0
;
ref
<
tab
->
ref
.
key_parts
;
ref
++
)
for
(
ref
=
0
;
ref
<
tab
->
ref
.
key_parts
;
ref
++
)
...
@@ -192,7 +193,7 @@ TEST_join(JOIN *join)
...
@@ -192,7 +193,7 @@ TEST_join(JOIN *join)
}
}
}
}
for
(
i
=
0
;
i
<
(
jt_range
->
end
-
jt_range
->
start
)
;
i
++
)
for
(
i
=
0
;
i
<
tables_in_range
;
i
++
)
{
{
JOIN_TAB
*
tab
=
jt_range
->
start
+
i
;
JOIN_TAB
*
tab
=
jt_range
->
start
+
i
;
TABLE
*
form
=
tab
->
table
;
TABLE
*
form
=
tab
->
table
;
...
...
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