Database Auto-Increment ID Generation via Partition Segmentation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing database systems face challenges in achieving strict serial auto-increment of primary key columns while maintaining high concurrency, as conventional auto-increment functions either compromise concurrency performance or fail to ensure seriality.
Innovation Solution
A database processing method that involves generating auto-increment identifiers for transactions in a specific order and writing them into the database, allowing for independent management of auto-increment IDs across partitions, ensuring that each transaction's data rows receive IDs that are sequentially increasing, even in high-concurrency environments.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If table-level auto-increment lock is used to ensure serial increment, then serial auto-increment is guaranteed, but concurrency performance is severely affected
Solution Approach 1:
The patent divides the database into multiple partitions, with each partition maintaining its own auto-increment ID counter. This segmentation allows different partitions to generate auto-increment IDs independently and concurrently, eliminating the need for table-level locking while ensuring serial increment within each partition.
Solution Approach 2:
The patent pre-generates batches of auto-increment IDs for each partition before actual data insertion occurs. This preliminary action allows the system to have auto-increment IDs ready in advance, enabling high-concurrency insert operations without requiring locks during the actual insertion process.
2Productivity
If lightweight lock is used to allow high-concurrency, then concurrency performance is improved, but serial auto-increment cannot be ensured
Solution Approach 1:
By segmenting the auto-increment ID generation into separate counters for each partition, the system allows multiple partitions to operate concurrently with lightweight locks while maintaining serial increment within each partition through dedicated counters.
3Reliability
If serial auto-incrementing is implemented by executing all operations in serial, then serial auto-increment is ensured, but concurrency performance is reduced and database becomes unavailable in highly concurrent applications
Solution Approach 1:
The patent segments the database into multiple partitions, allowing concurrent operations across different partitions while maintaining serial auto-increment within each partition. This enables the database to handle high-concurrency workloads without sacrificing serial increment guarantees.
Solution Approach 2:
The patent introduces partition-level counters as intermediaries between the global concurrency system and local serial increment requirements. These counters act as mediators that enable concurrent access across partitions while ensuring serial increment within each partition without requiring global serialization.
Data Source
AI summary
Embodiments of the disclosure provide a database processing method, a database processing apparatus, and an electronic device. The database processing method can include: providing a plurality of transactions to a transaction queue, wherein each transaction of the plurality of transactions includes an encapsulated write request for writing data into a database; generating auto-increment identifiers (IDs) for data rows of the data corresponding to the plurality of transactions according to an order of the transactions in the transaction queue; and writing the data into the database according to the auto-increment IDs assigned to the data rows of the data in the transaction.


