Here I have a query like below:
SELECT field
FROM table
WHERE value IN ('val1', 'val2', 'val3', ... 'valn')
Let's say there are 2000 values inside the IN clause, the value doesn't exist in other table. Do you have any idea to speed up this operation?
The question is open to accept any kind of methods..
Thanks!
The Oracle "with" clause will help performance in situations where your query contains several identical sub queries. Instead of re-computing the repeating sub queries, it will query or aggregate once, assign a name to the resulting data and refer to it.
Create an index that covers 'field' and 'value'.
Place those IN values in a temp table and join on it.
SELECT field
FROM table
WHERE value IN SELECT somevalue from sometable
As far as i know, you will face another problem. That will be the limitation of 'IN' clause. Using this, you can avoid that and hopefully fasten your query
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With