title: How can I make large IN clauses more efficient in SQL Server?
body: <p>My current query runs very slow when accessing a DB with pretty large tables</p>
  
  <pre><code>SELECT * 
  FROM table1
  WHERE timestamp BETWEEN 635433140000000000 AND 635433150000000000
    AND ID IN ('element1', 'element2', 'element3', ... , 'element 3002');
  </code></pre>
  
  <p>As you can see the <code>IN</code> clause has several thousand values. This query is executed roughly every second. </p>
  
  <p>Is there another way to write it to improve performance?</p>