title: OFFSET vs. ROW_NUMBER()
body: <p>As we know, Postgresql's OFFSET requires that it scan through all the rows up until the point it gets to where you requested, which makes it kind of useless for pagination through huge result sets, getting slower and slower as the OFFSET goes up.</p>
  
  <p>PG 8.4 now supports window functions.   Instead of:</p>
  
  <pre><code>SELECT * FROM table ORDER BY somecol LIMIT 10 OFFSET 500
  </code></pre>
  
  <p>You can say:</p>
  
  <pre><code>SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY somecol ASC) AS rownum FROM table) AS foo
  WHERE rownum &gt; 500 AND rownum &lt;= 510
  </code></pre>
  
  <p>Does the latter approach help us at all ?   Or do we have to keep using identifying columns and temp tables for large pagination ?</p>