]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Ensure that automatic indexes are only created in scenarios where they may be used...
authordan <dan@noemail.net>
Sat, 2 Jul 2011 15:32:57 +0000 (15:32 +0000)
committerdan <dan@noemail.net>
Sat, 2 Jul 2011 15:32:57 +0000 (15:32 +0000)
FossilOrigin-Name: 27c65d4d9c58bfc4ea8f9337fa15090459fb26c5

manifest
manifest.uuid
src/where.c
test/autoindex1.test

index ea458a6adad7e6ff29a7293b3fb567a4fc271fd7..b933d5723eda69be5d735a78e89505564844880f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\sexperimental\schanges\simproving\soptimization\sof\sDISTINCT\squeries\swith\sthe\strunk.
-D 2011-07-02T09:46:52.496
+C Ensure\sthat\sautomatic\sindexes\sare\sonly\screated\sin\sscenarios\swhere\sthey\smay\sbe\sused\smore\sthan\sonce.
+D 2011-07-02T15:32:57.635
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -250,7 +250,7 @@ F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582
 F src/wal.c 0c70ad7b1cac6005fa5e2cbefd23ee05e391c290
 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
-F src/where.c dcc0d91cc4b843adf79476b721c10ca6f382cb85
+F src/where.c 30dc117ecd9406b7e442426cb5368199035c27ff
 F test/8_3_names.test b93687beebd17f6ebf812405a6833bae5d1f4199
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
@@ -281,7 +281,7 @@ F test/auth.test b047105c32da7db70b842fd24056723125ecc2ff
 F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882
 F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5
 F test/autoinc.test 85ef3180a737e6580086a018c09c6f1a52759b46
-F test/autoindex1.test 860fc83f4fefb0c68ad062afc3ff43faa1534fc4
+F test/autoindex1.test 058d0b331ae6840a61bbee910d8cbae27bfd5991
 F test/autovacuum.test bb7c0885e6f8f1d633045de48f2b66082162766d
 F test/autovacuum_ioerr2.test 598b0663074d3673a9c1bc9a16e80971313bafe6
 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85
@@ -950,7 +950,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00
 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262
-P 953e169e8a7dac05a0b56b4ef5d500ec8399d37f 090b29177fbc9faa83b560d92ddc3710d291776e
-R a0416d3328a66ac3932394627191f7dc
+P 45e581bff7a75db6c9a2c45b73d034d0b8a166d1
+R 6e4dc8fc887e24292adb3ae0b641a038
 U dan
-Z a35e180a4755a506b249eeb5b9af1ec2
+Z d167de182be16055ea09a1a9326ef0ca
index e8854363145081a819b5840cc45102c2fc57dfdd..670b072715f4d91ec73e5c9173d2d5c63b29cb42 100644 (file)
@@ -1 +1 @@
-45e581bff7a75db6c9a2c45b73d034d0b8a166d1
\ No newline at end of file
+27c65d4d9c58bfc4ea8f9337fa15090459fb26c5
\ No newline at end of file
index 61361bd95dd7ba9a872d976a1f2d5e41c6d1be3d..f843e107400c4fd93c10de792bc75cc120d5dc33 100644 (file)
@@ -1902,6 +1902,10 @@ static void bestAutomaticIndex(
   WhereTerm *pWCEnd;          /* End of pWC->a[] */
   Table *pTable;              /* Table tht might be indexed */
 
+  if( pParse->nQueryLoop<=(double)1 ){
+    /* There is no point in building an automatic index for a single scan */
+    return;
+  }
   if( (pParse->db->flags & SQLITE_AutoIndex)==0 ){
     /* Automatic indices are disabled at run-time */
     return;
index bc628dc256c5b47548432df8d47288a504fe81c6..6c8d54d12523de484ffce3b24bbbd741c0c0dae4 100644 (file)
@@ -248,4 +248,14 @@ do_execsql_test autoindex1-600 {
   0 1 1 {SEARCH SUBQUERY 1 AS y USING AUTOMATIC COVERING INDEX (sheep_no=?) (~8 rows)}
 }
 
+
+do_execsql_test autoindex1-700 {
+  CREATE TABLE t5(a, b, c);
+  EXPLAIN QUERY PLAN SELECT a FROM t5 WHERE b=10 ORDER BY c;
+} {
+  0 0 0 {SCAN TABLE t5 (~100000 rows)} 
+  0 0 0 {USE TEMP B-TREE FOR ORDER BY}
+}
+
+
 finish_test