Hello

MS> The second index should be:
MS> CREATE INDEX IDX2 on tx(type, name ASC);

MS> What I had meant to ask was whether there is any benefit in having two 
MS> indexes when one of the indexes is exactly within the other.

MS> IDX1 is index on 'name ASC' while IDX2 is an index on 'type, name ASC' - 
MS> does this mean that in a sense IDX1 is a subset of IDX2 and can be removed?

If you wanted to have just one index, rather than two, then you could 
have:

CREATE INDEX idx ON tx(name ASC, type);

With the columns in this order (name followed by type), the index will be 
used for queries which have either just name, or both name and type in 
their WHERE clauses.

I think this is what this page is saying in sections 1.0 and 1.1:

http://www.sqlite.org/optoverview.html

If you had an index (type, name ASC), then a query which used column name, 
but didn't use column type would not get to use the index.

So, yes you could get away with one index.

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

Reply via email to