Subject Re: [firebird-support] Re: Index for ascending and descending order?
Author Ann W. Harrison
svanderclock wrote:
>> Once again: you don't.
>> Indexes are useful for data filtering. For ordering they are less useful.
>
> what???? of course not !! for ordering index can be very very important !! if
> you have a result set of 1.000.000 record and want to diplay only the 200 last
> items, and also you are a web server than handle thousand of request every second,
> how you do if you don't have index on ordering ???

By selecting the last 200 on some identifiable criteria and not
selecting 999,800 records you don't want.

>
> It's easy : if you result set is little then it's better to use the index in
> the filtering, if you result set is important it's better to use the index
> on the ordering ! this thing like this, the optimizer can't choose the best
> way, and this why we MUST sometime use ourself the PLAN ! i see some query
> that can go from 1 minute to 0.1 seconde depend of with way you choose
>

Even if your result set is large, you'll finish the whole operation
faster by selecting and sorting. Retrieving records in index order
is faster if you care only about the time to get the first record.

Good luck,

Ann