Re: Avoid full GIN index scan when possible

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Marc Cousin <cousinmarc(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid full GIN index scan when possible
Date: 2019-08-01 10:13:24
Message-ID: CAOBaU_Y7K_VjCQUfZzYf3iFXscnO-rGk1o+eH6xBs-fth5N0-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 1, 2019 at 8:43 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> On Wed, Jul 31, 2019 at 5:28 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > 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 != GIN_SEARCH_MODE_DEFAULT)
> > + if (searchMode != GIN_SEARCH_MODE_DEFAULT &&
> > + (searchMode != GIN_SEARCH_MODE_ALL || nQueryValues))
> > nQueryValues++;
> > key->nentries = nQueryValues;
> > key->nuserentries = nUserQueryValues;
> >
> > Also, I agree with Julien that this
> >
> > + so->forcedRecheck = key->triConsistentFn(key) != GIN_TRUE;
> >
> > probably needs to be
> >
> > + so->forcedRecheck |= key->triConsistentFn(key) != GIN_TRUE;
>
> Ping, Julien? Based on the above, it looks like if we had a
> last-minute patch addressing the above this could go directly to Ready
> for Committer? I will hold off moving this one to CF2 until my
> morning.

Attached v4 that should address all comments.

Attachment Content-Type Size
avoid_gin_fullscan-v4.diff application/octet-stream 6.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2019-08-01 10:22:23 Re: SQL:2011 PERIODS vs Postgres Ranges?
Previous Message Sergei Kornilov 2019-08-01 10:09:51 Re: allow online change primary_conninfo