/ Check-in [a3dcf6db]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Clearer presentation of the logic. No functional changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | skip-scan-improvement
Files: files | file ages | folders
SHA1: a3dcf6db76cc09bdfedb1bbeba3b359b77762cbe
User & Date: drh 2016-02-22 21:19:54
Context
2016-02-22
23:14
Avoid an unnecessary seek operation some corner-case skip-scan operations. check-in: 2a6003a9 user: drh tags: trunk
21:19
Clearer presentation of the logic. No functional changes. Closed-Leaf check-in: a3dcf6db user: drh tags: skip-scan-improvement
20:52
Avoid an unnecessary seek operation on some corner-case skip-scans. check-in: 38e837e6 user: drh tags: skip-scan-improvement
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

  1208   1208       }else if( bSeekPastNull ){
  1209   1209         sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
  1210   1210         nConstraint++;
  1211   1211         startEq = 0;
  1212   1212         start_constraints = 1;
  1213   1213       }
  1214   1214       codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);
  1215         -    if( pLoop->nSkip==0 || nConstraint>pLoop->nSkip ){
         1215  +    if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){
         1216  +      /* The skip-scan logic inside the call to codeAllEqualityConstraints()
         1217  +      ** above has already left the cursor sitting on the correct row,
         1218  +      ** so no further seeking is needed */
         1219  +    }else{
  1216   1220         op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
  1217   1221         assert( op!=0 );
  1218   1222         sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
  1219   1223         VdbeCoverage(v);
  1220   1224         VdbeCoverageIf(v, op==OP_Rewind);  testcase( op==OP_Rewind );
  1221   1225         VdbeCoverageIf(v, op==OP_Last);    testcase( op==OP_Last );
  1222   1226         VdbeCoverageIf(v, op==OP_SeekGT);  testcase( op==OP_SeekGT );
  1223   1227         VdbeCoverageIf(v, op==OP_SeekGE);  testcase( op==OP_SeekGE );
  1224   1228         VdbeCoverageIf(v, op==OP_SeekLE);  testcase( op==OP_SeekLE );
  1225   1229         VdbeCoverageIf(v, op==OP_SeekLT);  testcase( op==OP_SeekLT );
  1226   1230       }
  1227         -    
         1231  +
  1228   1232       /* Load the value for the inequality constraint at the end of the
  1229   1233       ** range (if any).
  1230   1234       */
  1231   1235       nConstraint = nEq;
  1232   1236       if( pRangeEnd ){
  1233   1237         Expr *pRight = pRangeEnd->pExpr->pRight;
  1234   1238         sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);