/ Check-in [b36034bb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bug fixes in the solver.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1: b36034bbd19bc5677b26a6f60ca96eb2b37db373
User & Date: drh 2013-05-08 03:22:07
Context
2013-05-08
04:22
More bug fixes to the WhereLoop generator and the solver in NGQP. Now finds the best plan for TPC-H Q8. This seems to prove the concept, but there is still much work to be done. check-in: 8e5aad37 user: drh tags: nextgen-query-plan-exp
03:22
Bug fixes in the solver. check-in: b36034bb user: drh tags: nextgen-query-plan-exp
03:05
Add the NGQP solver. check-in: 5d37587c user: drh tags: nextgen-query-plan-exp
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  5439   5439     aFrom = aTo+mxChoice;
  5440   5440     memset(aFrom, 0, sizeof(aFrom[0]));
  5441   5441     pX = (WhereLoop**)(aFrom+mxChoice);
  5442   5442     for(ii=0, pFrom=aTo; ii<mxChoice*2; ii++, pFrom++, pX += nLoop){
  5443   5443       pFrom->aLoop = pX;
  5444   5444     }
  5445   5445   
         5446  +  aFrom[0].nRow = (double)1;
  5446   5447     nFrom = 1;
  5447   5448     for(iLoop=0; iLoop<nLoop; iLoop++){
  5448   5449       nTo = 0;
  5449   5450       for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){
  5450   5451         for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
  5451   5452           Bitmask maskNew;
  5452   5453           if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
................................................................................
  5458   5459             if( nTo>=mxChoice && rCost>=mxCost ) continue;
  5459   5460             if( nTo<mxChoice ){
  5460   5461               jj = nTo++;
  5461   5462             }else{
  5462   5463               for(jj=nTo-1; aTo[jj].rCost>=mxCost; jj++){ assert(jj>0); }
  5463   5464             }
  5464   5465             pTo = &aTo[jj];
         5466  +        }else{
         5467  +          if( pTo->rCost<=rCost ) continue;
  5465   5468           }
  5466   5469           pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
  5467   5470           pTo->nRow = pFrom->nRow * pWLoop->nOut;
  5468   5471           pTo->rCost = rCost;
  5469   5472           memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
  5470   5473           pTo->aLoop[iLoop] = pWLoop;
  5471   5474           if( nTo>=mxChoice ){
................................................................................
  5473   5476             for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
  5474   5477               if( pTo->rCost>mxCost ) mxCost = pTo->rCost;
  5475   5478             }
  5476   5479           }
  5477   5480         }
  5478   5481       }
  5479   5482   
         5483  +#if 0
         5484  +    if( sqlite3WhereTrace ){
         5485  +      sqlite3DebugPrintf("---- round %d ---- nTo=%d\n", iLoop, nTo);
         5486  +      for(ii=0; ii<nTo; ii++){
         5487  +        sqlite3DebugPrintf("%03d:  cost=%g  nrow=%g\n",
         5488  +           ii, aTo[ii].rCost, aTo[ii].nRow);
         5489  +        for(jj=0; jj<=iLoop; jj++){
         5490  +          whereLoopPrint(aTo[ii].aLoop[jj], pWInfo->pTabList);
         5491  +        }
         5492  +      }
         5493  +    }
         5494  +#endif
         5495  +
  5480   5496       /* Swap the roles of aFrom and aTo in preparation for the next
  5481   5497       ** cycle. */
  5482   5498       pFrom = aTo;
  5483   5499       aTo = aFrom;
  5484   5500       aFrom = pFrom;
  5485   5501       nFrom = nTo;
  5486   5502     }