summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2016-04-28 16:59:33 +0300
committerMonty <monty@mariadb.org>2016-04-28 16:59:33 +0300
commit9c846373f02d6431d83add639e7560a69ba885a2 (patch)
tree101d110d3ec9a4796b4050779fb052120fd6d516 /sql/opt_range.cc
parentfabeab781920dfcaf8e606708ba2c6812f6ae5d8 (diff)
parentd5822a3ad0657040114cdc185c6387b9eb3a12b2 (diff)
downloadmariadb-git-9c846373f02d6431d83add639e7560a69ba885a2.tar.gz
Merge commit 'd5822a3ad0657040114cdc185c6387b9eb3a12b2' into 10.2
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index af027ad6fdc..a69709bbf03 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -13105,7 +13105,17 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
num_blocks= (ha_rows)(table_records / keys_per_block) + 1;
/* Compute the number of keys in a group. */
- keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - 1);
+ if (!group_key_parts)
+ {
+ /* Summary over the whole table */
+ keys_per_group= table_records;
+ }
+ else
+ {
+ keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts -
+ 1);
+ }
+
if (keys_per_group == 0) /* If there is no statistics try to guess */
/* each group contains 10% of all records */
keys_per_group= (table_records / 10) + 1;