Home > database >  Oracle mass index for function optimization
Oracle mass index for function optimization

Time:09-15

business scenario : we have an interface to improve to a third party calls, call frequency above 500 w + times a day, need to return one based on
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 LinkedBlockingBatchMsgIdQueue=new LinkedBlockingQueue (10000);


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:

  • Related