Kelly Jones wrote:
> I have a query that runs very quickly and returns no results:
> 
> SELECT * FROM filebackup WHERE sha1='x';
> 
> However, the more restrictive query below runs very slowly, although
> it obviously can't have any results either:
> 
> SELECT * FROM filebackup WHERE sha1='x' AND refid=0;
> 
> I have indexes on both sha1 (string) and refid (int). Only issue I
> see: this is a large table and refid=0 for 90%+ of the rows.

For whatever reason, SQLite decides to use an index on refid for this query. 
You can suppress it like this:

SELECT * FROM filebackup WHERE sha1='x' AND +refid=0;

Igor Tandetnik

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

Reply via email to