0

What index will enhance database performance for table

CREATE TABLE my_table (
    word_set text[]
)

for requests with WHERE my_table.word_set @> '<some word>'

Timofey Gorshkov
  • 4,987
  • 6
  • 41
  • 66
  • 3
    Check [this topic][1], same sort of issue. [1]: http://stackoverflow.com/questions/4058731/can-postgresql-index-array-columns/4059785#4059785 – Frank Heikens Jul 25 '12 at 11:40

1 Answers1

2

CREATE INDEX idx_test on my_table USING GIN (word_set);

Check EXPLAIN ANALYZE to see if the index is used. Turn enable_seqscan off when your table is almost empty or doesn't have enough unique data. Having an index doesn't mean the database will always use that index: Using an index might be slower than a sequential disk scan. It all depends.

Frank Heikens
  • 117,544
  • 24
  • 142
  • 135