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 1jiHvi-0002dH-HT for pgsql-general@arkaria.postgresql.org; Mon, 08 Jun 2020 13:35:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jiHvh-0006vQ-G2 for pgsql-general@arkaria.postgresql.org; Mon, 08 Jun 2020 13:35:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiHvh-0006vJ-58 for pgsql-general@lists.postgresql.org; Mon, 08 Jun 2020 13:35:09 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jiHvf-0001gG-2S for pgsql-general@lists.postgresql.org; Mon, 08 Jun 2020 13:35:08 +0000 Received: by mail-oi1-x229.google.com with SMTP id b8so15316159oic.1 for ; Mon, 08 Jun 2020 06:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=m36rSNJaJx89SXsBNj/Hv+i3TueQxYVdcFVddFaUaU8=; b=rkYpOYyFT4FXPb+4uawZ04njZ3GbLmN/Q2WnC8D1WwmL0sJODkhfNsSvTn+Al9/kED Xd/F7ZfXfDqX9caSLDqXj83lfYb7sSGR0zAIAqsx0ufjpMYFmNuAKcT++rPCeCqiJj8j amX1RoUBj0ui6OJB5P85G69r7Jfvd8CL52t08rl7TwHoTftXkLsdsYWwlPUU3sImTWDg Ul/JQTbr6c/umxPpBRiBnRkZRhIREfAKuDej8mLAB3Mb4vhuXkY9ksbRBu5gsqWihTOe +aFiHZwjnDrzRgrMNqEg4NqIMKY0zF9ICkNzSAjQtxaoTR8MYOUuNSGJs2nTN8u9HQNL HDmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=m36rSNJaJx89SXsBNj/Hv+i3TueQxYVdcFVddFaUaU8=; b=EV9PtTUryUR3zCCLgitkfMdmgf8TRboyuORvVht6QACYjjFbtj3eS+ElTul+/nYRvU GNJVw2rMtZSNQXNH5D7Z/5n/7OHcg8nzc88YLKy+xafU5SYVHRPfS8b7R2H6PrQCZ1LX 0wfZKKr1xqVD/cdMesX6WQyMTSoRgNBlN9EzkXoPN6vpLckT+3+wFGr/08l2OxRqEoIs mFCLFgfebHjRMJ0tYdFTUVboqFHIVowptK4BxKbJ0yx4TNHcH3176sOKEXj3c9E1iG2I R3KvCDgeaAtB9TsE/U+Kj64QzdOCBooLE5L5DqEExge6aV9eLu8AAvmCoZiJCRrpib6j 0hIw== X-Gm-Message-State: AOAM531JhegUm9+bZ+Gy8oRqIzYaqAiLuthNp58FM/0WVKXnRTnUZuML fqUeVq5FR9KBr4VhytODeDderELxkX+fYg== X-Google-Smtp-Source: ABdhPJwku8s4G/CTwkumy+wC8W6TkCKymizEvN+KBnTNr9ukNeQzVpXjrIX7CinHxZHXJBBp7l1UWQ== X-Received: by 2002:aca:abd3:: with SMTP id u202mr10150360oie.76.1591623306061; Mon, 08 Jun 2020 06:35:06 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id s18sm2409987oie.36.2020.06.08.06.35.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Jun 2020 06:35:05 -0700 (PDT) Subject: Re: Concurrenctly running CREATE TEMP TABLE IF NOT EXISTS [...] AS [...] To: pgsql-general@lists.postgresql.org References: <1102807465.20200608101409@am-soft.de> From: Ron Message-ID: <5fd32bf1-164c-742f-9e46-7c9cc547a0e1@gmail.com> Date: Mon, 8 Jun 2020 08:35:04 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1102807465.20200608101409@am-soft.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/8/20 3:14 AM, Thorsten Schöning wrote: > Hi all, > > I have an app exposing web services to generate reports. Those web > services accept multiple reports per request and calculate them > concurrently. There's one transaction spanning each entire request and > used by ALL spawned threads. The app makes sure that e.g. committing > transactions is handled by ONE thread only and individual statements > are NEVER reused by multiple threads. > > There are two types of reports: Some need to read data from the DB > themself, others can work on the data provided by the former ones. The > current implementation always creates temporary tables for results of > some query, so that one can simply check if some temporary table is > available and either only query that or create it before as necessary. > > I'm using "CREATE TEMP TABLE IF NOT EXISTS [...] AS [...]" and the > associated queries can take a long time. Would a set of GLOBAL temporary tables be a better fit for your problem (eliminating the need to create temporary tables each time)? -- Angular momentum makes the world go 'round.