Oracle sequence on the resulting id to a third party, (the id back to a relational table as the primary key id)
optimize code logic before :
Every time the third party call interface and performs a database query operation
Seelct seqName.. Nextval from dual
The optimized
the first step is to set up a queue
Private static LinkedBlockingQueue
the second step, one-time generated from 500 to 1000 id
The select seqName. Nextval as msgid from (select 1 from all_objects where rownum & lt;=? )
- rownum can after pressure testing, based on the database to draw a best value my side is configured to 1000 calls a time-consuming at about 50 milliseconds
Get completed cycle in the linkedBlockingBatchMsgIdQueue
the third step, the queue to get id
LinkedBlockingBatchMsgIdQueue. Poll ()
other solutions
Use redis on the id, so that more efficient high, considering we all need the sequence, there are multiple components based on the existing business must do a synchronization, after comprehensive consideration, adopt the way of queue to optimize mass access database sequence
CodePudding user response:
Thanks for sharing!CodePudding user response: