Re: select vs cursor/fetch speed disparity

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: select vs cursor/fetch speed disparity
Date: 2011-10-10 20:10:33
Message-ID: 4E935139.6080906@boscorama.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bosco Rama wrote:
> Tom Lane wrote:
>>
>> Cursors are biased towards fast-start plans on the theory that you
>> may not be intending to fetch the whole result. Queries with ORDER BY
>> and/or LIMIT are particularly likely to see plan changes as a
>> consequence of that. In 8.4 and up you can frob the
>> cursor_tuple_fraction setting to adjust this preference. Use
>> "EXPLAIN query" vs "EXPLAIN DECLARE CURSOR FOR query" to see what
>> sort of plan you're getting.
>
> I'll take a look at that setting and try the two 'explain's. However,
> would that really account for an increase in time by a factor of ~630?
> Just wondering.

Apparently it does. Setting cursor_tuple_fraction to 1.0 alleviates
the problem in my test system (need end of day before I can test it in
the production system). Thanks for the hint Tom.

I guess my question now is: Why does it affect this query so badly?
This is the only one that has exhibited such behavior (... so far).

Also, is it a bad thing to set that value to 1.0 as the DB-wide setting?
Not understanding the internals that well I'm not too sure what exactly
is happening when I fool with this value. I assume you guys set the
default to 0.1 based on some sort of generalized testing during the
development/testing phase(s).

> (BTW, I'm still working on a public version of the data & schema that
> reproduce this.)

I now have a small(er) sanitized example that shows this problem with
a slow-down factor of 100 (rather than the factor of 630 I had before).
Is it of any interest or is the above GUC setting all we care about?

Bosco.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2011-10-10 21:02:04 Re: a dumb question regarding RULES
Previous Message Christophe Pettus 2011-10-10 20:01:22 Logging queries cancelled due to replication timeouts