Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect NLJ plan due to index fetch #2997

Open
hatyo opened this issue Dec 9, 2024 · 0 comments
Open

Incorrect NLJ plan due to index fetch #2997

hatyo opened this issue Dec 9, 2024 · 0 comments
Assignees
Labels
planner Related to the query planner

Comments

@hatyo
Copy link
Contributor

hatyo commented Dec 9, 2024

In certain scenarios, the optimizer chooses a covering index scan for NLJ inner leg, however it is also putting a fetch between the NLJ operator and the (correlated) predicate filter operator, this causes plan execution to fail with a missing correlation error.

com.apple.foundationdb.record.RecordCoreException: com.apple.foundationdb.record.RecordCoreException: Missing binding for __corr_q4

The optimizer should either push the fetch down (rendering the covering scan less appealing) or choose a different access path all together I think.

Here is an example:

create table t1(id bigint, parent bigint, primary key(id))
-- create a secondary index childIdx on id and parent

now:

select b.id, b.parent from t1 as a, t1 as b where a.parent = b.id and b.id > 40

ends up with this incorrect plan:

image
@hatyo hatyo added the planner Related to the query planner label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planner Related to the query planner
Projects
None yet
Development

No branches or pull requests

2 participants