pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Cédric Villemain <cedric.villemain@dalibo.com>
To: Martin Kjeldsen <martin@martinkjeldsen.dk>
Cc: pgsql-performance@postgresql.org
Subject: Re: Bad prepare performance
Date: Tue, 1 Apr 2008 09:53:36 +0200
Message-ID: <200804010953.42063.cedric.villemain@dalibo.com> (raw)

Hi Martin, please CC the mailing-list, 
then others can repply ;)

Cédric Villemain (13:59 2008-03-31):
> Le Monday 31 March 2008, Martin Kjeldsen a écrit :
> > I've done the same query on a 8.2.5 database. The first one is prepared
> > first and the other is executed directly.
> >
> > I understand why the there is such a great difference between the two ways
> > of executing the query (postgres has no way of knowing that $1 will be
> > quite big and that the result is not too big).
> >
> > I could just avoid using prepare statements, but this is done 
automatically
> > with Perl's DBD::Pg. I know how to avoid using prepare statements (avoid
> > having placeholders in the statement), but that is not the prettiest of
> > work arounds. 
> 
> Did you saw this option :
> 
>   $sth = $dbh->prepare("SELECT id FROM mytable WHERE val = ?",
>                        { pg_server_prepare => 0 });
> 
> Then, *this* query will not be prepared by the server.

This works very well. Thanks!

Still I regard this as a work around and the optimal solution would be to 
allow the prepare statement to be prepared with an max(guid) is close to $1 
hint or something like that. 

I heard something about delayed prepare, where the prepared statements is 
prepared on first use, this would solve my problem. Is this something being 
work on right now?

Best regards


Martin Kjeldsen

Attachments:

  signature.asc (application/pgp-signature, 188B) download

view thread (3+ messages)

Message-ID: <200804010953.42063.cedric.villemain@dalibo.com>
Permalink:  ../200804010953.42063.cedric.villemain@dalibo.com/
Also on:    postgresql.org/message-id/200804010953.42063.cedric.villemain@dalibo.com

 · 

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: cedric.villemain@dalibo.com, martin@martinkjeldsen.dk
  Subject: Re: Bad prepare performance
  In-Reply-To: <200804010953.42063.cedric.villemain@dalibo.com>

* 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