SQLite

Check-in [87a9fc504f]
Login

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

Overview
Comment:Use an OP_NotFound opcode to cancel futile IN operators early. The current implementation is suboptimal because it always runs teh OP_NotFound. This still needs to be enhanced to only do the OP_NotFound if no results have been seen on the current loop.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | multikey-opt-idea
Files: files | file ages | folders
SHA3-256: 87a9fc504f9a78caf7a7949cc7ada0a19d61bfab51bb49a00a1607194c116212
User & Date: drh 2018-06-05 15:16:25.289
Context
2018-06-05
20:45
Add the OP_IfNoHope and OP_SeekHit opcodes used to reduce the number of unnecessary sqlite3BtreeMovetoUnpacked() calls when checking for an early exit on IN-operator loops. Futher optimizations are likely possible here. (check-in: 6bf251af43 user: drh tags: multikey-opt-idea)
15:16
Use an OP_NotFound opcode to cancel futile IN operators early. The current implementation is suboptimal because it always runs teh OP_NotFound. This still needs to be enhanced to only do the OP_NotFound if no results have been seen on the current loop. (check-in: 87a9fc504f user: drh tags: multikey-opt-idea)
13:54
Merge trunk changes. (check-in: 047295c588 user: drh tags: multikey-opt-idea)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/where.c.
5080
5081
5082
5083
5084
5085
5086
5087


5088

5089
5090
5091
5092
5093
5094
5095
5080
5081
5082
5083
5084
5085
5086

5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097







-
+
+

+







      struct InLoop *pIn;
      int j;
      sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
      for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
        sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
        if( pIn->eEndLoopOp!=OP_Noop ){
          if( pIn->nPrefix ){
            sqlite3VdbeAddOp3(v, OP_Noop, pLevel->iIdxCur,
            sqlite3VdbeAddOp4Int(v, OP_NotFound, pLevel->iIdxCur,
                              sqlite3VdbeCurrentAddr(v)+2,
                              pIn->iBase, pIn->nPrefix);
            VdbeCoverage(v);
          }
          sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
          VdbeCoverage(v);
          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
        }
        sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
Changes to src/wherecode.c.
588
589
590
591
592
593
594

595
596





597
598
599
600
601
602
603
588
589
590
591
592
593
594
595


596
597
598
599
600
601
602
603
604
605
606
607







+
-
-
+
+
+
+
+







            int iCol = aiMap ? aiMap[iMap++] : 0;
            pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);
          }
          sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);
          if( i==iEq ){
            pIn->iCur = iTab;
            pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;
            if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
            pIn->iBase = iReg - i;
            pIn->nPrefix = i;
              pIn->iBase = iReg - i;
              pIn->nPrefix = i;
            }else{
              pIn->nPrefix = 0;
            }
          }else{
            pIn->eEndLoopOp = OP_Noop;
          }
          pIn++;
        }
      }
    }else{