Subject Re: [firebird-support] Re: Generators for auto-increment - with override
Author Ann W. Harrison
Daniel L. Miller wrote:

> Assuming I trust any manually specified id - sometimes I'm paranoid
> enough that I don't even trust myself. The max() check was the simplest
> way I came up with to guarantee the validity of the id.

People familiar with Firebird are very hesitant to use a MAX check
because it requires a full table scan unless the field has a descending
index. Primary key indexes are ascending. (Interesting question... what
would break if we changed that?) Pierre Y. (?) suggested comparing
the key provided to the current generator value and incrementing the
generator by the difference if the key provided was larger. That works
and doesn't involve reading all the records in the table whenever a key
is provided.

Regards,


Ann