diff options
author | unknown <sergefp@mysql.com> | 2006-05-10 17:40:20 +0400 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2006-05-10 17:40:20 +0400 |
commit | 3fa6432b09be41ddcc8dae2a8e12eacab5bb95a2 (patch) | |
tree | 0b6b9ad4e8995aa3e5fe6ab195cfbc886695e691 /sql/opt_range.cc | |
parent | 588082712a50ecc4bc213291c6fe74986ec69c38 (diff) | |
download | mariadb-git-3fa6432b09be41ddcc8dae2a8e12eacab5bb95a2.tar.gz |
BUG#17379 Wrong reuse of E(#rows(range)) as E(#rows(ref(const))):
Re-work best_access_path() and find_best() to reuse E(#rows(range access)) as
E(#rows(ref[_or_null](const) access) only when it is appropriate.
[This is the final cumulative patch]
mysql-test/r/select.result:
BUG#17379: Testcase
mysql-test/r/subselect.result:
BUG#17379: Updated test results
mysql-test/t/select.test:
BUG#17379: Testcase
sql/opt_range.cc:
BUG#17379: Wrong reuse of E(#rows(range)) as E(#rows(ref(const))):
Make range optimizer together with TABLE::quick_* also return TABLE::quick_n_ranges
sql/sql_select.cc:
BUG#17379: Wrong reuse of E(#rows(range)) as E(#rows(ref(const))):
Re-work best_access_path() to reuse E(#rows(range access)) as
E(#rows(ref[_or_null](const) access) only when it is appropriate.
sql/table.h:
BUG#17379: Wrong reuse of E(#rows(range)) as E(#rows(ref(const))):
Make range optimizer together with TABLE::quick_* also return TABLE::quick_n_ranges
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 2610e4fc1c8..fb4af4e7932 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -347,8 +347,10 @@ typedef struct st_qsel_param { uint *imerge_cost_buff; /* buffer for index_merge cost estimates */ uint imerge_cost_buff_size; /* size of the buffer */ - /* TRUE if last checked tree->key can be used for ROR-scan */ + /* TRUE if last checked tree->key can be used for ROR-scan */ bool is_ror_scan; + /* Number of ranges in the last checked tree->key */ + uint n_ranges; } PARAM; class TABLE_READ_PLAN; @@ -5297,6 +5299,7 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree) param->table->file->primary_key_is_clustered()); param->is_ror_scan= !cpk_scan; } + param->n_ranges= 0; records=check_quick_keys(param,idx,tree,param->min_key,0,param->max_key,0); if (records != HA_POS_ERROR) @@ -5304,7 +5307,7 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree) param->table->quick_keys.set_bit(key); param->table->quick_rows[key]=records; param->table->quick_key_parts[key]=param->max_key_part+1; - + param->table->quick_n_ranges[key]= param->n_ranges; if (cpk_scan) param->is_ror_scan= TRUE; } @@ -5440,7 +5443,10 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, HA_NOSAME && min_key_length == max_key_length && !memcmp(param->min_key,param->max_key,min_key_length)) + { tmp=1; // Max one record + param->n_ranges++; + } else { if (param->is_ror_scan) @@ -5460,6 +5466,7 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree, is_key_scan_ror(param, keynr, key_tree->part + 1))) param->is_ror_scan= FALSE; } + param->n_ranges++; if (tmp_min_flag & GEOM_FLAG) { |