Sequence MAXVALUE Example Calculations
It is a requirement of the ID configuration implementation, that sequence max values are calculated and provided in the sequence creation script 02-NewID.sql.
MAXVALUE can be calculated with the following formula:
MAXVALUE = 2^63 / ( PRIMARY_ID_GRP_SIZE * SECONDARY_ID_GRP_SIZE)
For reference, the MAXVALUE of a sequence is used to generate the
ID offset, through the following formula:
IDOffset = ((PRIMARY_ID_GRP_NUM * SECONDARY_ID_GRP_SIZE) + SECONDARY_ID_GRP_NUM) * MAXVALUE
Decimal Ranged Example
For 10 instances and 20 partitions (200 ID regions):
MAXVALUE = 2^63 / (10 * 20) = 46116860184273879
User may wish to round down for convenience to 46000000000000000, or 40000000000000000.
Binary Ranged Example
For 8 instances and 32 partitions (256 or 2^8 ID regions):
Assume the user wishes to make full use of the ID range, therefore no rounding down in this example.
MAXVALUE = 2^63 / 256 = 36028797018963968
or
MAXVALUE = 2^63 / 2^8 = 2^55