Re: strange query plan with LIMIT - Mailing list pgsql-performance

From Pavel Stehule
Subject Re: strange query plan with LIMIT
Date
Msg-id BANLkTi=iPiHELpnikeNM070+qyZVyiqbbw@mail.gmail.com
Whole thread Raw
In response to Re: strange query plan with LIMIT  (anthony.shipman@symstream.com)
List pgsql-performance
Hello

2011/6/8  <anthony.shipman@symstream.com>:
> On Wednesday 08 June 2011 18:39, Pavel Stehule wrote:
>> if you use FOR statement, there should be a problem in using a
>> implicit cursor - try to set a GUC cursor_tuple_fraction to 1.0.
> Alas this is mammoth replicator, equivalent to PG 8.3 and it doesn't have that
> parameter.

It should be a part of problem - resp. combination with bad statistic.
Maybe you should to rewrite your code to

DECLARE int i = 0;

FOR x IN EXECUTE '....'
LOOP
  RETURN NEXT ...
  i := i + 1;
  EXIT WHEN i > limitvar
END LOOP

Regards

Pavel Stehule



> --
> Anthony Shipman                 | It's caches all the way
> Anthony.Shipman@symstream.com   | down.
>

pgsql-performance by date:

Previous
From: tv@fuzzy.cz
Date:
Subject: Re: strange query plan with LIMIT
Next
From: tv@fuzzy.cz
Date:
Subject: Re: Set of related slow queries