1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-19 21:43:15 +03:00

Performance improvements for whereScan methods.

FossilOrigin-Name: aae14350a37ad50e4607953ab496cba006032873
This commit is contained in:
drh
2013-06-10 12:34:45 +00:00
parent cb0071429f
commit 43b85ef5c6
3 changed files with 12 additions and 15 deletions

View File

@@ -231,7 +231,6 @@ struct WhereTerm {
** terms in the WHERE clause that are useful to the query planner.
*/
struct WhereScan {
WhereTerm *pCurrent; /* Most recent match */
WhereClause *pOrigWC; /* Original, innermost WhereClause */
WhereClause *pWC; /* WhereClause currently being scanned */
char *zCollName; /* Required collating sequence, if not NULL */
@@ -779,12 +778,13 @@ WhereTerm *whereScanNext(WhereScan *pScan){
Expr *pX; /* An expression being tested */
WhereClause *pWC; /* Shorthand for pScan->pWC */
WhereTerm *pTerm; /* The term being tested */
int k = pScan->k; /* Where to start scanning */
while( pScan->iEquiv<=pScan->nEquiv ){
iCur = pScan->aEquiv[pScan->iEquiv-2];
iColumn = pScan->aEquiv[pScan->iEquiv-1];
while( (pWC = pScan->pWC)!=0 ){
for(pTerm=pWC->a+pScan->k; pScan->k<pWC->nTerm; pScan->k++, pTerm++){
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
if( pTerm->leftCursor==iCur && pTerm->u.leftColumn==iColumn ){
if( (pTerm->eOperator & WO_EQUIV)!=0
&& pScan->nEquiv<ArraySize(pScan->aEquiv)
@@ -828,20 +828,18 @@ WhereTerm *whereScanNext(WhereScan *pScan){
){
continue;
}
pScan->pCurrent = pTerm;
pScan->k++;
pScan->k = k+1;
return pTerm;
}
}
}
pWC = pScan->pWC = pScan->pWC->pOuter;
pScan->k = 0;
k = 0;
}
pScan->pWC = pScan->pOrigWC;
pScan->k = 0;
k = 0;
pScan->iEquiv += 2;
}
pScan->pCurrent = 0;
return 0;
}
@@ -867,7 +865,6 @@ WhereTerm *whereScanInit(
int j;
/* memset(pScan, 0, sizeof(*pScan)); */
pScan->pCurrent = 0;
pScan->pOrigWC = pWC;
pScan->pWC = pWC;
if( pIdx && iColumn>=0 ){