Subject | Re: [firebird-support] Re: MAX(ID) Performance |
---|---|
Author | Helen Borrie |
Post date | 2009-10-24T20:11:13Z |
At 12:02 AM 25/10/2009, you wrote:
To find MAX(ID) efficiently you add the DESCENDING *index*. The DESC index does not affect the existing ASC index.
You also wrote:
ORDER BY ID is the same as ORDER BY ID ASC
If the optimizer decides to use an index for the ascending sort, it will use the ascending index.
The optimizer would consider the DESCENDING index only if the sort was specified as ORDER BY ID DESC
It won't use the DESC index for an ASC order plan.
./hb
>Hi Helen,If the primary key is ID, it has an ASCENDING index created for it automatically.
>>
>> Missing a DESCENDING index on ID?
>
>This tip is very helpful and now performance are much better, but now I have MIN(ID) problem, if I set up primary key like it is and create new index on sam filed but DESC is this will be best solution form my problem?
To find MAX(ID) efficiently you add the DESCENDING *index*. The DESC index does not affect the existing ASC index.
You also wrote:
>Ok, this trick is solved my problem for now, but I have same ordering details by ID field where I musn't use DESC indexing.By default, ORDER BY sorts in ascending order. So
ORDER BY ID is the same as ORDER BY ID ASC
If the optimizer decides to use an index for the ascending sort, it will use the ascending index.
The optimizer would consider the DESCENDING index only if the sort was specified as ORDER BY ID DESC
It won't use the DESC index for an ASC order plan.
./hb