summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2002-10-05 22:23:51 +0300
committerunknown <heikki@hundin.mysql.fi>2002-10-05 22:23:51 +0300
commit25b2d47517dbf04d5898c4b08bb88f2d3cb98839 (patch)
tree1f65a91a8476086670563c066d7ad49e045cce3d /innobase
parentbbbbe68dbb12e2b1ff6513eeed168af885552dd1 (diff)
downloadmariadb-git-25b2d47517dbf04d5898c4b08bb88f2d3cb98839.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 sql/ha_innobase.cc: Use longlong in range estimation, in case there are > 4 billion rows innobase/include/btr0cur.h: Use longlong in range estimation, in case there are > 4 billion rows innobase/btr/btr0cur.c: Do not let range estimator to return over 1 / 2 of total rows in table; use longlong in range estimation
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 */