From 783dece5d67533c564215c295f66e8dcb3feb006 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 5 Jun 2013 17:53:43 +0000 Subject: [PATCH] Performance improvement for the OR-clause analysis in the NGQP. FossilOrigin-Name: 9b1c4954e468d0acfb5787e6bff56d50a3e7bc1a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 28 ++++++++++++++-------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 454d643033..68794b6938 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\sperformance\stuning\sof\sthe\sNGQP. -D 2013-06-05T16:19:59.536 +C Performance\simprovement\sfor\sthe\sOR-clause\sanalysis\sin\sthe\sNGQP. +D 2013-06-05T17:53:43.355 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -289,7 +289,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 -F src/where.c 7d8a020b2d60ff2b536e6325af18ed11c24f81e5 +F src/where.c 35e510bf0de4925316934e0ae989db9d062069d5 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -1094,7 +1094,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 1c4a78807b7a28c9976ca8c5722ff4e2e8755b7e -R 4c15e208b04c5a33c6528133849a04db +P cbef38c2d123e7d5a02c2a2450e8b329e3e96ee9 +R 0e9737367b7d6db3cdf59c7691a34aed U drh -Z c639596f7b6bcfbd4cf032fe7e7c5fd1 +Z 4606f36521508d3eb4fac531dd74f101 diff --git a/manifest.uuid b/manifest.uuid index 2673f09571..0a8e044566 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbef38c2d123e7d5a02c2a2450e8b329e3e96ee9 \ No newline at end of file +9b1c4954e468d0acfb5787e6bff56d50a3e7bc1a \ No newline at end of file diff --git a/src/where.c b/src/where.c index 4229ddc7ec..342c9ac721 100644 --- a/src/where.c +++ b/src/where.c @@ -4430,17 +4430,6 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){ if( pWC->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK; pWCEnd = pWC->a + pWC->nTerm; pNew = pBuilder->pNew; - pItem = pBuilder->pTabList->a + pNew->iTab; - iCur = pItem->iCursor; - sSubBuild = *pBuilder; - sSubBuild.pOrderBy = 0; - sSubBuild.pBest = &sBest; - tempWC.pParse = pWC->pParse; - tempWC.pMaskSet = pWC->pMaskSet; - tempWC.pOuter = pWC; - tempWC.op = TK_AND; - tempWC.wctrlFlags = 0; - tempWC.nTerm = 1; for(pTerm=pWC->a; pTermeOperator & WO_OR)!=0 @@ -4452,12 +4441,23 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){ double rTotal = 0; double nRow = 0; Bitmask prereq = mExtra; - + + pItem = pBuilder->pTabList->a + pNew->iTab; + iCur = pItem->iCursor; + sSubBuild = *pBuilder; + sSubBuild.pOrderBy = 0; + sSubBuild.pBest = &sBest; for(pOrTerm=pOrWC->a; pOrTermeOperator& WO_AND)!=0 ){ + if( (pOrTerm->eOperator & WO_AND)!=0 ){ sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc; }else if( pOrTerm->leftCursor==iCur ){ + tempWC.pParse = pWC->pParse; + tempWC.pMaskSet = pWC->pMaskSet; + tempWC.pOuter = pWC; + tempWC.op = TK_AND; + tempWC.wctrlFlags = 0; + tempWC.nTerm = 1; tempWC.a = pOrTerm; sSubBuild.pWC = &tempWC; }else{ @@ -4787,7 +4787,7 @@ static const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){ ** error occurs. */ static int wherePathSolver(WhereInfo *pWInfo, double nRowEst){ - int mxChoice = 10; /* Maximum number of simultaneous paths tracked */ + int mxChoice; /* Maximum number of simultaneous paths tracked */ int nLoop; /* Number of terms in the join */ sqlite3 *db; /* The database connection */ int iLoop; /* Loop counter over the terms of the join */ -- 2.47.2