title: How to get id's from a list that are NOT in a table?
body: <p>I am receiving a list of ID's. Most of these already exist in a table. I need to find which ID's are NOT in the table. This question has nothing to do with joins.</p>
  <p>My API will receive a list of IDs, such as: [1, 2, 3, 4, 5]</p>
  <p>Let's say there are three records in the table: [2, 3, 4]</p>
  <p>The result I'm looking for is the array: [1, 5]</p>
  <p>Our SQL brains jump quickly to something like the following, but clearly that's not what we need:</p>
  <pre><code>select * from widgets where id not in [list]
  </code></pre>
  <p>We don't need the records not in the list, we need the part of the list not in the records!</p>
  <p>My fallback is to retrieve all records in the list and subtract from the list, something like this:</p>
  <pre><code>existing_ids = Widget.where(id: id_list).pluck(:id)
  new_ids = id_list - existing_ids
  </code></pre>
  <p>That will work...but feels heavy-handed. Particularly if id_list has 100,000 records, and the table has 99,999 of those records.</p>
  <p>I've searched around, and the only similar result is <a href="https://stackoverflow.com/questions/30430219/id-from-list-that-is-not-in-a-table">ID from list that is not in a table</a> ... which did not find a viable solution.</p>
  <p>Is there any way to do this in a single SQL query? (Bonus points for an ActiveRecord solution!)</p>