SQLite Forum

LIKE optimization - limitation to string literals
Login
You could just declare an index properly:

CREATE INDEX t1_name ON t1(name collate nocase);

getting rid of the current extraneous name_simple column and t1_name_simple index, not futz with the case_sensitive_like setting and merely do:

select * from t1 where name like 'A%';  
-- or --  
select * from t1 where name like 'a%';

which will then work correctly and use the index since the RHS is now used directly and the provided value does not start with a wildcard.

If you really want to have a name_simple column defined like that for some reason, then simply fix your index (`create index t1_name_simple on t1 (name_simple collate nocase)`), get rid of the diddling with the case_sensitive_like setting, and simply:

select * from t1 where name_simple like 'A%';  
-- or --  
select * from t1 where name_simple like 'a%';

Neither of these have any requirement for diddling in the dark.