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 1hsVut-0002wL-Kb for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 17:28:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsVur-0004Fz-7b for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 17:28:01 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsVuq-00049j-SA for pgsql-hackers@lists.postgresql.org; Tue, 30 Jul 2019 17:28:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsVuk-0006yZ-4J for pgsql-hackers@lists.postgresql.org; Tue, 30 Jul 2019 17:28:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6UHRmiM027218; Tue, 30 Jul 2019 13:27:48 -0400 From: Tom Lane To: Marc Cousin cc: Alexander Korotkov , Julien Rouhaud , Tomas Vondra , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Avoid full GIN index scan when possible In-reply-to: References: <20190628161051.szk2kxmue6yjdmra@development> <4547.1561748599@sss.pgh.pa.us> <20190628195401.frwhcga76rrytbc4@development> <7773.1561752983@sss.pgh.pa.us> Comments: In-reply-to Marc Cousin message dated "Mon, 01 Jul 2019 17:56:17 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27216.1564507668.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 30 Jul 2019 13:27:48 -0400 Message-ID: <27217.1564507668@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Marc Cousin writes: > By the way, while preparing this, I noticed that it seems that during th= is kind of index scan, the interrupt signal is masked > for a very long time. Control-C takes a very long while to cancel the qu= ery. But it's an entirely different problem :) Yeah, that seems like an independent problem/patch, but it's not obvious where to fix --- can you provide a self-contained test case? Meanwhile, I looked at the v3 patch, and it seems like it might not be too far from committable. I think we should *not* let this get bogged down in questions of whether EXPLAIN can report which index quals were used or ignored. That's a problem that's existed for decades in the btree code, with more or less zero user complaints. I do think v3 needs more attention to comments, for instance this hunk is clearly falsifying the adjacent comment: @ -141,7 +141,8 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum, uint32 i; = /* Non-default search modes add one "hidden" entry to each key */ - if (searchMode !=3D GIN_SEARCH_MODE_DEFAULT) + if (searchMode !=3D GIN_SEARCH_MODE_DEFAULT && + (searchMode !=3D GIN_SEARCH_MODE_ALL || nQueryValues)) nQueryValues++; key->nentries =3D nQueryValues; key->nuserentries =3D nUserQueryValues; Also, I agree with Julien that this + so->forcedRecheck =3D key->triConsistentFn(key) !=3D GIN_TRUE; probably needs to be + so->forcedRecheck |=3D key->triConsistentFn(key) !=3D GIN_TRUE; regards, tom lane