I have a table in an Oracle database, partitioned by a field. In our application we need to query data that is scatered across 2 partitions. Can you please tell me which method is better:
-
making multiple selects with UNION ALL like:
select * from table where field = 'A' UNION ALL select * from table where field = 'B' -
making one query:
select * from table where field in ('A','B')
Best Answer
Oracle will take care of partition pruning when using ** making one query: select * from table where field in ('A','B')
Here is an example:
The KEY(INLIST) designation for the partition start and stop keys specifies that an IN list predicate.