diff options
author | Georgi Kodinov <joro@sun.com> | 2009-10-07 18:03:42 +0300 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-10-07 18:03:42 +0300 |
commit | 1a48dd4e2bf0c6353bbf76b1f9b768620e0aa090 (patch) | |
tree | e8b98d4a75e63235bc86e6683cdea26c65b05c21 /sql/sql_select.cc | |
parent | 9226c847f5ac5424b50da07623e6e75a60725bc0 (diff) | |
download | mariadb-git-1a48dd4e2bf0c6353bbf76b1f9b768620e0aa090.tar.gz |
Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join
buffering is used
FORCE INDEX FOR ORDER BY now prevents the optimizer from
using join buffering. As a result the optimizer can use
indexed access on the first table and doesn't need to
sort the complete resultset at the end of the statement.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3f1432914a0..9dacb2c2ce4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1231,13 +1231,22 @@ JOIN::optimize() (!group_list && tmp_table_param.sum_func_count)) order=0; - // Can't use sort on head table if using row cache + // Can't use sort on head table if using join buffering if (full_join) { - if (group_list) - simple_group=0; - if (order) - simple_order=0; + TABLE *stable= (sort_by_table == (TABLE *) 1 ? + join_tab[const_tables].table : sort_by_table); + /* + FORCE INDEX FOR ORDER BY can be used to prevent join buffering when + sorting on the first table. + */ + if (!stable || !stable->force_index_order) + { + if (group_list) + simple_group= 0; + if (order) + simple_order= 0; + } } /* |