Preallocating Sequence Numbers
To increase the speed of database inserts, obtain a block of sequence numbers (by setting an allocation size) instead of executing a corresponding SELECT statement to obtain the newly assigned sequence number each time you create an object.
TopLink uses a default preallocation size of 50 when using a sequence table and 1 when using native sequencing.
- When using native sequencing in Sybase, SQL Server, or Informix databases, preallocation cannot be set - it is always 1.
- When using native sequencing, you must set the preallocation size explicitly in the TopLink Mapping editor.
- When using native sequencing in an Oracle database, you can use pre-allocation only if an INCREMENT is set on the Oracle Sequence object (not the CACHE option). This increment must match the pre-allocation size specified in the TopLink Mapping editor. If the increment is set incorrectly, invalid and negative sequence numbers could be generated. The CACHE option specifies how many sequences are preallocated on the database server; the INCREMENT specifies the number that can be preallocated to the database client.
Tip: Oracle recommends using sequence preallocation because of its performance and concurrency benefits.
Related Topics
About TopLink Descriptors
Working with Descriptors
Setting Descriptor Information
Using Sequence Numbers with Entity Beans
Using Native Sequencing
Working with Sequencing
Creating the Sequence Table on the Database
Copyright © 1997, 2004, Oracle.
All rights reserved.