1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

The top of an index equality loop normally starts with OP_SeekGE and OP_IdxGT.

This check-in adds a flag to OP_SeekGE such that it fails immediately if
the key is not equal, then jumps over the OP_IdxGT, saving a call to the key
comparison functions.  Consider this check-in a proof-of-concept.  It needs 
improvement before going on trunk.  Some tests fail, but only because they
new use fewer key comparisons than expected (which is a good thing!).

FossilOrigin-Name: 32e31b9bc8664afcd326a1ff3892d86dc5202474
This commit is contained in:
drh
2015-11-05 20:25:09 +00:00
parent d82211db56
commit 70528d7868
7 changed files with 39 additions and 16 deletions

View File

@@ -3691,11 +3691,13 @@ case OP_SeekGT: { /* jump, in3 */
#ifdef SQLITE_DEBUG
if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){
assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );
#if 0
assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
assert( pOp[1].p1==pOp[0].p1 );
assert( pOp[1].p2==pOp[0].p2 );
assert( pOp[1].p3==pOp[0].p3 );
assert( pOp[1].p4.i==pOp[0].p4.i );
#endif
}
#endif
@@ -3772,10 +3774,14 @@ case OP_SeekGT: { /* jump, in3 */
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif
ExpandBlob(r.aMem);
r.eqSeen = 0;
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, &r, 0, 0, &res);
if( rc!=SQLITE_OK ){
goto abort_due_to_error;
}
if( (pOp->p5 & OPFLAG_SEEKEQ)!=0 && r.eqSeen==0 ){
goto take_the_jump;
}
}
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
@@ -3803,6 +3809,7 @@ case OP_SeekGT: { /* jump, in3 */
res = sqlite3BtreeEof(pC->pCursor);
}
}
take_the_jump:
assert( pOp->p2>0 );
VdbeBranchTaken(res!=0,2);
if( res ){