1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Use compile-time options SQLITE_QUERY_PLANNER_LIMIT and

SQLITE_QUERY_PLANNER_LIMIT_INCR to control the value for
WhereLoopBuilder.iPlanLimit, rather than embedding magic numbers in the
code.

FossilOrigin-Name: 903e501894b2a5dd7055b5154d74d4a47a619f76e66485a4d62b6259f10723d6
This commit is contained in:
drh
2018-09-24 12:37:01 +00:00
parent 7ebb605c0a
commit 6fb5d358a8
4 changed files with 30 additions and 16 deletions

View File

@@ -3540,17 +3540,11 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
/* Loop over the tables in the join, from left to right */
pNew = pBuilder->pNew;
whereLoopInit(pNew);
/* Some pathological queries provide an unreasonable number of indexing
** options. The iPlanLimit value prevents these queries from taking up
** too much time in the planner. When iPlanLimit reaches zero, no further
** index+constraint options are considered. Seed iPlanLimit to 20K but
** also add an extra 1K to each table of the join, to ensure that each
** table at least gets 1K opportunities. */
pBuilder->iPlanLimit = 20000;
pBuilder->iPlanLimit = SQLITE_QUERY_PLANNER_LIMIT;
for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){
Bitmask mUnusable = 0;
pNew->iTab = iTab;
pBuilder->iPlanLimit += 1000; /* 1000 bonus for each table in the join */
pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;
pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);
if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){
/* This condition is true when pItem is the FROM clause term on the