Skip to content

Commit 0a4305c

Browse files
author
D. Richard Hipp
committed
Use a mini Bloom filter to help reduce the number of pointless searches for
prior SubrtnSig objects when generating code for IN operators with subqueries as their right operand.
1 parent bbc516a commit 0a4305c

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/expr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ static int findCompatibleInRhsSubrtn(
34363436
Vdbe *v;
34373437

34383438
if( pNewSig==0 ) return 0;
3439-
if( pParse->bHasSubrtn==0 ) return 0;
3439+
if( (pParse->mSubrtnSig & (1<<(pNewSig->selId&7)))==0 ) return 0;
34403440
assert( pExpr->op==TK_IN );
34413441
assert( !ExprUseYSub(pExpr) );
34423442
assert( ExprUseXSelect(pExpr) );
@@ -3564,7 +3564,7 @@ void sqlite3CodeRhsOfIN(
35643564
pSig->regReturn = pExpr->y.sub.regReturn;
35653565
pSig->iTable = iTab;
35663566
sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG);
3567-
pParse->bHasSubrtn = 1;
3567+
pParse->mSubrtnSig = 1 << (pSig->selId&7);
35683568
}
35693569
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
35703570
}

src/sqliteInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3834,7 +3834,7 @@ struct Parse {
38343834
u8 prepFlags; /* SQLITE_PREPARE_* flags */
38353835
u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
38363836
u8 bHasWith; /* True if statement contains WITH */
3837-
u8 bHasSubrtn; /* True if any P4_SUBRTNSIG has been set */
3837+
u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
38383838
#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
38393839
u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */
38403840
#endif

0 commit comments

Comments
 (0)