Re: GIN index not used

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: GIN index not used
Date: 2014-07-11 04:44:52
Message-ID: 20140711044452.GA7390@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Huang, Suya <Suya(dot)Huang(at)au(dot)experian(dot)com> wrote:

> Hi,
>
>
>
> 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?

Try to add an index on the date-column.

Btw.: works for me:

,----
| test=*# \d foo;
| Table "public.foo"
| Column | Type | Modifiers
| --------+-----------+-----------
| id | integer |
| ts | integer[] |
| Indexes:
| "idx_foo" gin (ts)
|
| test=*# set enable_seqscan to off;
| SET
| Time: 0,049 ms
| test=*# select * from foo;
| id | ts
| ----+------------
| 1 | {1,2,3}
| 2 | {10,20,30}
| (2 rows)
|
| Time: 0,230 ms
| test=*# explain select * from foo where ts @> array[2];
| QUERY PLAN
| ----------------------------------------------------------------------
| Bitmap Heap Scan on foo (cost=8.00..12.01 rows=1 width=36)
| Recheck Cond: (ts @> '{2}'::integer[])
| -> Bitmap Index Scan on idx_foo (cost=0.00..8.00 rows=1 width=0)
| Index Cond: (ts @> '{2}'::integer[])
| (4 rows)
`----

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2014-07-11 04:56:14 Re: GIN index not used
Previous Message Huang, Suya 2014-07-11 04:14:38 GIN index not used