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 1iyWmM-0000vN-Ul for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2020 08:08:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iyWmL-0004ku-OK for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2020 08:08:21 +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 1iyWmL-0004gg-8G for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2020 08:08:21 +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 1iyWmF-0001BL-MI for pgsql-hackers@postgresql.org; Mon, 03 Feb 2020 08:08:20 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id CB77F21C4CB5; Mon, 3 Feb 2020 11:08:12 +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 D7C0621C4DC4; Mon, 3 Feb 2020 11:08:10 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1580717291; bh=dPmAT3vWG4VFjxEE5LxfBb9YllU2Y7qKVZiaP4a6jFQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=nNEGEgL8iLaV2+YE6ZOLihCKdiwlMkXHHDwkqDf9hKmQASn4L0p1ppTo+k4Tg4Y5e 0aLsSaop1DXFVlQ0HnuvG4xVB610ln33SAQs9zDFcNbSNFFqyfZYNX62yZQaWQx/Dd 1RpfzU7EJqpVTBie2paq2UzlSAjND2nlNw1z/hQk= Subject: Re: [Proposal] Global temporary tables To: Robert Haas Cc: Pavel Stehule , Tomas Vondra , =?UTF-8?B?5pu+5paH5peMKOS5ieS7jik=?= , PostgreSQL Hackers , =?UTF-8?B?6JSh5p2+6Zyy?= =?UTF-8?B?KOWtkOWYiSk=?= , "Cai, Le" , =?UTF-8?B?6JCn5bCR6IGqKOmTgeW6tSk=?= References: <24099f4e-742c-e92b-729c-77bac1ca80d4@postgrespro.ru> <7dd64333-3b6f-5aae-20ac-5fde142902e1@postgrespro.ru> <2fd087e8-b03a-5996-e077-df010104177c@postgrespro.ru> <0bddbc6d-fed1-d56b-d39f-67352461b2d1@postgrespro.ru> <407d6499-950d-e3d9-acbc-a2e86d8b82a3@postgrespro.ru> <6cbc12a0-bf0e-0205-959e-d871eb7e7c3e@postgrespro.ru> <3bfa5b5d-6b3b-743d-573c-b85f933ba540@postgrespro.ru> From: Konstantin Knizhnik Message-ID: <3c68995f-0b2e-1c24-d4f5-d2f11c9dd34f@postgrespro.ru> Date: Mon, 3 Feb 2020 11:08:10 +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 31.01.2020 22:38, Robert Haas wrote: > Now, your idea is not quite as crazy as that, but it has the same > basic problem: you can't insert code into a low-level facility that > uses a high level facility which may in turn use and depend on that > very same low-level facility to not be in the middle of an operation. > If you do, it's going to break somehow. > Thank you for explanation. You convinced me that building indexes from _bt_getbuf is not good idea. What do you think about idea to check and build indexes for GTT prior to query execution? In this case we do not need to patch code of all indexes - it can be done just in one place. We can use build function of access method to initialize index and populate it with data. So right now when building query execution plan, optimizer checks if index is valid. If index belongs to GTT, it an check that first page of the index is initialized and if not - call build method for this index. If building index during building query plan is not desirable, we can just construct list of indexes which should be checked and perform check itself and building indexes somewhere after building plan but for execution of the query. Do you seem some problems with such approach? -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company