Re: NOT EXIST for PREPARE

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Yury Zhuravlev <u(dot)zhuravlev(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tatsuo Ishii <ishii(at)postgresql(dot)org>
Subject: Re: NOT EXIST for PREPARE
Date: 2016-03-23 18:01:25
Message-ID: CAHyXU0xXNE85a__b9y2McFkBNQtFLXbSuwiTAA-cBhPNN31Rcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 23, 2016 at 12:46 PM, Vladimir Sitnikov
<sitnikov(dot)vladimir(at)gmail(dot)com> wrote:
> 2016-03-23 16:21 GMT+03:00 Merlin Moncure <mmoncure(at)gmail(dot)com>:
> Merlin> A typical pattern is for the application to
> Merlin> prepare them all upon startup, but currently each PREPARE needs to be
> Merlin> wrapped with an exception handler in case someone else prepared it
> Merlin> first.
>
> If you plan to have "prepare if not exists" at startup only, why don't
> you just wrap it with
> exception handler then?

That's impolite to our users. Virtually all other commands have been
decorated with IF [NOT] exists to avoid having to guard with exception
handler -- why not this one? Also, if the handler is on the client
side, it tends to be racey.

> If you plan to always issue "prepare if not exists", then you will
> have to send full query text
> for each prepare => overhead. Those repeated query texts are
> "endless copies of the same PREPARE statements" Craig is talking about.

No one is arguing that that you should send it any every time (at
least -- I hope not).

> Merlin>The client prepares the statement exactly
> Merlin>once. The problem is there's no easy way to determine if someone else
> Merlin>prepared it first
>
> Merlin, if by "client" you somehow mean JDBC (e.g. pgjdbc), then it
> does track which connections
> have which queries prepared.

Again, not in pooling scenarios. The problems integrating server side
prepared statements with pgbouncer are well known.

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2016-03-23 18:02:32 Re: Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5)
Previous Message Peter Geoghegan 2016-03-23 18:00:07 Re: Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5)