Re: Why is this query not using GIN index?

From: Aaron Lewis <the(dot)warl0ck(dot)1989(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Oleg Bartunov <obartunov(at)gmail(dot)com>, Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why is this query not using GIN index?
Date: 2016-11-14 03:50:47
Message-ID: CAJZVxRnaRP6UMfNjgWPvbHEnUqjQ2AP+wFwMgbqUjZcxSXn7Ew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey guys,

I'm trying to understand the performance impact of "Index Recheck", I
googled for Index Recheck, but didn't find much details about it,
where can I know more about it?

And how did you know the performance is being significantly hurt by
inadequate work_mem?

I'm running PG 9.6.1, built from source.

On Mon, Nov 14, 2016 at 2:51 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Oleg Bartunov <obartunov(at)gmail(dot)com> writes:
>> On Sun, Nov 13, 2016 at 6:05 PM, Aaron Lewis <the(dot)warl0ck(dot)1989(at)gmail(dot)com>
>>> It takes 500ms with 10m rows, could it be faster?
>
>> sure. Recheck with function call is pretty expensive, so I'd not recommend
>> to create functional index, just create separate column of type tsvector
>> (materialize to_tsvector) and create gin index on it. You should surprise.
>
> I doubt it'll help that much --- more than half the time is going into the
> bitmap indexscan, and with over 1m candidate matches, there's no way
> that's going to be super cheap.
>
> I wonder whether a gist index would be better here, since it would support
> a plain indexscan which should require scanning much less of the index
> given the small LIMIT.
>
> (Materializing the tsvector would probably help for gist, too, by reducing
> the cost of lossy-index rechecks.)
>
> BTW, it still looks like the performance is being significantly hurt by
> inadequate work_mem.
>
> regards, tom lane

--
Best Regards,
Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yogesh Sharma 2016-11-14 07:01:41 Request to share information regarding deadlock in postgresql-8.1.18
Previous Message Venkata B Nagothi 2016-11-14 02:33:50 Re: Wal files being delayed - Pgsql 9.2