Subject | Re: How to mix ascending and descending fields in one index |
---|---|
Author | kokok_kokok |
Post date | 2009-10-08T13:19:33Z |
Yes, if I have the index (a,b)
select * from FOO order by A, B
uses this index and the result comes at the moment.
If I do not have any index, the results comes in 20 seconds because the plan uses natural plan.
It is normal.
My problem is that I need to do:
select * from FOO order by A desc, B
I would like to create a mix index to be used and then to get the results at the moment, like other SQL platforms I can create a index(a desc, b), but I do not see the way in Firebird since I only can use the "desc" attribute for the entire index -> desc (a,b)
Thanks
select * from FOO order by A, B
uses this index and the result comes at the moment.
If I do not have any index, the results comes in 20 seconds because the plan uses natural plan.
It is normal.
My problem is that I need to do:
select * from FOO order by A desc, B
I would like to create a mix index to be used and then to get the results at the moment, like other SQL platforms I can create a index(a desc, b), but I do not see the way in Firebird since I only can use the "desc" attribute for the entire index -> desc (a,b)
Thanks
> Did you try "select * from FOO order by A, B" with and without
> index? Did you notice any difference?
> There's problably nothing to gain by using an index for sorting -
> rather something to lose.
> You'll need to read all the records, and the fastest way to do this
> is to let Firebird use "natural" (and sort afterwards).
> As Martijn wrote: use indexes for filtering records, not for ordering.
>
> --
> Aage J.
>