diff options
author | drh <drh@noemail.net> | 2016-02-22 20:52:26 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-02-22 20:52:26 +0000 |
commit | a6d2f8eb1e2e1be45ac52106fd31eb8c5c81f7f5 (patch) | |
tree | acbd6946feb552ca85f3ba53656a6d2347c78450 /src/wherecode.c | |
parent | b9626cfa709ff5f71521035d21efd79b781bb760 (diff) | |
download | sqlite-a6d2f8eb1e2e1be45ac52106fd31eb8c5c81f7f5.tar.gz sqlite-a6d2f8eb1e2e1be45ac52106fd31eb8c5c81f7f5.zip |
Avoid an unnecessary seek operation on some corner-case skip-scans.
FossilOrigin-Name: 38e837e605076124b73235e1fd832838d9545cb2
Diffstat (limited to 'src/wherecode.c')
-rw-r--r-- | src/wherecode.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/wherecode.c b/src/wherecode.c index bb48e5dc7..34e166bc4 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1212,17 +1212,19 @@ Bitmask sqlite3WhereCodeOneLoopStart( start_constraints = 1; } codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff); - op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; - assert( op!=0 ); - sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); - VdbeCoverage(v); - VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind ); - VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last ); - VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT ); - VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE ); - VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE ); - VdbeCoverageIf(v, op==OP_SeekLT); testcase( op==OP_SeekLT ); - + if( pLoop->nSkip==0 || nConstraint>pLoop->nSkip ){ + op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; + assert( op!=0 ); + sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); + VdbeCoverage(v); + VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind ); + VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last ); + VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT ); + VdbeCoverageIf(v, op==OP_SeekGE); testcase( op==OP_SeekGE ); + VdbeCoverageIf(v, op==OP_SeekLE); testcase( op==OP_SeekLE ); + VdbeCoverageIf(v, op==OP_SeekLT); testcase( op==OP_SeekLT ); + } + /* Load the value for the inequality constraint at the end of the ** range (if any). */ |