Subject Re: [firebird-support] Re: table backward read (performence time are bad)
Author Helen Borrie
At 12:02 AM 28/03/2007, you wrote:

>I´ve changed the key to none compound index key.
>
>is now ID......
>
>bat the result is diminish a with compound indexes.......
>
>here the info for this test....
>
>
>SELECT FIRST 1 max(id)
> FROM ORDER_HEADER WHERE id < 844429225399265

This is a nonsense query, since FIRST 1 MAX(id) is illogical.

Use FIRST n to get the first n record of an ordered set.

Two different queries here, depending on the
uniqueness or otherwise of your search key:

1. If id is unique then you want
max(id) where id < 8444.......

2. If id is not unique, then you want
FIRST 1 id where id < 844....


>I think no good idea to search backwards inside the firebird
>database.

There's no such thing as "searching backwards" or
"searching forwards". There are different kinds
of searches, for which top-down indexes may help
sometimes. Therefore, know your data and provide
top-down indexes if you know you have places
where the optimizer might be helped by them.

I think good idea to get hold of a book on SQL -
or at least read the v.1.5 release notes to
understand what SELECT FIRST n does and how to use it.

./heLen