Re: Index Scan Backward Slow - Mailing list pgsql-performance

From Robert Klemme
Subject Re: Index Scan Backward Slow
Date
Msg-id mi2319$4ed$1@ger.gmane.org
Whole thread Raw
In response to Re: Index Scan Backward Slow  (David Osborne <david@qcode.co.uk>)
List pgsql-performance
On 01.05.2015 13:06, David Osborne wrote:
> Simple... that did it... thanks!
>
> dev=> create index on table(code,row_id);
> CREATE INDEX
> Time: 38088.482 ms
> dev=> explain (analyse,buffers)  select row_id as last_row_id from table
> where code='XX' order by row_id desc limit 1;

Just out of curiosity: Is there a particular reason why you do not use

select max(row_id) as last_row_id
from table
where code='XX'

?

Kind regards

    robert


pgsql-performance by date:

Previous
From: David Osborne
Date:
Subject: Re: Index Scan Backward Slow
Next
From: Anton Bushmelev
Date:
Subject: optimization join on random value