Is there a way to index in postgres for fast substring searches

前端 未结 3 1068
闹比i
闹比i 2021-02-04 05:43

I have a database and want to be able to look up in a table a search that\'s something like: select * from table where column like \"abc%def%ghi\" or select * from table where c

3条回答
  •  忘了有多久
    2021-02-04 06:25

    For the like operator use one of the operator classes varchar_pattern_ops or text_pattern_ops

    create index test_index on test_table (col varchar_pattern_ops);
    

    That will only work if the pattern does not start with a % in which case another strategy is required.

提交回复
热议问题