1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Ensure that automatic indexes are only created in scenarios where they may be used more than once.

FossilOrigin-Name: 27c65d4d9c58bfc4ea8f9337fa15090459fb26c5
This commit is contained in:
dan
2011-07-02 15:32:57 +00:00
parent 9661c027a4
commit 969e5595e8
4 changed files with 22 additions and 8 deletions

View File

@@ -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

View File

@@ -1 +1 @@
45e581bff7a75db6c9a2c45b73d034d0b8a166d1
27c65d4d9c58bfc4ea8f9337fa15090459fb26c5

View 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;

View 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