Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyXfd-000083-Ce for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Aug 2019 08:33:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hyXfc-0000UO-6U for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Aug 2019 08:33:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyXfb-0000NA-OS for pgsql-hackers@lists.postgresql.org; Fri, 16 Aug 2019 08:33:11 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyXfY-0007MB-LS for pgsql-hackers@postgresql.org; Fri, 16 Aug 2019 08:33:11 +0000 Received: by mail-lj1-x235.google.com with SMTP id f9so4538541ljc.13 for ; Fri, 16 Aug 2019 01:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kajkdFd5rCww0reeP5NciqGFwHQZCBU5i3/cMMvMOk4=; b=Qgo9uIabaC0M1fS3MjIYyfXpt4KcHMTF5d/un6xyj+RzMjFlBAWzV2/uIf+d6Gwv1a 2A69mh+d3QEvGxFNUDgX/lwVuDdvUvwft/w8VffimZtKR+5NrlUlopHwwib0bQt/xo4u a+kbN3JZNV/bA/NsZHimA2A3utVt7L9p8L24bFstCDdahCkv9Ln+EKKJEaOcgHSrGGZL ZUAwi5av6nbMK2v0YT/hAzzfWZy4QFVIhIBcCquoPHUV7vaeYnd/zGw+B8CyzPHGDtoV Fpk4dnXKV4dkIlsfHIHJ33kE9gru+Wd73x4+cTJV1GX4XCISEqpIZHxWmDjkJwH2LCpg dSPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kajkdFd5rCww0reeP5NciqGFwHQZCBU5i3/cMMvMOk4=; b=fCl40lytvZlStfdx6FzLTl8NkjRzFHfzHoTUt/gPnskCr1euUqTaZySrsj4Xl45zIt JAwRItyp6sjMMXBzrBdJjqC7yQyifI7VCRj6tgGX2MqJbX6r5KsTa4E0UrbKf5ZVcfiV 8u05sAOiCnkLFqVZJer1YoMFB43gPOhwtF3cGjaSvgFCMEecCiR850z3bPslcnu5/Zua p43qiZEnCbjvgUwSk4LAjVeRyNkipGJIH2bEh50oRgL+GMZJSzgTPSnHIkp/hTtp+8rs a7/zmsEFrjaMPzLV93VbX8v5kcPPhvV/DorYSvP4HX95YYmHZwnmG9vCmYAvrg+FWNOd 8u+g== X-Gm-Message-State: APjAAAVyH413U/li1SJHEUawszYkzKBjn/nOecPbNXmQZz37cUnyOkmS hJbAHenzEZKGOQqJnVfegm1Dmw6L/gwe+coYoHocbA== X-Google-Smtp-Source: APXvYqzEmk5o0B7pM9cWpv+BA05+YmV5kkEUgO71L3UYCZfxbBy4Txt3RlpoTODjr9weh2kX2ctswGa80+j1EROFyLk= X-Received: by 2002:a2e:91c6:: with SMTP id u6mr4750518ljg.68.1565944384424; Fri, 16 Aug 2019 01:33:04 -0700 (PDT) MIME-Version: 1.0 References: <73954ab7-44d3-b37b-81a3-69bdcbb446f7@postgrespro.ru> <8e0b539b-4b64-d2b2-08a1-ddaa3c7e7747@postgrespro.ru> <8b4bdfa6-7a90-95e2-1fd0-243767e5b357@postgrespro.ru> <94a19e7b-d99a-110c-8e5b-f5068682b474@postgrespro.ru> <614c1e9f-c0e6-332c-ba2b-85a7e1efb956@postgrespro.ru> <5a711f75-e999-a809-60e1-c74c8c9e7915@postgrespro.ru> <21f047d6-bb2d-950c-2aff-2fee301d5851@postgrespro.ru> <91de2094-165a-04f1-9b3d-348473394345@postgrespro.ru> In-Reply-To: From: Craig Ringer Date: Fri, 16 Aug 2019 16:32:52 +0800 Message-ID: Subject: Re: Global temporary tables To: Konstantin Knizhnik Cc: Pavel Stehule , PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000c5a442059037d61d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000c5a442059037d61d Content-Type: text/plain; charset="UTF-8" On Fri, 16 Aug 2019 at 15:30, Konstantin Knizhnik wrote: > > 1. Statistic for global temporary tables (including number of tuples, > pages and all visible flag). > My position is the following: while in most cases it should not be a > problem, because users rarely create indexes or do analyze for temporary > tables, > there can be situations when differences in data sets of global temporary > tables in different backends can really be a problem. > Unfortunately I can not propose good solution for this problem. It is > certainly possible to create some private (per-backend) cache for this > metadata. > But it seems to requires changes in many places. > Yeah. I don't really like just sharing them but it's not that bad either. > 2. Your concerns about performance penalty of global temp tables accessed > through shared buffers comparing with local temp tables access through > local buffers. > I think that this concern is not actual any more because there is > implementation of global temp tables using local buffers. > But my experiments doesn't show significant difference in access speed of > shared and local buffers. As far as shared buffers are used to be much > larger than local buffers, > there are more chances to hold all temp relation in memory without > spilling it to the disk. In this case access to global temp table will be > much faster comparing with access to > local temp tables. > You ignore the costs of evicting non-temporary data from shared_buffers, i.e. contention for space. Also increased chance of backends being forced to do direct write-out due to lack of s_b space for dirty buffers. > In case of pulling all content of temp table in memory (pg_prewarm) global temp table with shared buffers becomes faster. Who would ever do that? I forget or do not notice some of your questions, would you be so kind as > to repeat them? > -- Craig Ringer http://www.2ndQuadrant.com/ 2ndQuadrant - PostgreSQL Solutions for the Enterprise --000000000000c5a442059037d61d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, 16 Aug 2019 at 15:30, Konstantin = Knizhnik <k.knizhnik@postgr= espro.ru> wrote:
=C2=A0

1. Statistic for global temporary tables (including number of tuples, pages and all visible flag).
My position is the following: while in most cases it should not be a problem, because users rarely create indexes or do analyze for temporary tables,
there can be situations when differences in data sets of global temporary tables in different backends can really be a problem.
Unfortunately I can not propose good solution for this problem. It is certainly possible to create some private (per-backend) cache for this metadata.
But it seems to requires changes in many places.
=

Yeah. I don't really like just sharing them but it&= #39;s not that bad either.
=C2=A0
2. Your concerns about per= formance penalty of global temp tables accessed through shared buffers comparing with local temp tables access through local buffers.
I think that this concern is not=C2=A0 actual any more because there is implementation of global temp tables using local buffers.
But my experiments doesn't show significant difference in access speed of shared and local buffers. As far as shared buffers are used to be much larger than local buffers,
there are more chances to hold all temp relation in memory without spilling it to the disk. In this case access to global temp table will be much faster comparing with access to
local temp tables.

You ignore the= costs of evicting non-temporary data from shared_buffers, i.e. contention = for space. Also increased chance of backends being forced to do direct writ= e-out due to lack of s_b space for dirty buffers.
=C2=A0
> In case of pulling all content of temp table in memory (pg_prewarm) global temp table with shared buffers becomes faster.

Who would ever do that?

I forget or do not noti= ce some of your questions, would you be so kind as to repeat them?
=C2=A0
=C2= =A0

--
=C2=A0Cra= ig Ringer=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 http://www.2ndQuadrant.com/
=C2=A02ndQuadr= ant - PostgreSQL Solutions for the Enterprise
--000000000000c5a442059037d61d--