Nonstop Database, HiRDB Version 9 UAP Development Guide

[Contents][Index][Back][Next]

4.19.2 Defining a sequence generator

You use CREATE SEQUENCE to define a sequence generator. For details about CREATE SEQUENCE, see the manual HiRDB Version 9 SQL Reference.

The following shows an example of a definition of a sequence generator:

 
CREATE SEQUENCE SEQ1..........1
  AS INTEGER..................2
  START WITH 10...............3
  INCREMENT BY 10.............4
  MAXVALUE 999................5
  MINVALUE 10.................6
  CYCLE.......................7
  LOG INTERVAL 3..............8
IN RD01.......................9
 

Explanation:
  1. Defines sequence generator SEQ1 consisting of conditions 2 through 9.
  2. Data type
  3. Start value
  4. Increment value
  5. Maximum value
  6. Minimum value
  7. Cycle specification
    Cycles the numbers so that the maximum value (999) is followed immediately by the minimum value (10) with an increment value of 10.
  8. Log output interval
  9. Storage RDAREA name
Note
When the cycle specification is used, the sequence generator is capable of generating duplicate sequence numbers.
Organization of this subsection
(1) Specifying the sequence generator storage RDAREA
(2) Specifying the log output interval

(1) Specifying the sequence generator storage RDAREA

When you define a sequence generator, you can specify any RDAREA for the storage for the sequence generator that satisfies the following conditions:

Notes
  • In a HiRDB/Parallel Server, if the sequence generator and the table that uses the sequence generator (and which is not partitioned among multiple servers) are stored in separate servers, communication will occur each time the sequence generator is used, which will have an adverse effect on performance. For a table that is partitioned among multiple servers, you might be able to reduce the overhead for communication by storing the sequence generator and the table that uses the sequence generator in an RDAREA on the same server. Therefore, we recommend that you store a sequence generator and the table that uses the sequence generator in an RDAREA on the same server.
  • The inner replica facility cannot be used on an RDAREA that stores a sequence generator.

(2) Specifying the log output interval

You can improve performance by how you specify the log output interval when you define the sequence generator.

Sequence generator logs are output at the following times:

The following figure shows an example of a sequence generator for which a log output interval is specified.

[Figure]

Notes
  • Setting a small value for the sequence generator's log output interval will reduce the number of skipped numbers in the event of a system failure, but performance will be affected adversely because the number of log output operations is increased. On the other hand, if you set a large value for the log output interval, more numbers will be skipped in the event of a system failure, but performance will be improved because you reduce the number of log output operations.
  • The maximum number of skipped numbers will be the same as the value specified for the log output interval.