Re: Bad prepare performance - Mailing list pgsql-performance

From Cédric Villemain
Subject Re: Bad prepare performance
Date
Msg-id 200804010953.42063.cedric.villemain@dalibo.com
Whole thread Raw
In response to Bad prepare performance  (Martin Kjeldsen <martin@martinkjeldsen.dk>)
List pgsql-performance
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

Attachment

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: POSIX file updates
Next
From: "Sabin Coanda"
Date:
Subject: check performance parameters