$ sqlite3 SQLite version 3.8.4.3 2014-04-03 16:53:12 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> create table t(a, b, c); sqlite> create index t_ab on t(a, b); sqlite> create index t_ac on t(a, c); sqlite> explain query plan select * from t where a = 1 and (b = 2 or c = 2); 0|0|0|SEARCH TABLE t USING INDEX t_ac (a=?) sqlite> explain query plan select * from t where (a = 1 and b = 2) or (a = 1 and c = 2); 0|0|0|SEARCH TABLE t USING INDEX t_ab (a=? AND b=?) 0|0|0|SEARCH TABLE t USING INDEX t_ac (a=? AND c=?)
Although the two queries are equivalent the first form is not optimized to use available indices. Is this expected? -- Abramo Bagnara BUGSENG srl - http://bugseng.com mailto:[email protected] _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

