Re: Prepared statements and suboptimal plans - Mailing list pgsql-performance

From Stephen Frost
Subject Re: Prepared statements and suboptimal plans
Date
Msg-id 20110921023615.GV12765@tamriel.snowman.net
Whole thread Raw
In response to Re: Prepared statements and suboptimal plans  (Royce Ausburn <royce.ml@inomial.com>)
List pgsql-performance
* Royce Ausburn (royce.ml@inomial.com) wrote:
> > Tom just mentioned that 9.1 will be able to re-plan parameterized prepared statements, so this issue will go away.
Inthe mean time you can only really use the standard workaround of setting the prepare theshold to 0 to disable
server-sideprepare, so you can continue to use JDBC prepared statements and have the driver do the parameter
substitutionfor you. 
>
> Thanks Craig -- that trick helps a lot.

You might also be able to bump up work_mem by a fair bit to get PG to
use a hashagg instead of groupagg/sort, even though its estimate is way
off.  That's what I've done in the past for similar situations and it's
worked well.  I'd recommend increasing it for just this query and then
resetting it (assuming you don't just drop the connection, in which case
you don't need to reset it since a new connection will get the default).

    Thanks,

        Stephen

Attachment

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Prepared statements and suboptimal plans
Next
From: Stephen Frost
Date:
Subject: Re: Prepared statements and suboptimal plans