From 42685f211e0ba5610a2702f39a80f950c9d4ae4f Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 28 Apr 2014 19:34:06 +0000 Subject: [PATCH] The trunk assumes that an open range constraint on an indexed term (col>?) term matches 1/4 of the indexed rows, and that a closed constraint (col BETWEEN ? AND ?) matches 1/64. Change this branch to do the same. FossilOrigin-Name: 4047ac75e2a8f0b330255501c42e4f04e5ab500d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 05f3d798c0..b037731f09 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sunordered.test\sto\stake\sinto\saccount\sfor\sthe\sfact\sthat\sSQLite\snow\sprefers\sa\sfull-table\sscan\sover\sa\snon-covering\sindex\sscan\sthat\svisits\sa\slarge\spercentage\sof\sthe\stable\srows. -D 2014-04-28T15:11:25.118 +C The\strunk\sassumes\sthat\san\sopen\srange\sconstraint\son\san\sindexed\sterm\s(col>?)\sterm\smatches\s1/4\sof\sthe\sindexed\srows,\sand\sthat\sa\sclosed\sconstraint\s(col\sBETWEEN\s?\sAND\s?)\smatches\s1/64.\sChange\sthis\sbranch\sto\sdo\sthe\ssame. +D 2014-04-28T19:34:06.281 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -291,7 +291,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 263f8940aa21adabbc397590046f040c54aca5f4 +F src/where.c 0a518940065c10ad8dedf8f2d6e73f1e14eb8472 F src/whereInt.h 6804c2e5010378568c2bb1350477537755296a46 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1162,7 +1162,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 1b95544f84bf83c28cc15f6d0690fdf8a6bb3941 -R 307957877e44688fb3b83b922c0183e6 +P 20f468dfbcb247e51446fad411a6e6cc0d130411 +R eabc843f8d46cb0d3b0b7dd8faf4ef00 U dan -Z 085ae09cb0f2460f340245b5be0529cf +Z 37bdf577e72e4cd110b1edb4853d30e0 diff --git a/manifest.uuid b/manifest.uuid index 8fd0bd92ad..405d43fc27 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -20f468dfbcb247e51446fad411a6e6cc0d130411 \ No newline at end of file +4047ac75e2a8f0b330255501c42e4f04e5ab500d \ No newline at end of file diff --git a/src/where.c b/src/where.c index 4c1d81e183..4b2eef9c52 100644 --- a/src/where.c +++ b/src/where.c @@ -2155,6 +2155,12 @@ static int whereRangeScanEst( assert( pLower || pUpper ); nNew = whereRangeAdjust(pLower, nOut); nNew = whereRangeAdjust(pUpper, nNew); + /* TUNING: If there is both an upper and lower limit, assume the range is + ** reduced by an additional 75%. This means that, by default, an open-ended + ** range query (e.g. col > ?) is assumed to match 1/4 of the rows in the + ** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to + ** match 1/64 of the index. */ + if( pLower && pUpper ) nNew -= 20; nOut -= (pLower!=0) + (pUpper!=0); if( nNew<10 ) nNew = 10; if( nNew