In a JPA/Hibernate application using native Oracle sequences, is it better to use a single global sequence like hibernate_sequence
, or to define a separate sequence per table?
It seems like a single sequence is easier to maintain, but could make troubleshooting or ad hoc queries harder by making longer ID's.
Show activity on this post. I found the answer: "Sequence numbers are generated independently of tables, so the same sequence can be used for one or for multiple tables."
NOCYCLE. Specify NOCYCLE to indicate that the sequence cannot generate more values after reaching its maximum or minimum value. This is the default. CACHE. Specify how many values of the sequence the database preallocates and keeps in memory for faster access.
Common sequence words are first, next, second, meanwhile, suddenly, and finally. 'First' signals the first thing someone did in a story or the first step in a procedure. 'Next' signals the next event in a story or the next step in a procedure.
The difference between auto-increment columns in SQL Server and sequences in Oracle is that: In SQL Server, you mark a column as an auto-increment column and SQL Server automatically generates new values for the column when you insert a new row.
Although cacheing alleviates it, a sequence can cause contention when multiple sessions require nextvals. If you have one sequence serving all tables then all inserts on all tables will contend for the same sequence. If you are after performance, one sequence for each table will give less contention.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With