1

I need an index on some text columns to increase spped of queries. I not really sure whether I can use FTS or not. I have in my column something like that: 34565A43B2423FRR34AQ and I am searching in that way:

WHERE column ~* '5A43B'

and I'm expecting that this value will be found. But the table is big (about million rows) and the time is not efficient. What kind of index I can use?

1
  • It is important to notice that I have to use ~* operator because in search interface people can use regular expressions. Commented Aug 10, 2011 at 12:30

2 Answers 2

2

FTS won't work for this, a string like this can't be parsed into tokens. There is an extension that can do the trick: wildspeed. You have to install this module in the database before you can use it. The index might be very large, but it can also be very fast.

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

Comments

0

If you rewrite your query by changing POSIX regular expression to LIKE/ILIKE, you can use pg_trgm extension.

Such as:

WHERE column ~~* '%5A43B%'

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.