summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2004-07-15 09:08:51 +0300
committerunknown <heikki@hundin.mysql.fi>2004-07-15 09:08:51 +0300
commit9e6f619834527dfa031df16cf494765de3098720 (patch)
tree233122fef912777383bfbfdcfa7e3c3cf833d29b /innobase
parent5eb3dc3223b20f72f799923db541f6fd585aabed (diff)
downloadmariadb-git-9e6f619834527dfa031df16cf494765de3098720.tar.gz
btr0cur.c:
Do not add + 1 to the InnoDB index cardinality estimate if the B-tree just contains one page; the fix made in March 2004 caused InnoDB systematically to overestimate the cardinality of empty or small tables by 1 innobase/btr/btr0cur.c: Do not add + 1 to the InnoDB index cardinality estimate if the B-tree just contains one page; the fix made in March 2004 caused InnoDB systematically to overestimate the cardinality of empty or small tables by 1
Diffstat (limited to 'innobase')
-rw-r--r--innobase/btr/btr0cur.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 8974200efe8..b07b06765e6 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -2707,8 +2707,11 @@ btr_estimate_number_of_different_key_vals(
rec = page_rec_get_next(rec);
}
+
if (n_cols == dict_index_get_n_unique_in_tree(index)) {
- /* We add one because we know that the first record
+
+ /* If there is more than one leaf page in the tree,
+ we add one because we know that the first record
on the page certainly had a different prefix than the
last record on the previous index page in the
alphabetical order. Before this fix, if there was
@@ -2716,7 +2719,11 @@ btr_estimate_number_of_different_key_vals(
algorithm grossly underestimated the number of rows
in the table. */
- n_diff[n_cols]++;
+ if (btr_page_get_prev(page, &mtr) != FIL_NULL
+ || btr_page_get_next(page, &mtr) != FIL_NULL) {
+
+ n_diff[n_cols]++;
+ }
}
total_external_size +=