title: Improve performance SQL query in Python Cx_Oracle
body: <p>I actually use Cx_Oracle library in Python to work with my database Oracle.</p>
  
  <pre><code>import cx_Oracle as Cx
  
  # Parameters for server connexion
  dsn_tns = Cx.makedsn(_ip, _port, service_name=_service_name)
  
  # Connexion with Oracle Database
  db = Cx.connect(_user, _password, dsn_tns)
  
  # Obtain a cursor for make SQL query
  cursor = db.cursor()
  </code></pre>
  
  <p>One of my query write in an INSERT of a Python dataframe into my Oracle target table among some conditions.</p>
  
  <pre><code>query = INSERT INTO ORA_TABLE(ID1, ID2) 
  SELECT :1, :2
  FROM DUAL 
  WHERE (:1 != 'NF' AND :1 NOT IN (SELECT ID1 FROM ORA_TABLE)) 
     OR (:1 = 'NF' AND :2 NOT IN (SELECT ID2 FROM ORA_TABLE))
  </code></pre>
  
  <p>The goal of this query is to write only rows who respect conditions into the WHERE.</p>
  
  <p>Actually ,this query works well when my Oracle target table have few rows. But, if my target Oracle table have more than 100 000 rows, it's very slow because I read through all the table in WHERE condition.</p>
  
  <p>Is there a way to improve performance of this query with join or something else ?</p>
  
  <p>End of code :</p>
  
  <pre><code># SQL query incoming
  cursor.prepare(query)
  
  # Launch query with Python dataset
  cursor.executemany(None, _py_table.values.tolist())
  
  # Commit changes into Oracle database
  db.commit()
  
  # Close the cursor
  cursor.close()
  
  # Close the server connexion
  db.close()
  </code></pre>