SQLite

Check-in [1c4a78807b]
Login

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

Overview
Comment:Performance tweak to whereLoopInsert().
Downloads: Tarball | ZIP 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.358
Context
2013-06-05
16:19
Minor performance tuning of the NGQP. (check-in: cbef38c2d1 user: drh tags: nextgen-query-plan-exp)
12:47
Performance tweak to whereLoopInsert(). (check-in: 1c4a78807b 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: 96afe50866 user: drh tags: nextgen-query-plan-exp)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/where.c.
3855
3856
3857
3858
3859
3860
3861





3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880

3881
3882
3883
3884
3885
3886
3887
  }

  /* Search for an existing WhereLoop to overwrite, or which takes
  ** priority over pTemplate.
  */
  for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){
    if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue;





    if( p->nTerm<pTemplate->nTerm
     && (p->wsFlags & WHERE_INDEXED)!=0
     && (pTemplate->wsFlags & WHERE_INDEXED)!=0
     && p->u.btree.pIndex==pTemplate->u.btree.pIndex
     && p->prereq==pTemplate->prereq
    ){
      /* Overwrite an existing WhereLoop with an similar one that uses
      ** more terms of the index */
      pNext = p->pNextLoop;
      whereLoopClear(db, p);
      break;
    }
    if( (p->prereq & pTemplate->prereq)==p->prereq
     && p->rSetup<=pTemplate->rSetup
     && p->rRun<=pTemplate->rRun
    ){
      /* Already holding an equal or better WhereLoop.
      ** Return without changing or adding anything */
      goto whereLoopInsert_noop;

    }
    if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
     && p->rSetup>=pTemplate->rSetup
     && p->rRun>=pTemplate->rRun
    ){
      /* Overwrite an existing WhereLoop with a better one */
      pNext = p->pNextLoop;







>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
<
<
|
<
<
|
|
>







3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878


3879


3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
  }

  /* Search for an existing WhereLoop to overwrite, or which takes
  ** priority over pTemplate.
  */
  for(ppPrev=&pWInfo->pLoops, p=*ppPrev; p; ppPrev=&p->pNextLoop, p=*ppPrev){
    if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ) continue;
    if( (p->prereq & pTemplate->prereq)==p->prereq
     && p->rSetup<=pTemplate->rSetup
     && p->rRun<=pTemplate->rRun
    ){
      /* p is equal or better than pTemplate */
      if( p->nTerm<pTemplate->nTerm
       && (p->wsFlags & WHERE_INDEXED)!=0
       && (pTemplate->wsFlags & WHERE_INDEXED)!=0
       && p->u.btree.pIndex==pTemplate->u.btree.pIndex
       && p->prereq==pTemplate->prereq
      ){
        /* Overwrite an existing WhereLoop with an similar one that uses
        ** more terms of the index */
        pNext = p->pNextLoop;
        whereLoopClear(db, p);
        break;
      }else{


        /* pTemplate is not helpful.


        ** Return without changing or adding anything */
        goto whereLoopInsert_noop;
      }
    }
    if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
     && p->rSetup>=pTemplate->rSetup
     && p->rRun>=pTemplate->rRun
    ){
      /* Overwrite an existing WhereLoop with a better one */
      pNext = p->pNextLoop;