Re: Limit clause not using index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yves Vindevogel <yves(dot)vindevogel(at)implements(dot)be>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Limit clause not using index
Date: 2005-06-21 14:42:53
Message-ID: 3415.1119364973@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Yves Vindevogel <yves(dot)vindevogel(at)implements(dot)be> writes:
> Can anyone explain me this ?

> rvponp=# explain select * from tblprintjobs order by loginuser,
> desceventdate, desceventtime offset 25 limit 25 ;
> QUERY PLAN
> ------------------------------------------------------------------------
> -----------
> Limit (cost=349860.62..349860.68 rows=25 width=206)
> -> Sort (cost=349860.56..351416.15 rows=622236 width=206)
> Sort Key: loginuser, desceventdate, desceventtime
> -> Seq Scan on tblprintjobs (cost=0.00..25589.36 rows=622236 width=206)
> (4 rows)

Do you have an index matching that sort key? I'd certainly expect the
above to use it if it were there. For the full table case it's not so
clear --- an indexscan isn't always better.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Matthew Nuzum 2005-06-21 14:45:21 Re: Do Views execute underlying query everytime ??
Previous Message John A Meinel 2005-06-21 14:42:36 Re: Limit clause not using index