Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oesMd-0005CI-8g for pgsql-general@arkaria.postgresql.org; Sun, 02 Oct 2022 06:22:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oesMb-0006QM-Af for pgsql-general@arkaria.postgresql.org; Sun, 02 Oct 2022 06:22:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oesMa-0006NM-V7 for pgsql-general@lists.postgresql.org; Sun, 02 Oct 2022 06:22:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oesMW-0002bq-FC for pgsql-general@lists.postgresql.org; Sun, 02 Oct 2022 06:22:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2926Lv8n1072027; Sun, 2 Oct 2022 02:21:57 -0400 From: Tom Lane To: Bryn Llewellyn cc: "Peter J. Holzer" , pgsql-general list 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: <324B41E9-5A21-4C56-AA6E-6407A56CBAE0@yugabyte.com> References: <20220928011353.zo7enlnig5vvpowe@jrouhaud> <5B23D9B8-56E8-458F-AD3D-B5F88AAB2844@yugabyte.com> <20220928025427.coznr3we5plyq5pp@jrouhaud> <3881881.1664337639@sss.pgh.pa.us> <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> Comments: In-reply-to Bryn Llewellyn message dated "Sat, 01 Oct 2022 22:33:57 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1072025.1664691717.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 02 Oct 2022 02:21:57 -0400 Message-ID: <1072026.1664691717@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn 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 fel= t 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=E2=80=A6 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