title: MySQL WHERE NOT IN extremely slow
body: <p>Below is a SQL statement inside a stored procedure (<em>truncated for brevity</em>):</p>
  
  <pre><code>SELECT * 
  FROM item a 
  WHERE a.orderId NOT IN (SELECT orderId FROM table_excluded_item);
  </code></pre>
  
  <p>This statement takes 30 seconds or so! But if I remove the inner SELECT query, it drops to 1s. <code>table_excluded_item</code> is not huge, but I suspect the inner query is being executed more than it needs to be.</p>
  
  <p>Is there a more efficient way of doing this?</p>