mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
Merge heikki@work.mysql.com:/home/my/mysql
into donna.mysql.fi:/home/heikki/mysqln
This commit is contained in:
commit
4f3e7f68f5
2 changed files with 19 additions and 17 deletions
|
@ -2552,6 +2552,7 @@ btr_estimate_number_of_different_key_vals(
|
|||
ulint total_external_size = 0;
|
||||
ulint i;
|
||||
ulint j;
|
||||
ulint add_on;
|
||||
mtr_t mtr;
|
||||
|
||||
n_cols = dict_index_get_n_unique(index);
|
||||
|
@ -2624,8 +2625,25 @@ btr_estimate_number_of_different_key_vals(
|
|||
+ not_empty_flag)
|
||||
/ (BTR_KEY_VAL_ESTIMATE_N_PAGES
|
||||
+ total_external_size);
|
||||
}
|
||||
|
||||
/* If the tree is small, smaller than <
|
||||
10 * BTR_KEY_VAL_ESTIMATE_N_PAGES + total_external_size, then
|
||||
the above estimate is ok. For bigger trees it is common that we
|
||||
do not see any borders between key values in the few pages
|
||||
we pick. But still there may be BTR_KEY_VAL_ESTIMATE_N_PAGES
|
||||
different key values, or even more. Let us try to approximate
|
||||
that: */
|
||||
|
||||
add_on = index->stat_n_leaf_pages /
|
||||
(10 * (BTR_KEY_VAL_ESTIMATE_N_PAGES + total_external_size));
|
||||
|
||||
if (add_on > BTR_KEY_VAL_ESTIMATE_N_PAGES) {
|
||||
add_on = BTR_KEY_VAL_ESTIMATE_N_PAGES;
|
||||
}
|
||||
|
||||
index->stat_n_diff_key_vals[j] += add_on;
|
||||
}
|
||||
|
||||
mem_free(n_diff);
|
||||
}
|
||||
|
||||
|
|
|
@ -3130,22 +3130,6 @@ ha_innobase::info(
|
|||
rec_per_key = 1;
|
||||
}
|
||||
|
||||
/* Since the MySQL optimizer is often too
|
||||
pessimistic in the assumption that a table
|
||||
does not fit in the buffer pool, we
|
||||
increase the attractiveness of indexes
|
||||
by assuming the selectivity of any prefix
|
||||
of an index is 1 / 100 or better.
|
||||
(Actually, we should look at the table
|
||||
size, and if the table is smaller than
|
||||
the buffer pool, we should uniformly
|
||||
increase the attractiveness of indexes,
|
||||
regardless of the estimated selectivity.) */
|
||||
|
||||
if (rec_per_key > records / 100) {
|
||||
rec_per_key = records / 100;
|
||||
}
|
||||
|
||||
table->key_info[i].rec_per_key[j]
|
||||
= rec_per_key;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue