Home > database >  Under the high concurrency, oversold goods
Under the high concurrency, oversold goods

Time:04-27

Under the concurrent, how to solve the commodity oversold, request how great god in the database layer optimization?

CodePudding user response:

Add a timestamp timestamp field optimistic locking, program came in to check inventory quantity of timestamp values
 
The select timestamp from store name='watermelon'

Find out timestamp=11111
To update the stock
 
The update store set amount=amount - 1 where timestamp=11111 and name='watermelon'

The update is successful effects & gt; 0, deduct success means the inventory

CodePudding user response:

Bosses have practical application?
  • Related