Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewNsA-0001TZ-5A for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Mar 2018 08:04:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewNs8-0007Ox-Id for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Mar 2018 08:04:24 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewNs8-0007Oo-BU for pgsql-hackers@lists.postgresql.org; Thu, 15 Mar 2018 08:04:24 +0000 Received: from sraihb2.sra.co.jp ([202.32.10.6]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewNs0-0004p7-Fi for pgsql-hackers@lists.postgresql.org; Thu, 15 Mar 2018 08:04:23 +0000 Received: from srascf.sra.co.jp (srascf [133.137.8.80]) by sraihb2.sra.co.jp (Postfix) with ESMTP id 4255B2A15FC for ; Thu, 15 Mar 2018 17:04:13 +0900 (JST) Received: from srascb.sra.co.jp (unknown [133.137.8.65]) by srascf.sra.co.jp with smtp id 6a14_0811_8e51ad05_4ed0_4917_a90f_d6ec82306598; Thu, 15 Mar 2018 17:04:12 +0900 Received: from sranhm.sra.co.jp (osspc25 [133.137.174.97]) by srascb.sra.co.jp (Postfix) with ESMTP id 243BE2D6942 for ; Thu, 15 Mar 2018 17:04:13 +0900 (JST) Received: from yugo-n-ubuntu (dhcp-175-140.sra.co.jp [133.137.175.140]) by sranhm.sra.co.jp (Postfix) with SMTP id 15894A13AE; Thu, 15 Mar 2018 17:04:13 +0900 (JST) Date: Thu, 15 Mar 2018 17:04:13 +0900 From: Yugo Nagata To: Tom Lane Cc: Anastasia Lubennikova , pgsql-hackers@lists.postgresql.org Subject: Re: CURRENT OF causes an error when IndexOnlyScan is used Message-Id: <20180315170413.abca0c2b.nagata@sraoss.co.jp> In-Reply-To: <13902.1520877384@sss.pgh.pa.us> References: <20180201013349.937dfc5f.nagata@sraoss.co.jp> <20180201014444.f78358df.nagata@sraoss.co.jp> <22958.1517451171@sss.pgh.pa.us> <97dc81d3-0ea9-3032-49d9-7983e35fb010@postgrespro.ru> <20180220095252.GA18315@e733.localdomain> <13902.1520877384@sss.pgh.pa.us> X-Mailer: Sylpheed Pro 2.1.4 (GTK+ 2.24.23; x86_64-unknown-linux-gnu; Pro 2.1.4) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 12 Mar 2018 13:56:24 -0400 Tom Lane wrote: > Anastasia Lubennikova writes: > > [ return_heaptuple_in_btree_indexonlyscan_v2.patch ] > > I took a quick look at this, but I'm concerned about a couple of points: > > 1. What's the performance penalty of forming (and then deforming) the > added heap tuple? We'd be paying it for every index-only scan, whether > or not any CURRENT OF fetch ever happened. > > 2. The constructed tuple provides tableoid and ctid all right, but it'd > still have garbage values for other system columns. As the code stands, > we will properly error out if some attempt is made to fetch any of those > other columns, but with this change we'd just return the garbage. This > is a minor point, but it doesn't seem negligible to me; it might've been > hard to identify the bug at hand if we'd not had the cross-check of not > building a heap tuple. In addition, this patch fixes only nbtree indexes, but the simillar problem will occur also on GIST indexes which support index-only scan. If we resolve this bug by fixing index access methods, I think we need to fix all existing indexes that support index-only scan and also describe the specification in the documents, comments, or README, etc. for future indexes. > At this point Yugo-san's original patch is starting to look more > attractive. It's still ugly, but at least it's not imposing a performance > cost on unrelated queries. I would like to elaborate my patch if needed and possible. Any suggestion would be appriciated. Thanks, > > regards, tom lane -- Yugo Nagata