From: dan Date: Mon, 16 Mar 2015 09:21:30 +0000 (+0000) Subject: Another test case for the planner change on this branch. X-Git-Tag: version-3.8.9~75^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fstat4-change;p=thirdparty%2Fsqlite.git Another test case for the planner change on this branch. FossilOrigin-Name: f2207a0691ed361061719f4dacf021a677a9d892 --- diff --git a/manifest b/manifest index 4946d588ee..3b2c011b8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sestimating\sthe\snumber\sof\srows\svisited\sby\sa\srange\sscan\sfor\swhich\sthe\skeys\sconsist\sof\smore\sthan\sone\sfield,\sconsider\sprefixes\sof\sstat4\ssamples\sas\swell\sas\sthe\sfull\ssamples. -D 2015-03-14T18:59:58.801 +C Another\stest\scase\sfor\sthe\splanner\schange\son\sthis\sbranch. +D 2015-03-16T09:21:30.738 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -327,7 +327,7 @@ F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test f1c552ce39cca4ec922a7e4e0e5d0203d6b3281f F test/analyze7.test bb1409afc9e8629e414387ef048b8e0e3e0bdc4f F test/analyze8.test c05a461d0a6b05991106467d0c47480f2e709c82 -F test/analyze9.test 2f6cfeae1fcc61cc531bd19f68e1e28fb6edafbf +F test/analyze9.test 3dd9e203fad353ec8027b18a6d9a92af59f4e727 F test/analyzeA.test 3335697f6700c7052295cfd0067fc5b2aacddf9a F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d F test/analyzeC.test 555a6cc388b9818b6eda6df816f01ce0a75d3a93 @@ -1244,10 +1244,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 1c2166cb2a387a0856f41b399c3648bf8c5fce73 -R f0473fc546184f7826d3d60610130f49 -T *branch * stat4-change -T *sym-stat4-change * -T -sym-trunk * +P e1caf93c9ad0ee15d42030af95619f212d3fcf9d +R de6873e674f8f1bad7ecb0349d34590a U dan -Z e2a2579617ea31b6dadba1e9a71ba744 +Z 76e12c27217f9a3f485e4cb06238c66e diff --git a/manifest.uuid b/manifest.uuid index 02ad1198b1..e21139d81b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1caf93c9ad0ee15d42030af95619f212d3fcf9d \ No newline at end of file +f2207a0691ed361061719f4dacf021a677a9d892 \ No newline at end of file diff --git a/test/analyze9.test b/test/analyze9.test index 6e85272ad6..1ebd69c8d1 100644 --- a/test/analyze9.test +++ b/test/analyze9.test @@ -1139,7 +1139,7 @@ ifcapable stat4&&cte { # resolved (see below). # reset_db -do_test 26.1 { +do_test 26.1.1 { db transaction { execsql { CREATE TABLE t1(x, y, z); @@ -1163,10 +1163,10 @@ do_test 26.1 { } } {} -do_execsql_test 26.2 { +do_execsql_test 26.1.2 { SELECT count(*) FROM t1 WHERE x = 10000 AND y < 50; } {49} -do_execsql_test 26.3 { +do_execsql_test 26.1.3 { SELECT count(*) FROM t1 WHERE z = 444; } {20} @@ -1185,13 +1185,62 @@ do_execsql_test 26.3 { # At one point though, due to a problem in whereKeyStats(), the planner was # estimating that (x=10000 AND y<50) would match only 2 rows. # -do_eqp_test 26.4 { +do_eqp_test 26.1.4 { SELECT * FROM t1 WHERE x = 10000 AND y < 50 AND z = 444; } { 0 0 0 {SEARCH TABLE t1 USING INDEX t1z (z=?)} } +# This test - 26.2.* - tests that another manifestation of the same problem +# is no longer present in the library. Assuming: +# +# CREATE INDEX t1xy ON t1(x, y) +# +# and that have samples for index t1xy as follows: +# +# +# sample=('A', 70) nEq=(100, 2) nLt=(900, 970) +# sample=('B', 70) nEq=(100, 2) nLt=(1000, 1070) +# +# the planner should estimate that (x = 'B' AND y > 25) matches 76 rows +# (70 * 2/3 + 30). Before, due to the problem, the planner was estimating +# that this matched 100 rows. +# +reset_db +do_execsql_test 26.2.1 { + BEGIN; + CREATE TABLE t1(x, y, z); + CREATE INDEX i1 ON t1(x, y); + CREATE INDEX i2 ON t1(z); + + WITH + cnt(y) AS (SELECT 0 UNION ALL SELECT y+1 FROM cnt WHERE y<99), + letters(x) AS ( + SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D' + ) + INSERT INTO t1(x, y) SELECT x, y FROM letters, cnt; + + WITH + letters(x) AS ( + SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D' + ) + INSERT INTO t1(x, y) SELECT x, 70 FROM letters; + + WITH + cnt(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM cnt WHERE i<9999) + INSERT INTO t1(x, y) SELECT i, i FROM cnt; + + UPDATE t1 SET z = (rowid / 95); + ANALYZE; + COMMIT; +} + +do_eqp_test 26.2.2 { + SELECT * FROM t1 WHERE x='B' AND y>25 AND z=?; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x=? AND y>?)} +} finish_test