Simon Slavin <slav...@bigfraud.org> wrote:
> On 13 Sep 2011, at 1:07pm, François wrote:
> 
>> Can we consider that creating an index for an integer field is a good
>> practice if this field has at least 3 possible values ? Or more ?
> 
> It's about chunkiness, and which of the values you're looking for.
> 
> If all possible values are equally distributed, and you frequently look for a 
> particular value, the index will help even if you
> have only two possible values.  If you have almost all '2011' rows, and 
> you're searching for '2011', then the index won't help
> much.

Actually, the break-even point is roughly 1/10: an index helps if you are 
selecting 10% or fewer of the records in the table; otherwise, a linear scan is 
faster.
-- 
Igor Tandetnik

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

Reply via email to