Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 588 Bytes

3014.md

File metadata and controls

18 lines (15 loc) · 588 Bytes

OR Usage

Consider using an IN predicate when querying an indexed column:

The IN-list predicate can be exploited for indexed retrieval and also, the optimizer can sort the IN-list to match the sort sequence of the index, leading to more efficient retrieval. Note that the IN-list must contain only constants, or values that are constant during one execution of the query block, such as outer references.

Example

SELECT s.* FROM SH.sales s WHERE s.prod_id = 14 OR s.prod_id = 17

can be rewritten as:

SELECT s.* FROM SH.sales s WHERE s.prod_id IN (14, 17)