Subject | Re: [firebird-support] Re: Generators for auto-increment - with override |
---|---|
Author | Ann W. Harrison |
Post date | 2005-01-09T00:14:51Z |
Daniel L. Miller wrote:
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
> Assuming I trust any manually specified id - sometimes I'm paranoidPeople familiar with Firebird are very hesitant to use a MAX check
> 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.
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