Add support of the IN <list> predicate to the equality distribution logic #8732
+101
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we're able to derive
X(C,B)
fromX(A,B) and A=C
, however this works only forX = ComparativeBoolNode
and does not work forIN <list>
predicates.Imagine a join like this:
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