/ Check-in [1c4a7880]
Login

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

Overview
Comment:Performance tweak to whereLoopInsert().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1:1c4a78807b7a28c9976ca8c5722ff4e2e8755b7e
User & Date: drh 2013-06-05 12:47:59
Context
2013-06-05
16:19
Minor performance tuning of the NGQP. check-in: cbef38c2 user: drh tags: nextgen-query-plan-exp
12:47
Performance tweak to whereLoopInsert(). check-in: 1c4a7880 user: drh tags: nextgen-query-plan-exp
12:18
Add a test case contributed on the mailing list that works in NGQP but fails in legacy. check-in: 96afe508 user: drh tags: nextgen-query-plan-exp
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3855   3855     }
  3856   3856   
  3857   3857     /* Search for an existing WhereLoop to overwrite, or which takes
  3858   3858     ** priority over pTemplate.
  3859   3859     */
  3860   3860     for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){
  3861   3861       if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue;
  3862         -    if( p->nTerm<pTemplate->nTerm
  3863         -     && (p->wsFlags & WHERE_INDEXED)!=0
  3864         -     && (pTemplate->wsFlags & WHERE_INDEXED)!=0
  3865         -     && p->u.btree.pIndex==pTemplate->u.btree.pIndex
  3866         -     && p->prereq==pTemplate->prereq
  3867         -    ){
  3868         -      /* Overwrite an existing WhereLoop with an similar one that uses
  3869         -      ** more terms of the index */
  3870         -      pNext = p->pNextLoop;
  3871         -      whereLoopClear(db, p);
  3872         -      break;
  3873         -    }
  3874   3862       if( (p->prereq & pTemplate->prereq)==p->prereq
  3875   3863        && p->rSetup<=pTemplate->rSetup
  3876   3864        && p->rRun<=pTemplate->rRun
  3877   3865       ){
  3878         -      /* Already holding an equal or better WhereLoop.
  3879         -      ** Return without changing or adding anything */
  3880         -      goto whereLoopInsert_noop;
         3866  +      /* p is equal or better than pTemplate */
         3867  +      if( p->nTerm<pTemplate->nTerm
         3868  +       && (p->wsFlags & WHERE_INDEXED)!=0
         3869  +       && (pTemplate->wsFlags & WHERE_INDEXED)!=0
         3870  +       && p->u.btree.pIndex==pTemplate->u.btree.pIndex
         3871  +       && p->prereq==pTemplate->prereq
         3872  +      ){
         3873  +        /* Overwrite an existing WhereLoop with an similar one that uses
         3874  +        ** more terms of the index */
         3875  +        pNext = p->pNextLoop;
         3876  +        whereLoopClear(db, p);
         3877  +        break;
         3878  +      }else{
         3879  +        /* pTemplate is not helpful.
         3880  +        ** Return without changing or adding anything */
         3881  +        goto whereLoopInsert_noop;
         3882  +      }
  3881   3883       }
  3882   3884       if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
  3883   3885        && p->rSetup>=pTemplate->rSetup
  3884   3886        && p->rRun>=pTemplate->rRun
  3885   3887       ){
  3886   3888         /* Overwrite an existing WhereLoop with a better one */
  3887   3889         pNext = p->pNextLoop;