At 18:39 10.06.2003, Paulo Jan said:
--------------------[snip]--------------------
>Hi all:
>
> I have here a table belonging to a message board (Phorum 3.3), and
>there's an index in it that is not being used for reasons that I don't
>understand. The table is:
>
> ...
>
> select max(id) from todocinetv;
--------------------[snip]--------------------
Your question has already been answered, but:
I suspect that you're doing this to retrieve the row ID of a newly inserted
row. This may not be foolproof since others could already have inserted
rows in between your insertion and this ID lookup.
Assuming that you're using a sequence to provide the primary key (which you
should) you may safely query its current value:
SELECT currval('todocinetv_id_seq') as "newid"
This is guaranteed to return the last value **for your connection** only,
regardless if the sequence has actually been incremented by others or not.
And it's lightning fast.
Just my 2c :)
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/