Subject | Re: [firebird-support] Re: Firebird 2.1.3 optimizer in does not use index - Email found in subject |
---|---|
Author | Ann W. Harrison |
Post date | 2010-07-20T16:07:56Z |
Ismael L. Donis GarcĂa wrote:
generally faster to retrieve records in storage order and
sort them than to retrieve them in sorted order. More locality,
fewer disk reads, that kind of thing.
select first 10000 t1.s1
from t1 left join t2 on t1.s1=t2.s1
order by t1.s1
That will almost certainly use both indexes, because the more
usual
select first 10 t1.s1
from t1 left join t2 on t1.s1=t2.s1
order by t1.s1
Reading ten records in index order is likely to be faster than
reading ten thousand records in storage order, sorting them,
and throwing out the last 9990 of them.
Good luck,
Ann
> select t1.s1 from t1 left join t2 on t1.s1=t2.s1 order by t1.s1Maybe that will use the t1 index - but probably not. It's
>
generally faster to retrieve records in storage order and
sort them than to retrieve them in sorted order. More locality,
fewer disk reads, that kind of thing.
select first 10000 t1.s1
from t1 left join t2 on t1.s1=t2.s1
order by t1.s1
That will almost certainly use both indexes, because the more
usual
select first 10 t1.s1
from t1 left join t2 on t1.s1=t2.s1
order by t1.s1
Reading ten records in index order is likely to be faster than
reading ten thousand records in storage order, sorting them,
and throwing out the last 9990 of them.
Good luck,
Ann