RDBPROD: Performance Advice on Using WHERE IN (SELECT FROM table) (Doc ID 602499.1)

Last updated on AUGUST 09, 2016

Applies to:

Oracle Rdb Server on OpenVMS - Version 7.1.0.4 and later
HP OpenVMS Itanium
HP OpenVMS Alpha



Goal

Performance advice on using WHERE IN (in-list) when the in-list is an embedded SELECT:

  1. TAB1 contains 2 million rows and TAB2 contains 50000. Both have indexes on COL1.
    SQL> delete from tab1 where col1 in (select col1 from tab2);
  2. Performing the reverse, i.e. the delete is on the small table, the performance is very poor:
    SQL> delete from tab2 where not in (select col1 from tab1 t1 where t1.col1 = col1);

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms