sqlite not using index with like query

前端 未结 4 1919
别那么骄傲
别那么骄傲 2021-02-19 10:27

Ive been trying to get sqlite to use an index with a like to no avail. Ive tried collate nocase and still no luck. Anyone have any ideas on how to get sqlite to do a like hittin

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-19 11:05

    From the docs:

    Terms that are composed of the LIKE or GLOB operator can sometimes be used to constrain indices. There are many conditions on this use:

    • The left-hand side of the LIKE or GLOB operator must be the name of an indexed column with TEXT affinity.
    • The right-hand side of the LIKE or GLOB must be either a string literal or a parameter bound to a string literal that does not begin with a wildcard character.
    • The ESCAPE clause cannot appear on the LIKE operator.
    • The built-in functions used to implement LIKE and GLOB must not have been overloaded using the sqlite3_create_function() API.
    • For the GLOB operator, the column must be indexed using the built-in BINARY collating sequence.
    • For the LIKE operator, if case_sensitive_like mode is enabled then the column must indexed using BINARY collating sequence, or if case_sensitive_like mode is disabled then the column must indexed using built-in NOCASE collating sequence.

提交回复
热议问题