Subject Re: [firebird-support] Limit for Index Statistics?
Author Ivan Prenosil
> There is a value of statistics for check if an index is usefull or table
> scann is better?
>
> es.
>
> STAT >=0.003 index isn't usefull (TABLE SCAN is better)
> STAT <=0.0029 index is usefull (Indexed search is better)

If there were such simple answer, Firebird itself could reliably decide
when to use index and when not.

Apart from the fact that indexes are used for different tasks
(search, join, sort), and that there are several criterions for deciding
when to use index (total query speed, time to get first record,
size of temporaty files created, RAM requirements, CPU requirements,
select speed vs. update speec, etc.), there are many variables that determine
usefullness of index - selectivity, number of rows, row size,
page size, data distribution, query type, etc.

Examples:
Imagine the query that will return about 1% of rows.
If the rows are so small/narrow that 200 rows will fit on data page,
than 2 rows on average will be read from each datapage,
and so using of index will not reduce number of i/o operations.
If the rows are so big/wide that only 5 will fit on data page,
than using of index will reduce i/o operations by factor 20 !
In both cases the selectivity can be the same.

Or imagine table with boolean values - if you have 50 rows
with True, and 1000000 rows with False, using index
for locating True values makes sense, despite poor selectivity.

Ivan
http://www.volny.cz/iprenosil/interbase/