Daniel Burbridge <Daniel.Burbridge@publishingtechnology.com> writes:
> I have a problem with prepared statements choosing a bad query plan - I was hoping that 9.2 would have eradicated the
problem:(
9.2 will only pick the "right" plan if that plan's estimated cost is a
good bit cheaper than the "wrong" parameterized plan. In this case,
not only is there not a lot of difference, but the difference is in the
wrong direction. You need to fix that --- perhaps increasing stats
targets would help?
A more radical question is whether you have a well-chosen set of indexes
in the first place. These two seem a bit odd, and certainly not
terribly well matched to this query.
regards, tom lane