On 8/9/2017 10:50 AM, Wout Mertens wrote:
in experimenting with indexes I found that if you create an index on (a, b)
and then SELECT * FROM data WHERE a = 1 AND B = 2, it will use the index,
However, if you write SELECT * FROM data WHERE a = 1, it won't use the
Are you sure? How do you determine that? My experience is different.
Case in point, I have an app that allows searching across 4 of parameters,
and I am wondering if I could just use a single 4-valued index
If you have an index on (a, b, c, d), it'll help for conditions like "a=1" or "a=1 and b=2" or "a=1 and b=2 and
c=3" - conditions that use a prefix on an index. But it won't help with "b=2" or "c=3" or "b=2 and c=3".
Think of it this way. Imagine you have a phone book, with entries sorted by last name and
then first name. In this book, it's easy to find people named "Smith, John", or
all people with last name of Smith - but it won't at all help to find all people with
first name of John.
sqlite-users mailing list