mariadb/storage
Vasil Dimov 7f62ec7b38 Fix Bug#53761 RANGE estimation for matched rows may be 200 times different
Improve the range estimation algorithm.

Previously:
For a given level the algo knows the number of pages in the requested range and the n

With this change:
Same idea, but peek a few (10) of the intermediate pages to get a better estimate of 

In the bug report one of the examples has a btree with a snippet of the leaf level li
page1(899 records), page2(1 record), page3(1 record), page4(1 record)
so when trying to estimate, the previous algo, assumed there are average (899+1)/2=45
Fix Bug#53761 RANGE estimation for matched rows may be 200 times different

Improve the range estimation algorithm.

Previously:
For a given level the algo knows the number of pages in the requested range
and the number of records on the leftmost and the rightmost page. Then it
assumes all pages in between contain the average between the two border pages
and multiplies this average number by the number of intermediate pages.

With this change:
Same idea, but peek a few (10) of the intermediate pages to get a better
estimate of the average number of records per page. If there are less than 10
intermediate pages then all of them will be scanned and the result will be
precise, not an estimation.

In the bug report one of the examples has a btree with a snippet of the leaf
level like this:
page1(899 records), page2(1 record), page3(1 record), page4(1 record)
so when trying to estimate, the previous algo, assumed there are average
(899+1)/2=450 records per page which went terribly wrong. With this change
page2 and page3 will be read and the exact number of records will be returned.

Approved by:	Sunny (rb://401)
2010-08-16 17:23:29 +03:00
..
archive Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE 2010-07-26 12:54:20 -03:00
blackhole Merge of mysql-trunk-bugfixing into mysql-trunk-merge. 2010-07-15 10:47:50 -03:00
csv WL#5498: Remove dead and unused source code 2010-07-23 17:17:55 -03:00
example Merge of mysql-trunk-bugfixing into mysql-trunk-merge. 2010-07-15 10:47:50 -03:00
federated WL#5498: Remove dead and unused source code 2010-07-23 17:17:55 -03:00
heap WL#5498: Remove dead and unused source code 2010-07-23 17:17:55 -03:00
ibmdb2i Merge of mysql-trunk-bugfixing into mysql-trunk-merge. 2010-07-15 10:47:50 -03:00
innobase Fix Bug#53761 RANGE estimation for matched rows may be 200 times different 2010-08-16 17:23:29 +03:00
myisam Bug#42733: Type-punning warnings when compiling MySQL 2010-07-24 09:24:44 -03:00
myisammrg Add a maintainer target to the warning-mode of the build scripts. 2010-07-24 10:31:48 -03:00
ndb Backport fixes for some of the more noise compiler warnings in ndb. 2010-07-24 09:54:27 -03:00
perfschema WL#5498: Remove dead and unused source code 2010-07-23 17:17:55 -03:00
Makefile.am Another incarnation of the patch for Bug#30708 2010-05-19 17:00:23 +04:00