pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rainer Pruy <Rainer.Pruy@Acrys.COM>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Query slowing down significantly??
Date: Mon, 01 Mar 2010 13:15:00 -0500
Message-ID: <20628.1267467300@sss.pgh.pa.us> (raw)
In-Reply-To: <4B8BFDEF.1080006@acrys.com>
References: <4B8BB815.4060104@acrys.com>
	<17910.1267460132@sss.pgh.pa.us>
	<4B8BFDEF.1080006@acrys.com>

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



view thread (7+ messages)  latest in thread

Message-ID: <20628.1267467300@sss.pgh.pa.us>
Permalink:  ../20628.1267467300@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20628.1267467300@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Rainer.Pruy@Acrys.COM
  Subject: Re: Query slowing down significantly??
  In-Reply-To: <20628.1267467300@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox