Re: GIN index not used

From: "Huang, Suya" <Suya(dot)Huang(at)au(dot)experian(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: GIN index not used
Date: 2014-07-11 05:26:09
Message-ID: D83E55F5F4D99B4A9B4C4E259E6227CD014C32C9@AUX1EXC01.apac.experian.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Friday, July 11, 2014 2:56 PM
To: Andreas Kretschmer
Cc: Huang, Suya; pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] GIN index not used

Andreas Kretschmer <akretschmer(at)spamfence(dot)net> writes:
> Huang, Suya <Suya(dot)Huang(at)au(dot)experian(dot)com> wrote:
>> I’ve got a table with GIN index on integer[] type. While doing a
>> query with filter criteria on that column has GIN index created, it’s
>> not using index at all, still do the full table scan. Wondering why?

> Btw.: works for me:

Yeah, me too:

regression=# create table booking_weekly(booking_ts int[]); CREATE TABLE regression=# create index on booking_weekly using gin (booking_ts); CREATE INDEX regression=# explain select * from booking_weekly where booking_ts@>array[2446685];
QUERY PLAN
--------------------------------------------------------------------------------------------
Bitmap Heap Scan on booking_weekly (cost=8.05..18.20 rows=7 width=32)
Recheck Cond: (booking_ts @> '{2446685}'::integer[])
-> Bitmap Index Scan on booking_weekly_booking_ts_idx (cost=0.00..8.05 rows=7 width=0)
Index Cond: (booking_ts @> '{2446685}'::integer[]) Planning time: 0.862 ms
(5 rows)

What PG version is this? What non-default planner parameter settings are you using? (Don't say "none", because I can see you've got enable_seqscan turned off.)

regards, tom lane

Just found out something here http://www.postgresql.org/message-id/17021.1234474178@sss.pgh.pa.us

So I dropped the index and recreate it by specifying: using gin(terms_ts gin__int_ops) and the index works.

My PG version is 9.3.4, none-default planner settings:
enable_mergejoin = off
enable_nestloop = off

enable_seqscan is turned off for session while trying to figure out why the GIN index is not used.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2014-07-11 05:43:24 Re: GIN index not used
Previous Message Andreas Kretschmer 2014-07-11 05:01:23 Re: GIN index not used