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 1iQZUr-000514-8L for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Nov 2019 16:09:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iQZUp-0002gG-Tx for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Nov 2019 16:09:55 +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 1iQZUp-0002ff-D9 for pgsql-hackers@lists.postgresql.org; Fri, 01 Nov 2019 16:09:55 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iQZUm-0008Ot-0o for pgsql-hackers@postgresql.org; Fri, 01 Nov 2019 16:09:54 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 4224521C4A99; Fri, 1 Nov 2019 19:09:50 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.200] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id EA1B321C4A7D; Fri, 1 Nov 2019 19:09:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1572624590; bh=DRjX1ji2BAJiPgYVKlm2xYMir0YoPJ2vfFmX9bylisM=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=lVDinqRdbT3ESdoSkAMsU3XD+eXJB9oXVPAIIPxoRuSwmmUUFyccs5BnQO9o5joD+ ad4i86p9ma4VmJwj4UgSYogdRos4EDdkh9XobSMyHTNplH54DRO1+XieqAT28UtZ/8 G39lUsQzkx6E8FVtzM3E5a25dRWnD2Z1TFqIOGPU= Subject: Re: [Proposal] Global temporary tables To: Robert Haas Cc: Pavel Stehule , =?UTF-8?B?5pu+5paH5peMKOS5ieS7jik=?= , PostgreSQL Hackers , =?UTF-8?B?6JSh5p2+6Zyy?= =?UTF-8?B?KOWtkOWYiSk=?= , "Cai, Le" , =?UTF-8?B?5byg5bm/6IifKOaYjuiZmik=?= , =?UTF-8?B?6LW15q6/5aWO?= , =?UTF-8?B?6JCn5bCR6IGqKOmTgeW6tSk=?= References: <1A1A6EDC-D0EC-47B0-BD21-C2ACBAEA65E4@alibaba-inc.com> <0ef6f482-11ce-a99f-207e-26fa3f2f56db@postgrespro.ru> <24099f4e-742c-e92b-729c-77bac1ca80d4@postgrespro.ru> <80cf30c2-ebd5-a568-9f62-a970e4d91326@postgrespro.ru> From: Konstantin Knizhnik Message-ID: <136fcaf5-2841-6435-7640-be04c4891143@postgrespro.ru> Date: Fri, 1 Nov 2019 19:09:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 01.11.2019 18:26, Robert Haas wrote: > On Fri, Nov 1, 2019 at 11:15 AM Konstantin Knizhnik > wrote: >> It seems to me that I have found quite elegant solution for per-backend statistic for GTT: I just inserting it in backend's catalog cache, but not in pg_statistic table itself. >> To do it I have to add InsertSysCache/InsertCatCache functions which insert pinned entry in the correspondent cache. >> I wonder if there are some pitfalls of such approach? > That sounds pretty hackish. You'd have to be very careful, for > example, that if the tables were dropped or re-analyzed, all of the > old entries got removed -- I have checked it: - when table is reanalyzed, then cache entries are replaced. - when table is dropped, then cache entries are removed. > and then it would still fail if any code > tried to access the statistics directly from the table, rather than > via the caches. My assumption is that the statistics ought to be > stored in some backend-private data structure designed for that > purpose, and that the code that needs the data should be taught to > look for it there when the table is a GTT. Yes, if you do "select * from pg_statistic" then you will not see statistic for GTT in this case. But I do not think that it is so critical. I do not believe that anybody is trying to manually interpret values in this table. And optimizer is retrieving statistic through sys-cache mechanism and so is able to build correct plan in this case. -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company