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 1ipazC-0002ha-Fq for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jan 2020 16:48:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipaz9-0003nb-MO for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jan 2020 16:48:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipaz9-0003mu-A1 for pgsql-hackers@lists.postgresql.org; Thu, 09 Jan 2020 16:48:39 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ipaz6-0000Hd-AQ for pgsql-hackers@postgresql.org; Thu, 09 Jan 2020 16:48:37 +0000 Received: by mail-wm1-x341.google.com with SMTP id 20so3598224wmj.4 for ; Thu, 09 Jan 2020 08:48:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=0NIFQfntXRz+VYFfSHOHOEVhMyPBGCvbriVQVYy0ISU=; b=eEv/VmwJdfSsoMU4h9EOwQ28MrRLNK09+rYyJBbKjx7/CVtB0nwmLHxYSJ5yGT+bWo Pveo61BC7W/CQC2QGz+YEeoW/yyY5cxsvjxpRoLFFcjo8Y3o4nSzgSSZB9kmM6Mylcey 0wMbOnVYq1DP5ctbLjPYHyv2sOXTgax/1ZGXoa5IyMOeMpbADAF/HNp+6Btg11wZU6Wt qtnAou4LrXerb5v5yCVA6KCpMas8csSEiy9+9vi33k9/juuUQnl2hPbpnqTPYDwxMaeY snkVFL7zj+EdkBGHVr5weTtPCbF/jdoYtdgnB4IJooJ/bc1QHJil5WYsjXk/iwDld299 xang== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=0NIFQfntXRz+VYFfSHOHOEVhMyPBGCvbriVQVYy0ISU=; b=CEO7Q/eD2AKrDQbsx6DnjkbLRvTlOODxZ8eRzTziX3AWS5KTnFAA1NPo8pnmVh+Zwu 5Trini/W61hzxcQOu5nIur/D84rZ/gM7EP7ECJfbFoqbhDnR2LMl0QpWx3gLUHBRysbb 2zRVMl6heKiaa8eUneVAu4mwE2deMP4HmUYj3CTA+Bw0G7JlSampPS8J8PLvDDcHf9xA CCzBUE1fLw+G/ShGQwv5h0+zXe7Kh8Spvfw1Vqm+3L3VRffSNYfUDDTsrNKGnvjGqM1a +5g6d91ZAFYCM0QTkFoPczhEehpCD6/CB1aWiS/zw9H1NrFIbm6de8tYrzLNDgIceE9y Kz2w== X-Gm-Message-State: APjAAAU8MyQ43om0CK57vXItPiqBg4jQ6JIJgn1ik3VtDAVC5WBIn7qF pG7blNSYoOmNsrBKuSdhMhGQ3w== X-Google-Smtp-Source: APXvYqzvHqf5B4idOZXqQJWNQeRj0zYOc0rMiSiaB1/YRSOdJMxEGdXTiel+3a9XuUO5eTBmwI+Bdw== X-Received: by 2002:a05:600c:224d:: with SMTP id a13mr6106219wmm.57.1578588513485; Thu, 09 Jan 2020 08:48:33 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id p17sm8706809wrx.20.2020.01.09.08.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 08:48:31 -0800 (PST) Date: Thu, 9 Jan 2020 17:48:29 +0100 From: Tomas Vondra To: Konstantin Knizhnik Cc: =?utf-8?B?5pu+5paH5peMKOS5ieS7jik=?= , Pavel Stehule , Robert Haas , PostgreSQL Hackers , =?utf-8?B?6JSh5p2+6ZyyKOWtkOWYiSk=?= , "Cai, Le" , =?utf-8?B?6JCn5bCR6IGqKOmTgeW6tSk=?= Subject: Re: [Proposal] Global temporary tables Message-ID: <20200109164829.mdl3z5xalmaqxs67@development> References: <0ef6f482-11ce-a99f-207e-26fa3f2f56db@postgrespro.ru> <24099f4e-742c-e92b-729c-77bac1ca80d4@postgrespro.ru> <80cf30c2-ebd5-a568-9f62-a970e4d91326@postgrespro.ru> <5767433E-1A77-4682-B3FD-4869911021C8@alibaba-inc.com> <6b7570aa-14ea-2f28-c3b5-74dd785bbafe@postgrespro.ru> <20200105200603.wrb4beacwb57hhpk@development> <33969545-BEF7-4518-A741-302CBF7FF269@alibaba-inc.com> <0498c45c-53cb-d9b0-c1e2-7d2d1a618511@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0498c45c-53cb-d9b0-c1e2-7d2d1a618511@postgrespro.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jan 09, 2020 at 02:17:08PM +0300, Konstantin Knizhnik wrote: > > >On 06.01.2020 8:04, 曾文旌(义从) wrote: >>In the previous communication >> >>1 we agreed on the general direction >>1.1 gtt use local (private) buffer >>1.2 no replica access in first version >> >>2 We feel that gtt needs to maintain statistics, but there is no agreement on what it will be done. >> >>3 Still no one commented on GTT's transaction information processing, they include >>3.1 Should gtt's frozenxid need to be care? >>3.2 gtt’s clog clean >>3.3 How to deal with "too old" gtt data >> >>I suggest we discuss further, reach an agreement, and merge the two patches to one. >> > >I also hope that we should come to the common solution for GTT. >If we do not try to address parallel execution issues and access to >temp tables at replicas (and I agreed >that it should be avoided in first version of the patch), then GTT >patch becomes quite small. > Well, that was kinda my goal - making the patch as small as possible by eliminating bits that are contentious or where we don't know the solution (like planning for parallel queries). >The most complex and challenged task is to support GTT for all kind of >indexes. Unfortunately I can not proposed some good universal solution >for it. >Just patching all existed indexes implementation seems to be the only >choice. > I haven't looked at the indexing issue closely, but IMO we need to ensure that every session sees/uses only indexes on GTT that were defined before the seesion started using the table. Can't we track which indexes a particular session sees, somehow? >Statistic is another important case. >But once again I do not completely understand why we want to address >all this issues with statistic in first version of the patch? I think the question is which "issues with statistic" you mean. I'm sure we can ignore some of them, e.g. the one with parallel workers not having any stats (assuming we consider functions using GTT to be parallel restricted). >It contradicts to the idea to make this patch as small as possible. Well, there's "making patch as small as possible" vs. "patch behaving correctly" trade-off ;-) >Also it seems to me that everybody agreed that users very rarely >create indexes for temp tables and explicitly analyze them. I certainly *disagree* with this. We often see temporary tables as a fix or misestimates in complex queries, and/or as a replacement for CTEs with statistics/indexes. In fact it's a pretty valuable tool when helping customers with complex queries affected by poor estimates. >So I think GTT will be useful even with limited support of statistic. >In my version statistics for GTT is provided by pushing correspondent >information to backend's cache for pg_statistic table. I think someone pointed out pushing stuff directly into the cache is rather problematic, but I don't recall the details. >Also I provided pg_temp_statistic view for inspecting it by users. The >idea to make pg_statistic a view which combines statistic of normal >and temporary tables is overkill from my point of view. > >I do not understand why do we need to maintain hash with some extra >information for GTT in backends memory (as it was done in Wenjing >patch). >Also idea to use create extension for accessing this information seems >to be dubious. > I think the extension was more a PoC rather than a final solution. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services