Skip to content

Add support of the IN <list> predicate to the equality distribution logic#8732

Merged
dyemanov merged 1 commit intomasterfrom
work/in-eq-distrib
Sep 7, 2025
Merged

Add support of the IN <list> predicate to the equality distribution logic#8732
dyemanov merged 1 commit intomasterfrom
work/in-eq-distrib

Conversation

@dyemanov
Copy link
Copy Markdown
Member

@dyemanov dyemanov commented Sep 5, 2025

Currently we're able to derive X(C,B) from X(A,B) and A=C, however this works only for X = ComparativeBoolNode and does not work for IN <list> predicates.

Imagine a join like this:

select *
from A join B on A.ID = B.ID
where A.ID in (1, 2)
order by A.ID desc;

that can be loop-joined as either A->B or B->A. However, the IN predicate can currently use an index only for the A->B case, and if the optimizer chooses the opposite direction the performance drops down.

where A.ID = 1:
Fetches = 9, indexed reads from either A or B = 1

where A.ID = 1 OR A.ID = 2:
Fetches = 16, indexed reads from either A or B = 2

where A.ID IN (1, 2):
Fetches = 438587, indexed reads from either A or B = 72515

The plan in the last case reports "Index Full Scan" instead of the expected "Index List Scan".

After the fix:

where A.ID IN (1, 2):
Fetches = 18, indexed reads from either A or B = 2

@dyemanov dyemanov self-assigned this Sep 5, 2025
@dyemanov dyemanov merged commit 13f167a into master Sep 7, 2025
46 checks passed
@dyemanov dyemanov deleted the work/in-eq-distrib branch September 7, 2025 16:20
@mrotteveel mrotteveel added the rlsnotes60: no Intentionally not added to the Firebird 6.0 release notes. label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants