title: Indexed ORDER BY with LIMIT 1
body: <p>I'm trying to fetch most recent row in a table. I have a simple timestamp <code>created_at</code> which is indexed. When I query <code>ORDER BY created_at DESC LIMIT 1</code>, it takes far more than I think it should (about 50ms on my machine on 36k rows).</p>
  
  <p><em>EXPLAIN</em>-ing claims that it uses <em>backwards index scan</em>, but I confirmed that changing the index to be <code>(created_at DESC)</code> does not change the cost in query planner for a simple <em>index scan</em>.</p>
  
  <p>How can I optimize this use case?</p>
  
  <p>Running postgresql <code>9.2.4</code>.</p>
  
  <h3>Edit:</h3>
  
  <pre><code># EXPLAIN SELECT * FROM articles ORDER BY created_at DESC LIMIT 1;
                                                    QUERY PLAN                                                       
  -----------------------------------------------------------------------------------------------------------------------
  Limit  (cost=0.00..0.58 rows=1 width=1752)
     -&gt;  Index Scan Backward using index_articles_on_created_at on articles  (cost=0.00..20667.37 rows=35696 width=1752)
  (2 rows)
  </code></pre>