On 7 May 2010, at 10:47pm, Raeldor wrote: > I have 2 individually indexed fields. I have a select statement... > > select * from table1 where field1='x' and field2='y' > > this takes about 10 sections, yet if I do... > > select * from table1 where field1='x' > > it's instant, and if i do... > > select * from table1 where field2='y' > > it's also instant. What's going on here?!
Your fields are indexed individually. Having used one of the indices to satisfy one of the requirements, SQLite has to search through the records it found one by one to find out which fit the other requirement. Make an index which includes both fields CREATE INDEX ON myTable (field1, field2) and SQLite will magically figure out that this new index will let it satisfy both requirements in one search. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users