Skip to content

Indexes may not be used for multiple ORed conditions containing both field and non-field references #8926

@dyemanov

Description

@dyemanov

Provided test case:

select first 1 i.ID, i.ID_TYPE
 from IDENT$IDENTIFIERS i
      left join IDENT$LIFE l on l.ID_IDENT = i.ID
 where (i.IDENTIFIER_VALUE = ? or i.IDENTIFIER_CODE = ?) and (i.ID_TYPE = ? or ? = 0)
 order by l.CURRENT_STATE nulls last, i.ID_TYPE desc;

Actual plan:

PLAN SORT (JOIN (I NATURAL, L INDEX (IDENT$LIFE_IDENTIFIER)))

Expected plan:

PLAN SORT (JOIN (I INDEX (IDENT$IDENTIFIER_VALUE, IDENT$IDENTIFIER_CODE), L INDEX (IDENT$LIFE_IDENTIFIER)))

The plan turns into he expected one if the (i.ID_TYPE = ? or ? = 0) part is omitted or hinted to avoid index usage (i.ID_TYPE+0 = ?).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions