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

UNION ALL optimalization with fix false condition #8113

Open
EPluribusUnum opened this issue May 13, 2024 · 2 comments
Open

UNION ALL optimalization with fix false condition #8113

EPluribusUnum opened this issue May 13, 2024 · 2 comments

Comments

@EPluribusUnum
Copy link

Hi *!

CREATE OR ALTER VIEW union_opt
AS
SELECT 'A' union_id
FROM rdb$database
UNION ALL
SELECT 'B'
FROM rdb$database

SELECT *
FROM union_opt
WHERE union_id = 'A'

The select does 2 non-index reads.
I think it should be only 1 non-index read, as the second select expressions conditon is fix false, no row-by-row evaluation is needed.

Thank you!

@mrotteveel
Copy link
Member

It will need to get that row to be able to evaluate that it should be filtered out.

@EPluribusUnum EPluribusUnum changed the title UNION all optimalization with fix false condition UNION ALL optimalization with fix false condition May 14, 2024
@EPluribusUnum
Copy link
Author

The filtered column is a constant, so the column value is known at prepare time. The condition on the constant column also constant, so the condition can be evaluated at prepare time without needing to fetch any record from the table at exec time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants