From: drh Date: Thu, 21 Oct 2010 02:05:06 +0000 (+0000) Subject: Fix the query planner so that it uses the multi-index OR-clause solution if X-Git-Tag: version-3.7.4~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75ad260c2d05d881c9a44150737e3ba607936584;p=thirdparty%2Fsqlite.git Fix the query planner so that it uses the multi-index OR-clause solution if that is the lowest cost estimate. A prior bug cause the multi-index solution to be ignored in some circumstances. FossilOrigin-Name: 28ba6255282b1419b8b165e8461018d257b1f6c2 --- diff --git a/manifest b/manifest index 1a93e47329..1453abb12e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Avoid\staking\slocks\son\sunused\sdatabase\sconnections\swhen\scommitting\sa\nread\stransaction. -D 2010-10-14T01:17:30 +C Fix\sthe\squery\splanner\sso\sthat\sit\suses\sthe\smulti-index\sOR-clause\ssolution\sif\nthat\sis\sthe\slowest\scost\sestimate.\s\sA\sprior\sbug\scause\sthe\smulti-index\ssolution\nto\sbe\signored\sin\ssome\scircumstances. +D 2010-10-21T02:05:06 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b01fdfcfecf8a0716c29867a67959f6148b79961 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -240,7 +240,7 @@ F src/vtab.c 6c90e3e65b2f026fc54703a8f3c917155f419d87 F src/wal.c 0dc7eb9e907a2c280cdcde876d313e07ea4ad811 F src/wal.h 96669b645e27cd5a111ba59f0cae7743a207bc3c F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 204cdfb66eb82ee17a8fc0a9b12c1ab402755cbb +F src/where.c 4ca22dea63424d61680021ebdc9248b4f5797666 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 6745008c144bd2956d58864d21f7b304689c1cce @@ -876,14 +876,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ea8c2f5f8a890dcb422e9e46298ae6ca378c74b7 -R 03d2b3a92f9647a3db71aa9ca75489f4 +P c0ee614fd988f445c4884a37f494479bdd669185 +R 6e8c0a60de16e5bdb6a605bd3f1b39aa U drh -Z c2cdb52e62b9c570a5e1c8427f4ce5c4 +Z b859e44913d29246f2a51ec2ec0453b6 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFMtlotoxKgR168RlERAuf0AJ96F+hVDOt4y4GU2wooqTHtO4kKZgCeKIVj -dUPTQwgWJgqAaN5BweGLucY= -=QYIr +iD8DBQFMv5/WoxKgR168RlERAgmkAKCN96esWxQzRMXwPF6yb6e9uTWrlQCfYhIV +wi7V06O0ntyNXUrzsFmI5dw= +=a2Wv -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4e2a5db003..c178568b65 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0ee614fd988f445c4884a37f494479bdd669185 \ No newline at end of file +28ba6255282b1419b8b165e8461018d257b1f6c2 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 226055b472..7b3cfce43d 100644 --- a/src/where.c +++ b/src/where.c @@ -235,7 +235,7 @@ struct WhereCost { #define WHERE_COLUMN_IN 0x00040000 /* x IN (...) */ #define WHERE_COLUMN_NULL 0x00080000 /* x IS NULL */ #define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */ -#define WHERE_NOT_FULLSCAN 0x000f3000 /* Does not do a full table scan */ +#define WHERE_NOT_FULLSCAN 0x100f3000 /* Does not do a full table scan */ #define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */ #define WHERE_TOP_LIMIT 0x00100000 /* xEXPR or x>=EXPR constraint */ @@ -1581,8 +1581,9 @@ static void bestOrClauseIndex( WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm]; /* End of pWC->a[] */ WhereTerm *pTerm; /* A single term of the WHERE clause */ - /* No OR-clause optimization allowed if the NOT INDEXED clause is used */ - if( pSrc->notIndexed ){ + /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses + ** are used */ + if( pSrc->notIndexed || pSrc->pIndex!=0 ){ return; }