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
Do not remove LEFT JOIN if there is table hint. #4016
Conversation
/azp run test-all |
Azure Pipelines successfully started running 1 pipeline(s). |
@sdanyliv out of curiosity, what's the underlying issue? Is it a cardinality problem with temporal ranges (your test case uses AS OF, so only it should return only 1 row)? |
@jods4. with temporal tables here can be duplicates of Primary Key. Removing joins is not an option in that case. We can simplify restriction for |
Ok so this is indeed a cardinality issue? This fix feels like a hack. There might be other optimisations or transformations that look at cardinality and they would all be incorrect as well. If you merge this PR, it'd be really nice to leave a comment on the new condition to explain why it's there so we can review it in the future. |
It is question to current hint implementation. I've just noticed that we have issue with this one and in production it may lead in problems. Since I have no time to work with this right now - disabled optimization for tables with hints. Will add comment about that when tests are passed. |
@sdanyliv I see this was merged, please don't forget to add a comment so we remember why this was added and could potentially refactor it in the future. |
Yeah, I even tried to include Cardinality and give up. Current Query Hint realization do not give this possibility. |
@sdanyliv Understood, no problem if you need a fix for a bug in production. Just for long-term maintenance I think we need to remember to add a test that would fail if this is removed and a comment to explain for what specific case we keep LEFT JOIN with hints. |
Wrong JOIN optimization with Temporal Tables.