mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
bug #27531: 5.1 part of the fix:
- added join cache indication in EXPLAIN (Extra column). - prefer filesort over full scan over index for ORDER BY (because it's faster). - when switching from REF to RANGE because RANGE uses longer key turn off sort on the head table only as the resulting RANGE access is a candidate for join cache and we don't want to disable it by sorting on the first table only. mysql-test/r/archive_gis.result: bug #27531: join cache in EXPLAIN mysql-test/r/compress.result: bug #27531: - join cache in EXPLAIN. - prefer filesort over full scan over index for ORDER BY. mysql-test/r/ctype_utf8.result: bug #27531: join cache in EXPLAIN mysql-test/r/derived.result: bug #27531: join cache in EXPLAIN mysql-test/r/distinct.result: bug #27531: join cache in EXPLAIN mysql-test/r/func_group.result: bug #27531: join cache in EXPLAIN mysql-test/r/func_group_innodb.result: bug #27531: join cache in EXPLAIN mysql-test/r/gis.result: bug #27531: join cache in EXPLAIN mysql-test/r/greedy_optimizer.result: bug #27531: join cache in EXPLAIN mysql-test/r/group_by.result: bug #27531: join cache in EXPLAIN mysql-test/r/group_min_max.result: bug #27531: join cache in EXPLAIN mysql-test/r/index_merge_myisam.result: bug #27531: join cache in EXPLAIN mysql-test/r/information_schema.result: bug #27531: join cache in EXPLAIN mysql-test/r/innodb_gis.result: bug #27531: join cache in EXPLAIN mysql-test/r/innodb_mysql.result: bug #27531: join cache in EXPLAIN mysql-test/r/join.result: bug #27531: join cache in EXPLAIN mysql-test/r/join_nested.result: bug #27531: join cache in EXPLAIN mysql-test/r/key_diff.result: bug #27531: join cache in EXPLAIN mysql-test/r/myisam.result: bug #27531: join cache in EXPLAIN mysql-test/r/ndb_condition_pushdown.result: bug #27531: join cache in EXPLAIN mysql-test/r/ndb_gis.result: bug #27531: join cache in EXPLAIN mysql-test/r/range.result: bug #27531: join cache in EXPLAIN mysql-test/r/row.result: bug #27531: join cache in EXPLAIN mysql-test/r/select.result: bug #27531: - join cache in EXPLAIN. - prefer filesort over full scan over index for ORDER BY. mysql-test/r/ssl.result: bug #27531: - join cache in EXPLAIN. - prefer filesort over full scan over index for ORDER BY. mysql-test/r/ssl_compress.result: bug #27531: - join cache in EXPLAIN. - prefer filesort over full scan over index for ORDER BY. mysql-test/r/subselect.result: bug #27531: join cache in EXPLAIN mysql-test/r/subselect3.result: bug #27531: join cache in EXPLAIN mysql-test/r/union.result: bug #27531: join cache in EXPLAIN mysql-test/r/view.result: bug #27531: join cache in EXPLAIN sql/sql_select.cc: bug #27531: - join cache in EXPLAIN. - prefer filesort over full scan over index for ORDER BY. - disable sorting on the first table only when switching from REF to RANGE.
This commit is contained in:
@ -5893,6 +5893,12 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
||||
tab->ref.key= -1;
|
||||
tab->ref.key_parts=0; // Don't use ref key.
|
||||
join->best_positions[i].records_read= rows2double(tab->quick->records);
|
||||
/*
|
||||
We will use join cache here : prevent sorting of the first
|
||||
table only and sort at the end.
|
||||
*/
|
||||
if (i != join->const_tables && join->tables > join->const_tables + 1)
|
||||
join->full_join= 1;
|
||||
}
|
||||
|
||||
tmp= NULL;
|
||||
@ -12660,6 +12666,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
||||
uint nr;
|
||||
key_map keys;
|
||||
|
||||
/*
|
||||
filesort() and join cache are usually faster than reading in
|
||||
index order and not using join cache
|
||||
*/
|
||||
if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1)
|
||||
DBUG_RETURN(0);
|
||||
/*
|
||||
If not used with LIMIT, only use keys if the whole query can be
|
||||
resolved with a key; This is because filesort() is usually faster than
|
||||
@ -15513,6 +15525,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tab->next_select == sub_select_cache)
|
||||
extra.append(STRING_WITH_LEN("; Using join cache"));
|
||||
|
||||
/* Skip initial "; "*/
|
||||
const char *str= extra.ptr();
|
||||
|
Reference in New Issue
Block a user