Re: Massive slowdown when LIMIT applied - Mailing list pgsql-general

From Tom Lane
Subject Re: Massive slowdown when LIMIT applied
Date
Msg-id 19785.1155738181@sss.pgh.pa.us
Whole thread Raw
In response to Massive slowdown when LIMIT applied  (Graeme Hinchliffe <graeme.hinchliffe@zeninternet.co.uk>)
List pgsql-general
Graeme Hinchliffe <graeme.hinchliffe@zeninternet.co.uk> writes:
> If I do the following:

> SELECT username,acctstarttime FROM radacct WHERE username='user'
> ORDER BY acctstarttime;

> again the results come up slightly slower as would be expected but
> still very quickly.. (a few hundred rows in this case)

> Now, if I do the following:

> SELECT username,acctstarttime FROM radacct WHERE username='user'
> ORDER BY acctstarttime LIMIT 50;

> I have to wait a very long time, IE instead of 2-3 seconds.. can be
> as slow as 10+ minutes.

Have you compared EXPLAIN ANALYZE outputs for the two cases?  Presumably
the planner is picking a different plan for the LIMIT case (and guessing
wrong :-()

            regards, tom lane

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Timezones -- what comes out does not go in?
Next
From: Tom Lane
Date:
Subject: Re: Segmentation Fault