Baruch Burstein wrote: > If I have an index on table1(colA, colB), will it be used for both the > where and the order by in either of these cases: > > select * from table1 where colA=1 order by colB; > select * from table1 where colB=1 order by colA;
$ sqlite3 sqlite> create table table1(colA, colB, [...]); sqlite> create index i on table1(colA, colB); sqlite> explain query plan select * from table1 where colA=1 order by colB; 0|0|0|SEARCH TABLE table1 USING INDEX i (colA=?) sqlite> explain query plan select * from table1 where colB=1 order by colA; 0|0|0|SCAN TABLE table1 USING INDEX i In the second query, the database reads colB1 from the index, but this happens for _all_ rows, so the WHERE is not sped up. Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users