Patent ID: 7801844

Claim:
A method performed by a surrogate key domain component that is executed by a processor for generating surrogate keys using a surrogate key domain table that is stored in a database, the method comprising: sending a first request to a surrogate key domain table for a first quantity of surrogate key values; in response to the request, acquiring a lock on the surrogate key domain table, the surrogate key domain table comprising a database object in the database, the surrogate key domain table including values representing an increment, a current seed, and a cache size to be used by the surrogate key domain component to generate surrogate keys to assign to records that are to be inserted into the database; upon acquiring a lock on the surrogate key domain table, querying the surrogate key domain table for the increment, the current seed, and the cache size; receiving the identity of a first starting value as identified by the current seed; reserving a first sequence of the first quantity of values by performing the following: assigning the value of the current seed to a current key of the surrogate key domain component, the current key representing the value to be used for the next surrogate key generated by the surrogate key domain component; determining a maximum value for the current key based on the value of the current seed and the cache size; writing a new value to the current seed of the surrogate key domain table, the new value being the sum of the current seed, the cache size, and the increment; and wherein the method further comprises: for each record of a set of records to be inserted into the database, performing the following: creating a surrogate key for the record that is equal to the value of the current key; incrementing the value of the current key by the increment; and inserting the record into the database; after assigning a surrogate key to each of the records, determining whether the value of the current key is less than the maximum value; upon determining that the value of the current key is less than the maximum value, querying the surrogate key domain table for the current value of the current seed; comparing the current value of the current seed to the new value that was written to the current seed previously to determine whether another process has obtained the increment, the current seed, and the cache size from the surrogate key domain table since the surrogate key domain component obtained the increment, the current seed, and the cache size; and upon determining that the current value of the current seed is the same as the new value, writing the value of the current key to the current seed thus allowing the unused values to be subsequently used as surrogate keys.