主权项 |
1. A method comprising:
storing a database that includes a plurality of database columns that each include a plurality of entries each having a respective value, wherein the plurality of database columns includes a first column; associating a first lock with a first lock portion of the database; associating a second lock with a second lock portion of the database, wherein the second lock portion does not overlap the first lock portion of the database and wherein the first lock portion of the database is more frequently updated than the second lock portion of the database; accumulating a plurality of first updates, each first update being an update to a value in the first lock portion of the database, prior to acquiring the first lock, until a first predetermined update aggregation rule is satisfied; in response to determining that the first predetermined update aggregation rule is satisfied, acquiring the first lock associated with the first lock portion of the database and then updating the database by applying the accumulated first updates to the first lock portion of the database; accumulating a plurality of second updates, each second update being an update to a value in the second lock portion of the database, prior to acquiring the second lock, until a second predetermined update aggregation rule is satisfied; in response to determining that the second predetermined update aggregation rule is satisfied, acquiring the second lock associated with the second lock portion of the database and then updating the database by applying the accumulated second updates to the second lock portion of the database; and associating one or more third locks with respective third lock portions of the database, wherein the third lock portions do not overlap each other, the first lock portion, or the second lock portion of the database, wherein the third lock portions are more frequently updated than the second lock portion, and wherein more frequently updated values are distributed across the first lock portion and one or more third lock portions to avoid lock contention. |