Re: Limit clause not using index - Mailing list pgsql-performance

From Tom Lane
Subject Re: Limit clause not using index
Date
Msg-id 3415.1119364973@sss.pgh.pa.us
Whole thread Raw
In response to Limit clause not using index  (Yves Vindevogel <yves.vindevogel@implements.be>)
Responses Re: Limit clause not using index
List pgsql-performance
Yves Vindevogel <yves.vindevogel@implements.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

pgsql-performance by date:

Previous
From: John A Meinel
Date:
Subject: Re: Limit clause not using index
Next
From: Matthew Nuzum
Date:
Subject: Re: Do Views execute underlying query everytime ??