Re: Why is this query not using GIN index? - Mailing list pgsql-general

From Oleg Bartunov
Subject Re: Why is this query not using GIN index?
Date
Msg-id CAF4Au4xFW8ymxsCtWJjwbq6V_TVj49vCnPdZa635HeGP2VO+ug@mail.gmail.com
Whole thread Raw
In response to Why is this query not using GIN index?  (Aaron Lewis <the.warl0ck.1989@gmail.com>)
Responses Re: Why is this query not using GIN index?
List pgsql-general


On Sun, Nov 13, 2016 at 2:50 PM, Aaron Lewis <the.warl0ck.1989@gmail.com> wrote:
I have a simple table, and a gin index,

create table mytable(hash char(40), title varchar(500));
create index name_fts on mytable using gin(to_tsvector('english', 'title'));

                                                                                                            ^^^^^
 
create unique index md5_uniq_idx on mytable(hash);

When I execute a query with tsquery, the GIN index was not in use:

test=# explain analyze select * from mytable where
to_tsvector('english', title) @@ 'abc | def'::tsquery limit 10;
                                                     QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.00..277.35 rows=10 width=83) (actual
time=0.111..75.549 rows=10 loops=1)
   ->  Seq Scan on mytable  (cost=0.00..381187.45 rows=13744 width=83)
(actual time=0.110..75.546 rows=10 loops=1)
         Filter: (to_tsvector('english'::regconfig, (title)::text) @@
'''abc'' | ''def'''::tsquery)
         Rows Removed by Filter: 10221
 Planning time: 0.176 ms
 Execution time: 75.564 ms
(6 rows)

Any ideas?


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


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: Trigram is slow when 10m rows
Next
From: Aaron Lewis
Date:
Subject: Re: Trigram is slow when 10m rows