Re: Index Scan Backward Slow

From: Robert Klemme <shortcutter(at)googlemail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Index Scan Backward Slow
Date: 2015-05-02 08:48:40
Message-ID: mi2319$4ed$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Anton Bushmelev 2015-05-03 21:23:28 optimization join on random value
Previous Message Robert Haas 2015-05-01 11:55:49 Re: PATCH: adaptive ndistinct estimator v4