PostgreSQL
PostgreSQL#
The starting value of the sequence migrated to Altibase is set higher than the intended value.#
Cause#
This issue may occur when a migration is performed while there are active sessions using sequences in PostgreSQL. PostgreSQL sequences are cached on a per-session basis, and a number of values are pre-generated each time a session connects, based on the 'CACHE * INCREMENT BY' setting. For example, if a sequence is created with START WITH 1, INCREMENT BY 1, and CACHE 100, performing SELECT NEXTVAL('seq_name') will return 1 in the first session, but 101 in the second session. Due to this caching behavior of PostgreSQL sequences, when migrating to Altibase, the starting value (START WITH) of the sequence is increased by 'CACHE * INCREMENT BY * (number of sessions - 1) + START WITH'.
Solution#
Before performing the migration, all application sessions connected to PostgreSQL must be terminated.