Subject Re: [firebird-support] MAX(ID) Performance
Author Thomas Steinmaurer
> I have one table into firebird (2.1.3) databse with structure:
> ID - integer (keyfield)
> NAME - varchar (indexed)
> DESCRIPT - varchar
> and about 3.000.000 records in it.
>
> I don't want to say that Oracle Express Edition is better than FirebirdSQL but when I call
>
> SELECT MAX(ID) FROM TABLE1
>
> Oracle returns 3.005.101 for a 2 secounds
> Firebird returns 3.005.101 for a 10min and 15 secounds on same machine
>
> What is wrong with Firebird in my case?

You need an DESCENDING index on ID.

Btw, if you need that to do something like MAX(ID) + 1 for implementing
an auto-increment thingy, then you'd better try generators in Firebird.
Aka sequences in Oracle.


--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com
My blog:
http://blog.upscene.com/thomas/