pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Names of run-time configuration parameters (was: Limiting the operations that client-side code can perform upon its database backend's artifacts)
Date: Sun, 02 Oct 2022 02:21:57 -0400
Message-ID: <1072026.1664691717@sss.pgh.pa.us> (raw)
In-Reply-To: <324B41E9-5A21-4C56-AA6E-6407A56CBAE0@yugabyte.com>
References: <20220928011353.zo7enlnig5vvpowe@jrouhaud>
	<5B23D9B8-56E8-458F-AD3D-B5F88AAB2844@yugabyte.com>
	<20220928025427.coznr3we5plyq5pp@jrouhaud>
	<C1704EC1-487A-4BB0-8301-2530E97F04AA@yugabyte.com>
	<3881881.1664337639@sss.pgh.pa.us>
	<F0A23614-749D-4A89-84C5-119D4000F9FE@yugabyte.com>
	<20220930184515.mw2avsox5daz6yok@hjp.at>
	<35254B0B-6501-4CF6-A13F-76D03756C2B2@yugabyte.com>
	<20221001120553.b7z7pujnmsllgn5b@hjp.at>
	<20221001122421.ja2vri66mvyrg5hm@jrouhaud>
	<20221001124229.4a3q4peqzynz6cd6@hjp.at>
	<936582.1664640735@sss.pgh.pa.us>
	<97B46A72-70A3-43E6-8F8A-7B50A16C0A97@yugabyte.com>
	<962011.1664651980@sss.pgh.pa.us>
	<324B41E9-5A21-4C56-AA6E-6407A56CBAE0@yugabyte.com>

Bryn Llewellyn <bryn@yugabyte.com> writes:
> I've seen this pattern in use:

>   create temp table if not exists pg_temp.flag(val boolean not null) on commit delete rows;
>   insert into pg_temp.flag(val) values(true);

> But doing a DDL before every use of the session-state representation felt heavier than assuming that it's there and creating the table only if it isn't. But I haven't done any timing tests. Is the "create… if not exists" so lightweight when the to-be-created object does exist that I'm fussing over nothing?

Fair question.  My gut feeling is that the subtransaction created by the
BEGIN ... EXCEPTION construct is more expensive than a no-op CREATE
IF NOT EXISTS.  I've not measured it though; and I'm pretty sure that
the answer would vary depending on how often you expect the code to fall
through versus needing to create the table.

			regards, tom lane





view thread (8+ messages)

Message-ID: <1072026.1664691717@sss.pgh.pa.us>
Permalink:  ../1072026.1664691717@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1072026.1664691717@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bryn@yugabyte.com, hjp-pgsql@hjp.at
  Subject: Re: Names of run-time configuration parameters (was: Limiting the operations that client-side code can perform upon its database backend's artifacts)
  In-Reply-To: <1072026.1664691717@sss.pgh.pa.us>
  References: <20220928011353.zo7enlnig5vvpowe@jrouhaud> <5B23D9B8-56E8-458F-AD3D-B5F88AAB2844@yugabyte.com> <20220928025427.coznr3we5plyq5pp@jrouhaud> <C1704EC1-487A-4BB0-8301-2530E97F04AA@yugabyte.com> <3881881.1664337639@sss.pgh.pa.us> <F0A23614-749D-4A89-84C5-119D4000F9FE@yugabyte.com> <20220930184515.mw2avsox5daz6yok@hjp.at> <35254B0B-6501-4CF6-A13F-76D03756C2B2@yugabyte.com> <20221001120553.b7z7pujnmsllgn5b@hjp.at> <20221001122421.ja2vri66mvyrg5hm@jrouhaud> <20221001124229.4a3q4peqzynz6cd6@hjp.at> <936582.1664640735@sss.pgh.pa.us> <97B46A72-70A3-43E6-8F8A-7B50A16C0A97@yugabyte.com> <962011.1664651980@sss.pgh.pa.us> <324B41E9-5A21-4C56-AA6E-6407A56CBAE0@yugabyte.com> <1072026.1664691717@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