title: SQL Statement Performance Issue on Informix
body: <p>I have this Informix SQL statement which takes ages to run.  Does anybody see any way to optimize it so it wouldn't take so long?</p>
  
  <pre><code>SELECT * FROM OriginalTable WHERE type = 'S' AND flag &lt;&gt; 'S' INTO TEMP TempTableA;
  
  SELECT * FROM OriginalTable WHERE type = 'Z' AND flag &lt;&gt; 'S' INTO TEMP TempTableB;
  
  UPDATE OriginalTable SET flag = 'D' WHERE Serialnumber in
  (
  select Serialnumber from TempTableA
  WHERE NOT EXISTS(SELECT * FROM TempTableB
                 WHERE TempTableB.Col1 = TempTableA.Col1
                   AND TempTableB.Col2 = TempTableA.Col2)
  ) 
  </code></pre>
  
  <p>I have in my OriginalTable around 300 million rows, TempTableA 93K rows, and TempTableB 58K rows.</p>