Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Attempt the constant propagation optimization on any WHERE clause that has a top-level AND operator, even if the query is not a join. This is an attempt to partially address the concern raised in forum post 830d37b928. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e994c9f29f7a561dd5f30573865b0f79 |
User & Date: | drh 2021-05-14 14:26:57 |
Context
2021-05-14
| ||
15:37 | Avoid adding superfluous virtual WHERE clause terms that might arise due to the constant propagation optimization. (check-in: cf63abbe user: drh tags: trunk) | |
14:26 | Attempt the constant propagation optimization on any WHERE clause that has a top-level AND operator, even if the query is not a join. This is an attempt to partially address the concern raised in forum post 830d37b928. (check-in: e994c9f2 user: drh tags: trunk) | |
13:32 | Fix an over-length source code comment in whereexpr.c. No logic changes. (check-in: af5eb902 user: drh tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
4465 4466 4467 4468 4469 4470 4471 | ** Find all terms of COLUMN=VALUE or VALUE=COLUMN in pExpr where VALUE ** is a constant expression and where the term must be true because it ** is part of the AND-connected terms of the expression. For each term ** found, add it to the pConst structure. */ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ Expr *pRight, *pLeft; | | | 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 | ** Find all terms of COLUMN=VALUE or VALUE=COLUMN in pExpr where VALUE ** is a constant expression and where the term must be true because it ** is part of the AND-connected terms of the expression. For each term ** found, add it to the pConst structure. */ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ Expr *pRight, *pLeft; if( NEVER(pExpr==0) ) return; if( ExprHasProperty(pExpr, EP_FromJoin) ) return; if( pExpr->op==TK_AND ){ findConstInWhere(pConst, pExpr->pRight); findConstInWhere(pConst, pExpr->pLeft); return; } if( pExpr->op!=TK_EQ ) return; |
︙ | ︙ | |||
6324 6325 6326 6327 6328 6329 6330 | #endif /* Do the WHERE-clause constant propagation optimization if this is ** a join. No need to speed time on this operation for non-join queries ** as the equivalent optimization will be handled by query planner in ** sqlite3WhereBegin(). */ | | > | 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 | #endif /* Do the WHERE-clause constant propagation optimization if this is ** a join. No need to speed time on this operation for non-join queries ** as the equivalent optimization will be handled by query planner in ** sqlite3WhereBegin(). */ if( p->pWhere!=0 && p->pWhere->op==TK_AND && OptimizationEnabled(db, SQLITE_PropagateConst) && propagateConstants(pParse, p) ){ #if SELECTTRACE_ENABLED if( sqlite3SelectTrace & 0x100 ){ SELECTTRACE(0x100,pParse,p,("After constant propagation:\n")); sqlite3TreeViewSelect(0, p, 0); |
︙ | ︙ |