2

it seems that my server won't use gin index.

  1. I've created a new database with one table.
  2. I've inserted one row as example.
  3. I've loaded trigram extension and created gin index using trigrams
  4. But when I check if the index works right I can see it doesn't
  5. Any ideas?

SQL: http://pastebin.com/1yDQQA1Z

P.S. A day ago I've followed a tutorial about trigrams. Basically it was the same like my example above. The table had 2 columns, numeric(5, 0) and character varying (the one with gin trgm index). Query was with like operator using "%" and index was working (I could see Bitmap using in query explain), so I know, my server can use index (and its properly installed).

Thanks in advance.

1
  • P.S.S I've tried to load extension first and then create table, or insert data and then create index... i've tried many combinations but without any luck. Commented Jan 27, 2013 at 13:35

1 Answer 1

6

Don't test on one row, it is meaningless.

Here's an excerpt of the documentation explaining why, in Examining Index Usage:

Use real data for experimentation. Using test data for setting up indexes will tell you what indexes you need for the test data, but that is all.

It is especially fatal to use very small test data sets. While selecting 1000 out of 100000 rows could be a candidate for an index, selecting 1 out of 100 rows will hardly be, because the 100 rows probably fit within a single disk page, and there is no plan that can beat sequentially fetching 1 disk page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.