Issue Details (XML | Word | Printable)

Key: CORE-4102
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: GR
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Bad optimization of OR predicates applied to unions

Created: 22/May/13 06:37 PM   Updated: 12/Jul/15 06:02 AM
Component/s: Engine
Affects Version/s: 2.1.0, 2.1.1, 2.0.5, 2.1.2, 2.1.3, 3.0 Initial, 2.0.6, 2.5.0, 2.1.4, 2.5.1, 2.0.7, 2.1.5, 2.5.2, 2.1.5 Update 1, 2.5.2 Update 1
Fix Version/s: 3.0 Alpha 1, 2.5.3

Issue Links:
Relate
 

QA Status: Done successfully


 Description  « Hide
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))


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dmitry Yemanov added a comment - 23/May/13 07:47 AM
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 x.id = 0 or x.id = 1