title: Sql query with an or statement takes too long to execute
body: <p>I have a table with 2 columns - ref_table_id, ref_objid.
  This table is used to reference objects in other tables. It has actually more than 2 columns but other columns are not important.</p>
  
  <p>The following query takes 1 second to execute:</p>
  
  <pre><code>delete from ref_table_id
  where (ref_table_id = 1 and 
         ref_objid not in (select objid from table1))
  </code></pre>
  
  <p>As well this query takes 1 second to execute:</p>
  
  <pre><code>delete from ref_table_id
  where (ref_table_id = 2 and 
         ref_objid not in (select objid from table2))
  </code></pre>
  
  <p>However this query takes 3 minutes to execute:</p>
  
  <pre><code>delete from ref_table_id
  where (ref_table_id = 1 and 
         ref_objid not in (select objid from table1))
     or (ref_table_id = 2 and 
         ref_objid not in (select objid from table2))
  </code></pre>
  
  <p>Why does the last query take so much time? It is basically just a combination of the first two. Can anyone please explain this?</p>
  
  <p>I am using Oracle.</p>
  
  <p>Thank you</p>