diff options
author | drh <drh@noemail.net> | 2018-06-05 20:45:20 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-06-05 20:45:20 +0000 |
commit | 8c2b6d784b44c601ea600e8cfca9a222ce66b54b (patch) | |
tree | a838532373314e1174e8e5ad4d8640ffadac7912 /src/wherecode.c | |
parent | 86d0ea755844cc3ace4800cfb1400d18bc067ccb (diff) | |
download | sqlite-8c2b6d784b44c601ea600e8cfca9a222ce66b54b.tar.gz sqlite-8c2b6d784b44c601ea600e8cfca9a222ce66b54b.zip |
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.
FossilOrigin-Name: 6bf251af4347165a470d39457d61ab6d2a06c206db8f30bd8be5dbb388ae8a5b
Diffstat (limited to 'src/wherecode.c')
-rw-r--r-- | src/wherecode.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wherecode.c b/src/wherecode.c index 1c653c9f5..a20a9808e 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1664,6 +1664,9 @@ Bitmask sqlite3WhereCodeOneLoopStart( ** above has already left the cursor sitting on the correct row, ** so no further seeking is needed */ }else{ + if( pLoop->wsFlags & WHERE_IN_ABLE ){ + sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur); + } op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; assert( op!=0 ); sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint); @@ -1727,6 +1730,10 @@ Bitmask sqlite3WhereCodeOneLoopStart( testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE ); } + if( pLoop->wsFlags & WHERE_IN_ABLE ){ + sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1); + } + /* Seek the table cursor, if required */ if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ |