aboutsummaryrefslogtreecommitdiff
path: root/src/where.c
diff options
context:
space:
mode:
authordrh <>2024-05-28 12:41:11 +0000
committerdrh <>2024-05-28 12:41:11 +0000
commitefe474af97decf22821c8b5249075101bd7feea5 (patch)
tree4fccc83d4a41179fe1052133a02b5ea44bbb2c4c /src/where.c
parent6fa46d0e06a805817c574e38f307ee4ea2d9c7a8 (diff)
downloadsqlite-efe474af97decf22821c8b5249075101bd7feea5.tar.gz
sqlite-efe474af97decf22821c8b5249075101bd7feea5.zip
Increase the number of parallel paths in the query solver from 12 to 20.
In the .wheretrace output, sort the parallel paths in order of increasing cost. FossilOrigin-Name: 8ba2c2f5cb31f7bcc426bec78457316ef11d0b5debf24e8da8c6fc2f95878b1e
Diffstat (limited to 'src/where.c')
-rw-r--r--src/where.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/where.c b/src/where.c
index 980047947..fc4a88eab 100644
--- a/src/where.c
+++ b/src/where.c
@@ -5286,9 +5286,9 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
** ----- --------
** 1 1 // the most common case
** 2 5
- ** 3+ 12
+ ** 3+ 20
*/
- mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 12);
+ mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 20);
assert( nLoop<=pWInfo->pTabList->nSrc );
WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n",
nRowEst, pParse->nQueryLoop));
@@ -5535,16 +5535,28 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
#ifdef WHERETRACE_ENABLED /* >=2 */
if( sqlite3WhereTrace & 0x02 ){
+ LogEst rMin, rFloor = 0;
+ int nDone = 0;
sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
- for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
- sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c",
- wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
- pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?');
- if( pTo->isOrdered>0 ){
- sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop);
- }else{
- sqlite3DebugPrintf("\n");
+ while( nDone<nTo ){
+ rMin = 0x7fff;
+ for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
+ if( pTo->rCost>rFloor && pTo->rCost<rMin ) rMin = pTo->rCost;
+ }
+ for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
+ if( pTo->rCost==rMin ){
+ sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c",
+ wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
+ pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?');
+ if( pTo->isOrdered>0 ){
+ sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop);
+ }else{
+ sqlite3DebugPrintf("\n");
+ }
+ nDone++;
+ }
}
+ rFloor = rMin;
}
}
#endif