On 2014年5月8日 GMT+08:00AM1:51:43, Clemens Ladisch <clem...@ladisch.de> wrote: >Simon Slavin wrote: >> On 7 May 2014, at 1:29pm, Woody Wu <narkewo...@gmail.com> wrote: >>> The 'explain query plan' gives same result for the first and the >second query: >>> >>> 0|0|0|SEARCH TAB mp USING COVERING INDEX sqlite_auto_index_mp_1 >(ntimereq<?) (~1 rows) >>> >>> BTW: I dont understand what the (~1 rows) mean. >> >> Literally "about 1 row". This is SQLite's estimate of how many rows >the 'mp' table has. > >Actually, the estimate of how many rows will match this search. > >SQLite assumes that such a comparison is useful for reducing the number >of result rows. In this case, the estimate is quite wrong. > >> You can let SQLite make a better estimate by using the 'ANALYZE' >command. > >Yes. However, even if a better estimate were to show that this index >is >not very useful, there would exist, at the moment, no better index >(with >id1 or id2 as the first indexed column). > > >Regards, >Clemens >_______________________________________________ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Do you mean that my index for this case is already the best choice? And, as a general question, for a query in the form of select max(a) from table where a < InF and b=B and c=C. what's the best index in the case of (1) B is an existed one, or (2) B is not exists ? -Woody Wu _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users