Skip to content

The partial index is not involved when filtering conditions through OR. #7804

@sim1984

Description

@sim1984

I created partial index

CREATE INDEX IDX_TRIAL_LINE_PLACE_WIN
ON TRIAL_LINE(PLACE_WON)
WHERE PLACE_WON = 1 OR PLACE_WON = 2 OR PLACE_WON = 3;

And execute query:

SELECT COUNT(*)
FROM TRIAL_LINE
WHERE PLACE_WON = 1

plan:

PLAN (TRIAL_LINE NATURAL)

Select Expression
    -> Aggregate
        -> Filter
            -> Table "TRIAL_LINE" Full Scan

However, if you run a query like this, the index will be used:

SELECT COUNT(*)
FROM TRIAL_LINE
WHERE PLACE_WON = 1 OR PLACE_WON = 2
PLAN (TRIAL_LINE INDEX (IDX_TRIAL_LINE_PLACE_WIN, IDX_TRIAL_LINE_PLACE_WIN, IDX_TRIAL_LINE_PLACE_WIN))

Select Expression
    -> Aggregate
        -> Filter
            -> Table "TRIAL_LINE" Access By ID
                -> Bitmap And
                    -> Bitmap
                        -> Index "IDX_TRIAL_LINE_PLACE_WIN" Full Scan
                    -> Bitmap Or
                        -> Bitmap
                            -> Index "IDX_TRIAL_LINE_PLACE_WIN" Range Scan (full match)
                        -> Bitmap
                            -> Index "IDX_TRIAL_LINE_PLACE_WIN" Range Scan (full match)

Naturally, the index will be used for the full expression:

SELECT COUNT(*)
FROM TRIAL_LINE
WHERE PLACE_WON = 1 OR PLACE_WON = 2 OR PLACE_WON = 3

It seems to me that this clearly contradicts what is described in the release note:

The search condition defined for the index contains ORed boolean expressions and one of them is explicitly included in the WHERE condition;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions