Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Select from sequence and then insert into table intermittently takes more time

3471614Jun 8 2017 — edited Jul 26 2017

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

CREATED16/NOV/16
LAST_DDL_TIME30/JAN/17
SEQUENCE_OWNERABC_DEV_OWNER
SEQUENCE_NAMEABC_SUCCESS_SEQ
MIN_VALUE1
MAX_VALUE9999999999999999999999999999
INCREMENT_BY1
CYCLE_FLAGN
ORDER_FLAGN
CACHE_SIZE1000
LAST_NUMBER238607333
PARTITION_COUNT
SESSION_FLAGN
KEEP_VALUEN

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?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2017
Added on Jun 8 2017
32 comments
5,440 views