Re: Gin indexes on intarray is fast when value in array does not exists, and slow, when value exists

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: otar shavadze <oshavadze(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Gin indexes on intarray is fast when value in array does not exists, and slow, when value exists
Date: 2016-11-08 19:40:42
Message-ID: CAMkU=1zcRSAKZbZian2u3_eZPEHQBTr9kVBP2=jFZwX6=fCc0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Nov 8, 2016 at 9:43 AM, otar shavadze <oshavadze(at)gmail(dot)com> wrote:

> I have table with 500 000 rows, I have int[] column "my_array" in this
> table, this array column contains minimum 1 and maximum 5 different values.
>
> I have GIN index on my_array column:
>
> * "CREATE INDEX idx ON table_name USING GIN(my_array gin__int_ops)"*
>
> Then I use this query: "*SELECT * FROM table_name WHERE my_array @>
> '{3}'::integer[] ORDER BY id LIMIT 50"*
>
> Execution time of this query is approximately 500-1000 ms. Then if I drop
> gin index "*idx*", query works extremely fast, less than 20 ms.
>

Please post the information requested here:
https://wiki.postgresql.org/wiki/Slow_Query_Questions

Also, can you show,

select * from pg_stats where tablename ='table_name' and attname='my_array'
\x\g\x

Cheers,

Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ryan Mahoney 2016-11-08 19:48:23 Running on Docker, AWS with Data Stored on EBS
Previous Message Oleg Bartunov 2016-11-08 18:56:45 Re: Gin indexes on intarray is fast when value in array does not exists, and slow, when value exists