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

Bad optimization of OR predicates applied to unions [CORE4102] #4430

Closed
firebird-automations opened this issue May 22, 2013 · 9 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: GR (gr)

Is related to QA527

Script to reproduce:

CREATE TABLE TEST_TABLE (ID INTEGER);
CREATE INDEX IDX1 ON TEST_TABLE (ID);

CREATE VIEW TEST_VIEW
AS
SELECT ID FROM TEST_TABLE
UNION ALL
SELECT ID FROM TEST_TABLE ;

===============================================

Queries with plans:

SELECT *
FROM TEST_TABLE
WHERE (ID = 0) OR (ID = 1)

Plan
PLAN (TEST_TABLE INDEX (IDX1, IDX1))

----------------------------------------

SELECT * FROM TEST_VIEW
WHERE (ID = 0)

Plan
PLAN (TEST_VIEW TEST_TABLE INDEX (IDX1))
PLAN (TEST_VIEW TEST_TABLE INDEX (IDX1))

----------------------------------------

SELECT * FROM TEST_VIEW
WHERE (ID = 0) OR (ID = 1)

Plan
PLAN (TEST_VIEW TEST_TABLE NATURAL)
PLAN (TEST_VIEW TEST_TABLE NATURAL)

while expected

Plan
PLAN (TEST_VIEW TEST_TABLE INDEX (IDX1, IDX1))
PLAN (TEST_VIEW TEST_TABLE INDEX (IDX1, IDX1))

Commits: e2d4568 525a178 FirebirdSQL/fbt-repository@cd3ce80 FirebirdSQL/fbt-repository@f462c7f FirebirdSQL/fbt-repository@a790c1d

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Simplified test case:

select * from
(
select rdb$relation_id as id
from rdb$relations r
union all
select rdb$relation_id as id
from rdb$relations r
) x
where http://x.id = 0 or http://x.id = 1

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Version: 2.5.2 Update 1 [ 10521 ]

Version: 2.1.5 Update 1 [ 10522 ]

Version: 2.0.7 [ 10390 ]

Version: 2.5.1 [ 10333 ]

Version: 2.1.4 [ 10361 ]

Version: 2.5.0 [ 10221 ]

Version: 2.0.6 [ 10303 ]

Version: 3.0 Initial [ 10301 ]

Version: 2.1.3 [ 10302 ]

Version: 2.1.2 [ 10270 ]

Version: 2.0.5 [ 10222 ]

Version: 2.1.1 [ 10223 ]

Version: 2.1.0 [ 10041 ]

summary: Bad optimization of quiries with OR predicate to view with union => Bad optimization of OR predicates applied to unions

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: In Progress [ 3 ] => Open [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

Fix Version: 2.5.3 [ 10461 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA527 [ QA527 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pmakowski

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment