Re: Query slowing down significantly?? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Query slowing down significantly??
Date
Msg-id 20628.1267467300@sss.pgh.pa.us
Whole thread Raw
In response to Re: Query slowing down significantly??  (Rainer Pruy <Rainer.Pruy@Acrys.COM>)
Responses Re: Query slowing down significantly??  (Rainer Pruy <Rainer.Pruy@Acrys.COM>)
List pgsql-performance
Rainer Pruy <Rainer.Pruy@Acrys.COM> writes:
> The prepared statement gives:
> ...
> And that is quite a bad plan given the current distribution of values.

Yeah.  The planner really needs to know the actual parameter values in
order to pick the best plan for this case.

One thing that you might be able to do to avoid giving up on prepared
statements entirely is to use an "unnamed" rather than named prepared
statement here.  That will lead to the query plan being prepared only
when the parameter values are made available, rather than in advance.
It'd depend on what client library you're using whether this is a simple
change or not.

            regards, tom lane

pgsql-performance by date:

Previous
From: Rainer Pruy
Date:
Subject: Re: Query slowing down significantly??
Next
From: Rainer Pruy
Date:
Subject: Re: Query slowing down significantly??