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
I also have the same issue with org.xerial/sqlite-jdbc "3.25.2"
. A simple TEXT based index is not getting used with LIKE operator. But, if I put =
, the index gets used. My table schema :
create table if not exists test (ID INTEGER PRIMARY KEY, VALUE TEXT NOT NULL)
create index test_idx on test(value)
insert into test (ID, VALUE) values (1, 'gold bangles')
insert into test (ID, VALUE) values (2, 'gold bandana')
insert into test (ID, VALUE) values (2, 'gold bracelet')
explain query plan select * from test where value='gold bandana'
Output:
0|0|0|SEARCH TABLE test USING COVERING INDEX test_idx(VALUE=?)
explain query plan select * from test where value like 'gold%'
Output:
0|0|0|SCAN TABLE test