Skip to content

Commit

Permalink
Use a mini Bloom filter to help reduce the number of pointless search…
Browse files Browse the repository at this point in the history
…es for

prior SubrtnSig objects when generating code for IN operators with subqueries
as their right operand.
  • Loading branch information
D. Richard Hipp committed Jul 5, 2024
1 parent bbc516a commit 0a4305c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3436,7 +3436,7 @@ static int findCompatibleInRhsSubrtn(
Vdbe *v;

if( pNewSig==0 ) return 0;
if( pParse->bHasSubrtn==0 ) return 0;
if( (pParse->mSubrtnSig & (1<<(pNewSig->selId&7)))==0 ) return 0;
assert( pExpr->op==TK_IN );
assert( !ExprUseYSub(pExpr) );
assert( ExprUseXSelect(pExpr) );
Expand Down Expand Up @@ -3564,7 +3564,7 @@ void sqlite3CodeRhsOfIN(
pSig->regReturn = pExpr->y.sub.regReturn;
pSig->iTable = iTab;
sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG);
pParse->bHasSubrtn = 1;
pParse->mSubrtnSig = 1 << (pSig->selId&7);
}
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
}
Expand Down
2 changes: 1 addition & 1 deletion src/sqliteInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@ struct Parse {
u8 prepFlags; /* SQLITE_PREPARE_* flags */
u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
u8 bHasWith; /* True if statement contains WITH */
u8 bHasSubrtn; /* True if any P4_SUBRTNSIG has been set */
u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */
#endif
Expand Down

0 comments on commit 0a4305c

Please sign in to comment.