summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authorheikki@hundin.mysql.fi <>2002-10-05 22:23:51 +0300
committerheikki@hundin.mysql.fi <>2002-10-05 22:23:51 +0300
commitcc1db6142fcb3a09b6b132d8a7c6a800a2e62c63 (patch)
tree1f65a91a8476086670563c066d7ad49e045cce3d /innobase
parenta9c9856f26c510bf8026f58110d34c5283207bd1 (diff)
downloadmariadb-git-cc1db6142fcb3a09b6b132d8a7c6a800a2e62c63.tar.gz
btr0cur.c:
Do not let range estimator to return over 1 / 2 of total rows in table; use longlong in range estimation btr0cur.h, ha_innobase.cc: Use longlong in range estimation, in case there are > 4 billion rows
Diffstat (limited to 'innobase')
-rw-r--r--innobase/btr/btr0cur.c20
-rw-r--r--innobase/include/btr0cur.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 8abf918366a..6cf3d640aa0 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -2531,7 +2531,7 @@ btr_cur_add_path_info(
/***********************************************************************
Estimates the number of rows in a given index range. */
-ulint
+ib_longlong
btr_estimate_n_rows_in_range(
/*=========================*/
/* out: estimated number of rows */
@@ -2548,7 +2548,7 @@ btr_estimate_n_rows_in_range(
btr_path_t* slot2;
ibool diverged;
ulint divergence_level;
- ulint n_rows;
+ ib_longlong n_rows;
ulint i;
mtr_t mtr;
@@ -2608,6 +2608,22 @@ btr_estimate_n_rows_in_range(
n_rows = n_rows * 2;
}
+
+ /* Do not estimate the number of rows in the range
+ to over 1 / 2 of the estimated rows in the whole
+ table */
+
+ if (n_rows > index->table->stat_n_rows / 2) {
+ n_rows = index->table->stat_n_rows / 2;
+
+ /* If there are just 0 or 1 rows in the table,
+ then we estimate all rows are in the range */
+
+ if (n_rows == 0) {
+ n_rows = index->table->stat_n_rows;
+ }
+ }
+
return(n_rows);
}
diff --git a/innobase/include/btr0cur.h b/innobase/include/btr0cur.h
index b01cbd9a875..7039ceba245 100644
--- a/innobase/include/btr0cur.h
+++ b/innobase/include/btr0cur.h
@@ -417,7 +417,7 @@ btr_cur_parse_del_mark_set_sec_rec(
/***********************************************************************
Estimates the number of rows in a given index range. */
-ulint
+ib_longlong
btr_estimate_n_rows_in_range(
/*=========================*/
/* out: estimated number of rows */