From: Daniel Verite <daniel@manitou-mail.org>
To: "Thorsten Schöning" <tschoening@am-soft.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Concurrenctly running CREATE TEMP TABLE IF NOT EXISTS [...] AS [...]
Date: Mon, 08 Jun 2020 11:05:02 +0200
Message-ID: <3ab95c06-a632-4601-8ccc-2f285a587f09@manitou-mail.org> (raw)
In-Reply-To: <1102807465.20200608101409@am-soft.de>
Thorsten Schöning wrote:
> I'm using "CREATE TEMP TABLE IF NOT EXISTS [...] AS [...]" and the
> associated queries can take a long time. So the following lists some
> questions about executing those concurrently, even thouzgh I've
> already read threads like the following:
> > The bottom line is that CREATE TABLE IF NOT EXISTS doesn't pretend
> > to handle concurrency issues any better than regular old CREATE
> > TABLE, which is to say not very well.[...]
>
> https://www.postgresql.org/message-id/CA+TgmoZAdYVtwBfp1FL2sMZbiHCWT4UPrzRLNnX1Nb30Ku3-gg@mail.gmail...
The caveat you mention about IF NOT EXISTS does not apply to
temporary tables, as they're not shared across sessions.
That is, if two concurrent transactions execute at the same time
CREATE TEMP TABLE IF NOT EXISTS foo(...)
it can't fail as described above because that creates two distinct tables,
each private to their session.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: https://www.manitou-mail.org
Twitter: @DanielVerite
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: daniel@manitou-mail.org, tschoening@am-soft.de
Subject: Re: Concurrenctly running CREATE TEMP TABLE IF NOT EXISTS [...] AS [...]
In-Reply-To: <3ab95c06-a632-4601-8ccc-2f285a587f09@manitou-mail.org>
References: <1102807465.20200608101409@am-soft.de> <3ab95c06-a632-4601-8ccc-2f285a587f09@manitou-mail.org>
* 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