On Sat, 1 Feb 2014 11:21:45 -0500
Stephen Chrzanowski <pontia...@gmail.com> wrote:

> Would be interesting to see when and where that single index comes
> into play when multiple indexes are defined.

create table T (t int primary key, a int , b int);
create index Ta on T(a);
create index Tb on T(b);

select * from T where a < 1 or b < 1

Using one index, pick your poison.  You could use Ta or Tb, but for the
other half of the OR you'll have to scan the table.  So you might as
well scan the table and forget about the index.  

Using two indexes, you can find the matching values in Ta and Tb, and
produce results from the union of the two.  

For 10 rows, the two-index algorithm is likely slower.  For a million
rows, depending on the cardinality of the data, it could be
significantly faster.  

--jkl
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to