Re: NOT EXIST for PREPARE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, 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:05:59
Message-ID: 11898.1458756359@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com> writes:
> 2016-03-23 16:21 GMT+03:00 Merlin Moncure <mmoncure(at)gmail(dot)com>:
>> On Wed, Mar 23, 2016 at 7:27 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> Craig>> With PREPARE IF NOT EXISTS the client is also paying parse and network
> Craig>> overhead for every time you send that statement. Much better
> Craig>> not to send it repeatedly in the first place.

> Merlin> How did you determine that? 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 and this patch directly addresses that.

> With suggested "prepare if not exists", client would still have to send full
> query text along with "prepare if not exist" command.
> That is "network overhead".

Yes. Also, the query would certainly go through the lex and raw-parse
steps (scan.l and gram.y) on the database side before we could get as far
as realizing that it's a PREPARE IF NOT EXISTS and we should check for
pre-existence of the statement name. Those steps are a nontrivial
fraction of the full parse-analysis overhead, especially for simpler
statements.

So I wouldn't take it as a given that this is actually going to be
very efficient. Some measurements would be important to make the case
that this is worth having.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2016-03-23 18:06:47 Re: Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5)
Previous Message Magnus Hagander 2016-03-23 18:04:44 Re: Re: Missing rows with index scan when collation is not "C" (PostgreSQL 9.5)