diff options
author | unknown <kostja@oak.local> | 2003-09-16 04:04:54 +0400 |
---|---|---|
committer | unknown <kostja@oak.local> | 2003-09-16 04:04:54 +0400 |
commit | 4a32d2e1103d038ea14ecf8a51b17ee639b98fe1 (patch) | |
tree | 5d921a5e0dfad0307e8e5a570ba788dae9c0a4fb /sql/sql_select.cc | |
parent | 447f398171e99c14bc6c39f169da435484b8ba9d (diff) | |
download | mariadb-git-4a32d2e1103d038ea14ecf8a51b17ee639b98fe1.tar.gz |
join buffer cache usage/not usage is taken
into account to increase the cost of FULL SCAN
sql/sql_select.cc:
more accurate FULL SCAN cost estimation:
join buffer cache usage/not usage is taken
into account to increase the cost
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3738382928f..bd0c21bb3b0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2133,11 +2133,21 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, s->table->used_keys && best_key) && !(s->table->force_index && best_key)) { // Check full join - /* - Estimate cost of reading table. Note, that we don't read a table - on each iteration as in most cases join buffer is in use. - */ + /* Estimate cost of reading table. */ tmp= (double) s->read_time; + if (s->on_expr) // Can't use join cache + { + /* We have to read the whole table for each record */ + tmp*= record_count; + } + else + { + /* We read the table as many times as join buffer becomes full. */ + tmp*= (1.0 + floor((double) cache_record_length(join,idx) * + record_count / + (double) thd->variables.join_buff_size)); + } + /* In case of full scan we check every row in the table: here we take into account rows read and skipped, as well as rows |