title: SQLite: fastest way to check if a table has more than x rows
body: <p>What is the fastest way to check if a SQLite table has more than 100,000 rows?</p>
  
  <hr>
  
  <p>The test table has 26 columns and 200,000,000 rows.</p>
  
  <pre><code>SELECT COUNT(*) FROM ( SELECT * FROM table LIMIT 100001 )
  </code></pre>
  
  <p>took 0.27 seconds.</p>
  
  <p>The following three needed 12 and a half minutes</p>
  
  <pre><code>SELECT COUNT(*) FROM table
  SELECT COUNT(*) FROM table LIMIT 100001
  SELECT CASE WHEN COUNT(Id) &gt;= 100000 THEN 1 ELSE 0 END FROM table
  </code></pre>