diff options
author | drh <> | 2025-01-25 14:30:36 +0000 |
---|---|---|
committer | drh <> | 2025-01-25 14:30:36 +0000 |
commit | 0186ee1cd742a78f8b98fd1ec7e197aaf8f1c2f8 (patch) | |
tree | e62d5743750d958894a18b16bfa1b11b88e941dc /src | |
parent | dea434ea6513a3f91bf15ce4106db0c54a9d6161 (diff) | |
download | sqlite-0186ee1cd742a78f8b98fd1ec7e197aaf8f1c2f8.tar.gz sqlite-0186ee1cd742a78f8b98fd1ec7e197aaf8f1c2f8.zip |
Improvments to debug output on the star-query heuristic.
FossilOrigin-Name: b3ebeb0682a2c837987acf4ed92f06cf91aea235830c5a0f9dd1ce64afe16e84
Diffstat (limited to 'src')
-rw-r--r-- | src/sqliteInt.h | 4 | ||||
-rw-r--r-- | src/where.c | 22 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3045d7c4a..d29b2e393 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1151,7 +1151,7 @@ extern u32 sqlite3WhereTrace; ** 0xFFFF---- Low-level debug messages ** ** 0x00000001 Code generation -** 0x00000002 Solver +** 0x00000002 Solver (Use 0x40000 for less detail) ** 0x00000004 Solver costs ** 0x00000008 WhereLoop inserts ** @@ -1170,6 +1170,8 @@ extern u32 sqlite3WhereTrace; ** ** 0x00010000 Show more detail when printing WHERE terms ** 0x00020000 Show WHERE terms returned from whereScanNext() +** 0x00040000 Solver overview messages +** 0x00080000 Star-query heuristic */ diff --git a/src/where.c b/src/where.c index 24674f91d..d25a1723d 100644 --- a/src/where.c +++ b/src/where.c @@ -5544,8 +5544,8 @@ static int computeMxChoice(WhereInfo *pWInfo){ } if( nDep<=3 ) continue; rDelta = 15*(nDep-3); -#ifdef WHERETRACE_ENABLED /* 0x4 */ - if( sqlite3WhereTrace&0x4 ){ +#ifdef WHERETRACE_ENABLED /* 0x80000 */ + if( sqlite3WhereTrace & 0x80000 ){ Bitmask x; int ii; sqlite3DebugPrintf( @@ -5564,10 +5564,12 @@ static int computeMxChoice(WhereInfo *pWInfo){ sqlite3DebugPrintf("\n"); } #endif - for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ - pWLoop->rStarDelta = 0; + if( pWInfo->nOutStarDelta==0 ){ + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + pWLoop->rStarDelta = 0; + } } - pWInfo->nOutStarDelta = rDelta; + pWInfo->nOutStarDelta += rDelta; for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ if( pWLoop->maskSelf==m ){ pWLoop->rRun -= rDelta; @@ -5576,6 +5578,16 @@ static int computeMxChoice(WhereInfo *pWInfo){ } } } +#ifdef WHERETRACE_ENABLED /* 0x80000 */ + if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->nOutStarDelta ){ + sqlite3DebugPrintf("WhereLoops changed by star-query heuristic:\n"); + for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){ + if( pWLoop->rStarDelta ){ + sqlite3WhereLoopPrint(pWLoop, &pWInfo->sWC); + } + } + } +#endif } return pWInfo->nOutStarDelta>0 ? 18 : 12; } |