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.92) (envelope-from ) id 1jEMfh-0006FQ-QJ for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Mar 2020 00:34: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 1jEMfg-0007A1-AF for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Mar 2020 00:34:56 +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 1jEMff-00079s-Cz for pgsql-bugs@lists.postgresql.org; Wed, 18 Mar 2020 00:34:56 +0000 Received: from 153.126.206.245.v6.sakura.ne.jp ([2401:2500:102:3039:153:126:206:245] helo=mail.clear-code.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEMfb-0008Ln-7K for pgsql-bugs@lists.postgresql.org; Wed, 18 Mar 2020 00:34:53 +0000 Received: from localhost (KD106181171115.au-net.ne.jp [106.181.171.115]) by mail.clear-code.com (Postfix) with ESMTPSA id E6956101866; Wed, 18 Mar 2020 09:34:36 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com E6956101866 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1584491677; bh=sZDPNnMsNEEpokGOcKiK+IdBSyVrDKLzJoh+HHo2u9Q=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=U5WWptIWSFd/mgZIXpvei6Z6M+zQWjTa1+wlimQG8YVgRu1WqiHHE7VDxql5wDiUu 56VC3KCf0NVdCgTydlAUe+R0IxW0a6ehyairVTR/KhuXIgKbwpRjuZ1fIKI19CfMdP wj/KWJ7CObp8v9JbVzhkhQo3wm4gWM7LPvxZgCds= Date: Wed, 18 Mar 2020 09:34:31 +0900 (JST) Message-Id: <20200318.093431.280154679895579436.horimoto@clear-code.com> To: tgl@sss.pgh.pa.us Cc: david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong From: Horimoto Yasuhiro In-Reply-To: <5148.1584372043@sss.pgh.pa.us> References: <20200316.172230.2295109568745072390.horimoto@clear-code.com> <5148.1584372043@sss.pgh.pa.us> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E6956101866 X-Spamd-Result: default: False [1.40 / 999.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MV_CASE(0.50)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_CONTAINS_FROM(1.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:2516, ipnet:106.181.0.0/16, country:JP]; FREEMAIL_CC(0.00)[gmail.com,lists.postgresql.org] X-Rspamd-Server: mail.clear-code.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, Thank you for your explanation. I understand what you say. Thank you, From: Tom Lane Subject: Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong Date: Mon, 16 Mar 2020 11:20:43 -0400 > Horimoto Yasuhiro writes: >> So I think that choosing index-only scan for this case (false is returned by gistcanreturn() case) >> isn't expected behavior. > > You're mistaken. An index-only scan is not only useful but potentially > quite desirable for queries such as count(*); in the best case it ends > up just counting the index entries without ever visiting the heap at all. > > It does look a bit weird that we might select an IOS for an index type > that can't ever return any column values, but so far as I can see it > should work fine. The index isn't being asked to do anything that it > doesn't have to do anyway, ie, return the correct set of heap TIDs. > Testing locally with a GIST index gives the right answers, too. > >> We found the problem I reported with PGroonga: >> https://github.com/pgroonga/pgroonga/issues/101 > >> This problem causes an error because PGroonga can't return >> IndexScanDesc::xs_itup but IndexScanDesc::xs_want_itup is true. >> Because PostgreSQL requests index-only scan even when PGroonga >> returns false by amcanreturn(). > > You should be returning an empty, zero-column tuple (either itup > or htup format) in that situation. The limit of "I don't have > any columns I can return" is to form a tuple with no columns, > not to fail to form a tuple. > > regards, tom lane > >