Re: LIMIT causes huge slow down

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: LIMIT causes huge slow down
Date: 2014-03-12 16:34:31
Message-ID: 1394642071713-5795717.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Harry Rossignol wrote
> hello
>
> i am just a lowly application developer, but i always include my 'where'
> fields in my order by specification.
> I.E. ORDER BY id_webzine,id_flickr,id_picasa,id_photo rather then just
> id_photo

You really should consider thinking about what you need rather than blindly
adhering to a rule that puts additional burden on the system when it may not
be necessary.

WRT to question posed: probably the easiest workaround is to move the
unlimited query to a WITH clause and then apply the limit separately.

You should indicate what version of PostgreSQL you are using.

Sorry I'm not much help on the how and why of the actual plan choices here.
The sorting is constant but since the limit and the where clause target
different tables a full evaluation is needed to determine a solution so
picking individual rows, which is what I see happening, doesn't by you
anything.

But, for all I know your using an old version and this undesirable behavior
has already been found and fixed.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/LIMIT-causes-huge-slow-down-tp5795640p5795717.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-03-12 18:49:13 Re: BUG #9548: jpg error 53 when trying to view jpg stored in blob field
Previous Message Rainer Tammer 2014-03-12 16:28:54 Re: Problem with PostgreSQL 9.2.7 and make check on AIX 7.1