Subject | Re: [ib-support] Select max(id) is slow ? |
---|---|
Author | Ann W. Harrison |
Post date | 2001-09-18T14:59:53Z |
At 11:48 AM 9/18/2001 +0200, Carsten Schäfer wrote:
so that it only adds the primary key if that field is null - that's
just for insurance and to take care of cases when they key isn't
needed. Set up a procedure to invoke the generator and use
that procedure from your program to get the value for the primary key.
unless you have a descending index on the field. Second, it's not
reliable, especially if you use the read-committed transaction mode.
Someone else may have stored a row after yours, and you'll get that
number rather than the one you stored.
Regards,
Ann
www.ibphoenix.com
We have answers.
>Now i want to put the new id that is given from the generator in myAt the moment, the only way to do that is to change your trigger
>object that was inserted.
so that it only adds the primary key if that field is null - that's
just for insurance and to take care of cases when they key isn't
needed. Set up a procedure to invoke the generator and use
that procedure from your program to get the value for the primary key.
>I use 'select max (id_apos) from t_apos' to get the highest id fromFirst, yes that is slow. InterBase reads every row to get the MAX
>the table (insert and select in one transaction).
unless you have a descending index on the field. Second, it's not
reliable, especially if you use the read-committed transaction mode.
Someone else may have stored a row after yours, and you'll get that
number rather than the one you stored.
Regards,
Ann
www.ibphoenix.com
We have answers.