From 09e1df6c009bc90558ec0250f005bb59fe8f808e Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 29 Apr 2014 16:10:22 +0000 Subject: [PATCH] Ignore likelihood() values on indexed IPK lookups. FossilOrigin-Name: 5bb7757a7b32a74482d3e93e9c9eea02273fe981 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 2 +- test/cost.test | 36 ++++++++++++++++++++++-------------- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index a7e8fbdb50..cf16f91a6e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sso\sthat\sit\supdates\ssqlite_stat1\sconsistently. -D 2014-04-29T12:01:35.119 +C Ignore\slikelihood()\svalues\son\sindexed\sIPK\slookups. +D 2014-04-29T16:10:22.104 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 da9c2c1d0c2ecf51ea3b7a27c826999972f24086 +F src/where.c 397bd5d4f402238c396d73b3c98b9fa2c312eea4 F src/whereInt.h 6804c2e5010378568c2bb1350477537755296a46 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -406,7 +406,7 @@ F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 F test/corruptG.test 1ab3bf97ee7bdba70e0ff3ba2320657df55d1804 F test/corruptH.test 88ed71a086e13591c917aac6de32750e7c7281cb F test/corruptI.test b3e4203d420490fc3d3062711597bc1dea06a789 -F test/cost.test 84473f27749e0f3b6837a8e1403967010c347ca5 +F test/cost.test 62386ccac862ea9a808a0954037f430690974b0f F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f @@ -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 a8ae93f0cffa116df0ba34d46a53f49d42dace41 -R 176e01464114f39a9f52a0420836d3f7 +P 2dc5a0b55567f13f0528ed17242e680cde2f2a29 +R b5feca3cdcf90dbcdc4d81625fcb13e8 U dan -Z 9c22069b17d97b138b62636ee980813e +Z d7294cbb283905147264033ecb5a94d9 diff --git a/manifest.uuid b/manifest.uuid index 5debc1c5f8..0097b17163 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2dc5a0b55567f13f0528ed17242e680cde2f2a29 \ No newline at end of file +5bb7757a7b32a74482d3e93e9c9eea02273fe981 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 8abe6bd1a1..566c907e55 100644 --- a/src/where.c +++ b/src/where.c @@ -4189,7 +4189,7 @@ static int whereLoopAddBtreeIndex( assert( eOp & (WO_ISNULL|WO_EQ|WO_IN) ); assert( pNew->nOut==saved_nOut ); - if( pTerm->truthProb<=0 ){ + if( pTerm->truthProb<=0 && iCol>=0 ){ assert( (eOp & WO_IN) || nIn==0 ); pNew->nOut += pTerm->truthProb; pNew->nOut -= nIn; diff --git a/test/cost.test b/test/cost.test index 0f9314fc8e..979815f9f7 100644 --- a/test/cost.test +++ b/test/cost.test @@ -66,10 +66,10 @@ do_eqp_test 3.2 { #------------------------------------------------------------------------- # If there is no likelihood() or stat3 data, SQLite assumes that a closed # range scan (e.g. one constrained by "col BETWEEN ? AND ?" constraint) -# visits 1/16 of the rows in a table. +# visits 1/64 of the rows in a table. # -# Note: 1/17 =~ 0.058 -# Note: 1/15 =~ 0.067 +# Note: 1/63 =~ 0.016 +# Note: 1/65 =~ 0.015 # reset_db do_execsql_test 4.1 { @@ -78,12 +78,12 @@ do_execsql_test 4.1 { CREATE INDEX i2 ON t1(b); } do_eqp_test 4.2 { - SELECT * FROM t1 WHERE likelihood(a=?, 0.058) AND b BETWEEN ? AND ?; + SELECT * FROM t1 WHERE likelihood(a=?, 0.014) AND b BETWEEN ? AND ?; } { 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)} } do_eqp_test 4.3 { - SELECT * FROM t1 WHERE likelihood(a=?, 0.067) AND b BETWEEN ? AND ?; + SELECT * FROM t1 WHERE likelihood(a=?, 0.016) AND b BETWEEN ? AND ?; } { 0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b>? AND b? AND x? AND b=950 AND b<=1010) OR (b IS NULL AND c NOT NULL) ORDER BY a } { + 0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b