Postgresql ILIKE versus TSEARCH

后端 未结 3 880
天涯浪人
天涯浪人 2020-12-17 02:07

I have a query with a number of test fields something like this:

SELECT * FROM some-table
  WHERE field1 ILIKE \"%thing%\"
     OR field2 ILIKE \"%thing\"
           


        
3条回答
  •  隐瞒了意图╮
    2020-12-17 02:49

    A full text search setup is not identical to a "contains" like query. It stems words etc so you can match "cars" against "car".

    If you really want a fast ILIKE then no standard database index or FTS will help. Fortunately, the pg_trgm module can do that.

    • http://www.postgresql.org/docs/9.1/static/pgtrgm.html
    • http://www.depesz.com/2011/02/19/waiting-for-9-1-faster-likeilike/

提交回复
热议问题