Dear Experts,
I have a insert into a table script running in my code and this table has the primary key value coming in from a sequence.
Thus before every insert into a table, a select to sequence is fired to get the next sequence value and then the insertion happens.
My application is running in parallel on 4 clusters and processing on an average 300 transactions per second. Thus per second there will be 300 inserts into the table thus 300 selects from sequence
This works well for few hours and the select from sequence and insert into table takes between 5 to 10 milliseconds.
However every few hours this slows down for a fraction of second and the select from sequence and insert into table takes 3 to 4 seconds for around 7 to 8 transactions and thus the processing time of these 7 to 8 transaction takes more than 1 second where as my requirement is that each transaction should be processed within a second.
After that fraction of second, it again starts working well.
Would anyone have an idea why for a fraction of second every few hours the select from sequence and the insert into table slows down?
I am fine if the sequence has GAPS, my only requirement is they should be unique as the sequence number is the only primary key to my table
Data Base Oracle:
Sequence definition
CREATED | 16/NOV/16 |
LAST_DDL_TIME | 30/JAN/17 |
SEQUENCE_OWNER | ABC_DEV_OWNER |
SEQUENCE_NAME | ABC_SUCCESS_SEQ |
MIN_VALUE | 1 |
MAX_VALUE | 9999999999999999999999999999 |
INCREMENT_BY | 1 |
CYCLE_FLAG | N |
ORDER_FLAG | N |
CACHE_SIZE | 1000 |
LAST_NUMBER | 238607333 |
PARTITION_COUNT | |
SESSION_FLAG | N |
KEEP_VALUE | N |
Table column:
TX_ID NOT NULL NUMBER (Primary Key)
Java hibernate code that ensures a select is fired for every insert
@Id
@SequenceGenerator(name = "ABC_SUCCESS_SEQ",
sequenceName = "ABC_SUCCESS_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "ABC_SUCCESS_SEQ")
@Column(name = "TX_ID")
private Long transactionId;
I tried to increase the cache of sequence to 1000 and it helps but still there are few burst of transaction every few hours that take time and the reason is because for fraction of seconds the select from sequence and insert into table takes time.
Can anyone suggest anything?