From ffdcd9ff55f18d1acb725974e0ed3568e4e1fe1c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 17 Jun 2014 15:13:04 +0000 Subject: [PATCH] Small tweaks to the query planner to get it to try harder to use an index for sorting and to avoid using automatic indexes on constant terms. FossilOrigin-Name: 2d9de154f8f398d66693a4bc35eef1353ae61728 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/where.c | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8b72fa3c7f..b1885fd82f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.8.3.1 -D 2014-02-11T14:52:19.939 +C Small\stweaks\sto\sthe\squery\splanner\sto\sget\sit\sto\stry\sharder\sto\suse\san\sindex\nfor\ssorting\sand\sto\savoid\susing\sautomatic\sindexes\son\sconstant\sterms. +D 2014-06-17T15:13:04.717 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -293,7 +293,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 540f52385a653d7cc077e381875ec02bf4c80053 +F src/where.c 9ec7ce024a5963a3c0b3f3234fbef5de53f08f54 F src/whereInt.h 96a75c61f1d2b9d4a8e4bb17d89deb0cf7cba358 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1153,10 +1153,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 3111df71b2a6bef08cf37c6e350f5accc506f9eb -R bed1bf07eba8673ccef2bc493f925e43 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.8.3.1 * +P ea3317a4803d71d88183b29f1d3086f46d68a00e +R f3e3efe64172b5c947d66b04e17d9c81 U drh -Z ae0c2dc014fac62d82a18ce766a4d589 +Z ab6ad47f6438e43e215e120c654c4cf3 diff --git a/manifest.uuid b/manifest.uuid index cfdba17d01..0a416ca410 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ea3317a4803d71d88183b29f1d3086f46d68a00e \ No newline at end of file +2d9de154f8f398d66693a4bc35eef1353ae61728 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 67ef577e9b..704890ca3f 100644 --- a/src/where.c +++ b/src/where.c @@ -4213,6 +4213,7 @@ static int whereLoopAddBtree( WhereTerm *pWCEnd = pWC->a + pWC->nTerm; for(pTerm=pWC->a; rc==SQLITE_OK && pTermprereqRight & pNew->maskSelf ) continue; + if( sqlite3ExprIsConstant(pTerm->pExpr->pRight) ) continue; if( termCanDriveIndex(pTerm, pSrc, 0) ){ pNew->u.btree.nEq = 1; pNew->u.btree.nSkip = 0; @@ -4972,7 +4973,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** number of output rows. The 48 is the expected size of a row to sort. ** FIXME: compute a better estimate of the 48 multiplier based on the ** result set expressions. */ - rSortCost = nRowEst + estLog(nRowEst); + rSortCost = nRowEst + estLog(nRowEst) + 10; WHERETRACE(0x002,("---- sort cost=%-3d\n", rSortCost)); } -- 2.39.5