PostgreSQL LIKE query performance variations

后端 未结 8 2538
青春惊慌失措
青春惊慌失措 2020-11-22 00:54

I have been seeing quite a large variation in response times regarding LIKE queries to a particular table in my database. Sometimes I will get results within 20

8条回答
  •  名媛妹妹
    2020-11-22 01:21

    for what it's worth, Django ORM tends to use UPPER(text) for all LIKE queries to make it case insensitive,

    Adding an index on UPPER(column::text) has greatly sped up my system, unlike any other thing.

    As far as leading %, yes that will not use an index. See this blog for a great explanation:

    https://use-the-index-luke.com/sql/where-clause/searching-for-ranges/like-performance-tuning

提交回复
热议问题