A page extension method of a database and related product
By pre-allocating storage space and using an atomic commit mechanism, data is directly written to the physical storage area, solving the problems of redundant data copying and lock contention in database page expansion, thus improving expansion performance and concurrency capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CETC JINCANG (BEIJING) TECH CO LTD
- Filing Date
- 2026-02-27
- Publication Date
- 2026-06-05
AI Technical Summary
The existing database page expansion process suffers from increased CPU overhead and write latency due to redundant data copying, and lock contention caused by circular single-page expansion limits concurrent processing capabilities.
By pre-allocating storage space and adopting an atomic commit mechanism, the circular single-page expansion is transformed into a batch operation, directly writing the page initialization data to the physical storage area, bypassing the intermediate buffer, and dynamically adjusting the number of pages allocated by combining exclusive locking protection and load status awareness.
It reduces storage redundancy and CPU overhead, lowers write latency, improves the database's concurrent processing capabilities and fault recovery of expansion operations, and optimizes expansion efficiency and predictability.
Smart Images

Figure CN122152816A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to database technology, and in particular to a method for expanding database pages and related products. Background Technology
[0002] In database page expansion scenarios, from a storage perspective, the initial data of a new page is written sequentially to the database buffer and the operating system kernel buffer, forming multiple memory copies. This not only causes storage redundancy but also significantly increases CPU overhead and write latency due to multiple data copies. From a concurrency locking perspective, current database batch expansion is essentially achieved by repeatedly executing single-page expansion, which easily leads to severe lock contention and limits the database's concurrent processing capabilities. Summary of the Invention
[0003] One objective of this invention is to improve the performance of database page expansion by eliminating redundant data copying and reducing CPU overhead and write latency.
[0004] A further objective of this invention is to optimize the circular single-page expansion into atomic batch operations.
[0005] Specifically, the present invention provides a method for expanding database pages, comprising: Determine the actual number of pages allocated for expansion at the current moment based on the page expansion requests in the data table; In response to the actual number of pages allocated meeting the preset batch expansion conditions, storage space is pre-allocated based on the actual number of pages allocated for performing atomic commit operations; During the exclusive lock period of the storage space, the page initialization data of the data table is directly loaded into the storage space to complete the batch page expansion.
[0006] Optionally, the step of determining the actual number of pages allocated for expansion at the current moment based on the page expansion request of the data table includes: In response to a page expansion request for a data table, obtain the number of pages to be expanded as indicated by the page expansion request, as well as the current load status indicators of the database engine. The actual number of pages allocated for expansion at the current moment is determined based on the number of pages to be expanded and the load status indicators.
[0007] Optionally, in response to a page expansion request for a data table, the step of obtaining the number of pages to be expanded as indicated by the page expansion request includes: Historical extension records are obtained based on the source process identifier of the page extension request; Determine the average number of expanded pages in the historical expanded records within a preset time window, and determine the average number of expanded pages as the number of pages to be expanded.
[0008] Optionally, the step of determining the actual number of pages allocated for expansion at the current moment based on the number of pages to be expanded and the load status indicator includes: The number of pages to be expanded is determined as the base request quantity; The load adjustment amount is determined based on the load status index and the preset weighting factor corresponding to the load status index, wherein the preset weighting factor is obtained by performing a gradient descent operation on historical extended records. The number of candidate pages to be allocated is obtained by weighted summation of the basic request volume and the load adjustment volume. The number of candidate pages allocated and the preset expansion limit of the database are input into the minimum value function, and the output value of the minimum value function is determined as the actual number of pages allocated.
[0009] Optionally, after determining the actual number of pages allocated for expansion at the current moment based on the page expansion request of the data table, the method further includes: Determine whether the actual number of pages allocated is greater than or equal to a preset batch expansion threshold; If so, determine that the actual number of pages allocated meets the preset batch expansion conditions; If not, it is determined that the actual number of pages allocated does not meet the preset batch expansion conditions.
[0010] Optionally, the step of directly loading the page initialization data of the data table into the storage space to complete the batch page expansion includes: The storage space is defined as the multiple memory buffer pages corresponding to the actual number of allocated pages. During the validity period of the exclusive lock state of the storage space, a contiguous physical storage area is allocated for the data table; The page initialization data of the data table is written to the physical storage area using a direct access method; The page initialization data already written to the physical storage area is loaded in batches into the multiple locked memory buffer pages to complete the batch expansion.
[0011] Optionally, the database page expansion method further includes: in response to the actual number of pages allocated not meeting a preset batch expansion condition, performing cyclic single-page expansion based on the actual number of pages allocated.
[0012] According to another aspect of the present invention, a computer-readable storage medium is also provided, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the page expansion method for any of the above-described databases.
[0013] According to another aspect of the present invention, a computer program product is also provided, comprising a computer program that, when executed by a processor, implements the steps of any of the above-described database page expansion methods.
[0014] According to another aspect of the present invention, a computer device is also provided, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any database page expansion method.
[0015] The database page expansion method of this invention transforms the circular single-page expansion mode into a one-time batch operation by pre-allocating storage space and relying on an atomic commit mechanism. This eliminates the problem of expansion time increasing linearly with the number of pages, improving the efficiency and predictability of dynamic expansion of database storage space. Utilizing exclusive locking protection of storage space, page initialization data is directly loaded into the target storage area, bypassing the intermediate copying process between the database buffer and the operating system kernel buffer. This eliminates storage waste caused by multiple memory copies and avoids the additional CPU overhead and I / O latency introduced by multiple data copies. By placing the time-consuming storage allocation and I / O initialization outside the locking phase, it ensures that exclusive locking is only used to protect atomic commit operations, shortening the lock holding time, avoiding lock contention caused by I / O latency, and improving the database's concurrent processing capabilities.
[0016] Furthermore, the database page expansion method of the present invention, by simultaneously considering the number of pages to be expanded and the real-time database engine load status, can dynamically calculate the actual allocation number that best fits the current operating environment, so that page expansion can not only meet storage needs, but also actively avoid high load periods or resource bottlenecks, and avoid instantaneous performance impact caused by blind expansion.
[0017] Furthermore, the database page expansion method of the present invention, by pre-determining multiple memory buffer pages corresponding to the actual number of allocated pages as storage space and allocating contiguous physical storage areas during the exclusive locking period, ensures a continuous mapping between logical pages and physical storage space. This not only reduces the metadata overhead of subsequent page management but also improves the I / O efficiency of sequential data access after expansion. By using a direct access method to write page initialization data to the physical storage area, the dual buffering link of the database shared buffer and the operating system page cache is bypassed, avoiding data copying overhead and synchronization waits between multi-level caches, significantly reducing CPU usage and write latency. By batch loading the initialized physical storage data into the locked memory buffer pages, the page image in memory and the content in persistent storage are made consistent in a single atomic operation, ensuring the recoverability of the expansion operation in case of failure.
[0018] The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments of the invention in conjunction with the accompanying drawings. Attached Figure Description
[0019] The following sections will describe some specific embodiments of the invention in detail by way of example and not limitation, with reference to the accompanying drawings. The same reference numerals in the drawings denote the same or similar parts or portions. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings: Figure 1 This is a schematic flowchart of a database page expansion method according to an embodiment of the present invention; Figure 2 This is a schematic flowchart illustrating the current-moment expansion in a database page expansion method according to an embodiment of the present invention; Figure 3 This is a schematic flowchart illustrating the process of obtaining the number of pages to be expanded in a database page expansion method according to an embodiment of the present invention; Figure 4 This is a schematic flowchart illustrating the determination of the actual number of page allocations in a database page expansion method according to an embodiment of the present invention; Figure 5 This is a schematic flowchart illustrating the batch expansion condition setting in a database page expansion method according to an embodiment of the present invention; Figure 6 This is a schematic flowchart of a database page expansion method according to an embodiment of the present invention; Figure 7 This is a schematic diagram of a computer program product according to an embodiment of the present invention; Figure 8 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; Figure 9 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0020] In database page expansion scenarios, the initialization data of new pages must follow the existing double-buffered write process: First, the database process writes the initialization data, such as the zero page, into the database-specific buffer (e.g., shared_buffers). After the data is temporarily cached, the initialization data is copied from the database buffer to the operating system kernel buffer (page cache) through a system call. Finally, the operating system disk flushing process writes the data in the kernel buffer to the physical disk.
[0021] In the above process, the same initialization data forms multiple memory copies in the database buffer and kernel buffer, which not only causes memory storage redundancy and reduces memory utilization efficiency, but also significantly increases CPU processing overhead and prolongs data write latency due to multiple data copy operations across memory regions.
[0022] Meanwhile, the database batch expansion function is implemented by repeatedly executing single-page expansion logic. Therefore, the database needs to initiate a single-page expansion process for each page to be expanded sequentially. Each expansion requires acquiring a table-level expansion lock, allocating independent disk space, performing page loading and fixing operations, and releasing the lock resource after expansion is complete. This approach leads to frequent acquisition and release of expansion locks during batch expansion, causing intense lock contention. Many business requests are blocked while waiting for lock resources, severely limiting the database's concurrent processing capabilities. Furthermore, the multiple memory allocations and disk I / O operations cause the total overhead of batch expansion to increase linearly with the number of pages expanded, making the operation completion time unpredictable and increasing the difficulty of database maintenance.
[0023] The following description, with reference to the accompanying drawings, illustrates a database page expansion method and related products according to embodiments of the present invention.
[0024] Figure 1 This is a schematic flowchart of a database page expansion method according to an embodiment of the present invention, such as... Figure 1 As shown, the page expansion method for this database can generally include: Step S101: Determine the actual number of pages allocated for expansion at the current moment based on the page expansion request of the data table; Step S102: In response to the actual number of pages allocated meeting the preset batch expansion conditions, storage space is pre-allocated based on the actual number of pages allocated for performing atomic commit operations. Step S103: During the validity period of the exclusive lock state of the storage space, the page initialization data of the data table is directly loaded into the storage space to complete the batch page expansion.
[0025] In this embodiment, after receiving a data table page expansion request, the database parses the expansion scale parameters (such as the number of pages to be expanded, target storage capacity, etc.), request type parameters (such as regular dynamic expansion, batch special expansion, temporary table expansion, etc.) characterizing the request scenario attributes, and data table identifier parameters (such as data table OID, database name, table type identifier, etc.). Then, a parameter validity verification process is initiated, including: verifying whether the expansion scale parameter is a positive integer or a valid numerical range, whether the data table identifier exists and is in a normal state, and whether the request type belongs to a preset type supported by the database; if any parameter is invalid, missing, or mismatched, an exception response is returned and logged; if all parameters are valid, the process proceeds to the next step.
[0026] In this embodiment, the database engine's running status is collected in real time at a preset collection frequency through the database's built-in status awareness module. This includes the number of background processes waiting for the data table extension lock, the lock waiting queue length, the percentage of idle resources in the buffer pool, the usage rate of memory, the page replacement frequency, the disk I / O load level, the physical storage free capacity, the I / O response latency, the number of current concurrent transactions in the database, the CPU utilization rate, and the percentage of remaining system memory.
[0027] In this embodiment, an expansion strategy configuration set matching the data table identifier parameter and request type parameter is loaded from the database configuration data. This expansion strategy configuration set includes a maximum expansion scale threshold for a single batch, a minimum expansion scale threshold for a single batch, a batch trigger judgment threshold, and a weight coefficient for each running state (the weight coefficient is obtained by self-learning and iterative optimization based on the differences in resource requirements of the business scenario using a machine learning algorithm). The initial page allocation quantity is obtained by weighted summing of the expansion scale parameter, running state, and weight coefficient. The initial page allocation quantity is then checked against the maximum expansion scale threshold for a single batch, the minimum expansion scale threshold for a single batch, and the batch trigger judgment threshold in multiple dimensions: if the initial page allocation quantity exceeds the maximum expansion scale threshold for a single batch, the initial page allocation quantity is corrected to the maximum expansion scale threshold for a single batch; if the initial page allocation quantity is less than the minimum expansion scale threshold for a single batch, the initial page allocation quantity is corrected to the minimum expansion scale threshold for a single batch. The corrected initial page allocation quantity is used as the actual page allocation quantity for the current time of expansion. If the actual page allocation quantity is greater than or equal to the batch trigger judgment threshold, the actual page allocation quantity is determined to meet the preset batch expansion conditions; otherwise, the actual page allocation quantity is determined not to meet the preset batch expansion conditions.
[0028] In this embodiment, when the actual number of page allocations meets the preset batch expansion conditions, the batch pre-allocation phase begins. This batch pre-allocation phase is based on atomic operations, pre-allocating the required physical storage space and establishing exclusive locking protection for this operation, creating a safe and isolated execution environment for batch writes. The pre-allocation operation is implemented by calling the file space pre-allocation interface provided by the operating system (such as Linux's fallocate). The operating system determines the length of consecutive bytes (i.e., storage space) that needs to be reserved based on the actual number of page allocations, initiates a pre-allocation request, and calls the operation to ensure that the specified storage space is marked as "occupied".
[0029] It should be noted that pre-allocation operations typically only update metadata (such as block bitmaps) without actually writing data, thus avoiding the huge I / O overhead caused by zero-write operations. After successful pre-allocation, the operating system updates the file size metadata in memory and creates an allocation record, which is bound to the current transaction for subsequent atomic commits or rollbacks.
[0030] In this embodiment, to ensure the atomicity and isolation of the batch expansion operation, the database enters an exclusive locking state after successful pre-allocation. This exclusive locking state is constructed through a multi-layered locking mechanism. A table-level exclusive lock is acquired to prevent other transactions from modifying or expanding the data table during this period. A slot is reserved in the buffer for each new page to be initialized, and an exclusive buffer lock is applied to prevent these memory pages from being accidentally evicted or read. A transaction status flag set by the operating system indicates that the database is in the process of batch expansion, and a monitoring timer is started by the operating system to ensure that the locking state is not held indefinitely due to unforeseen circumstances.
[0031] In this embodiment, under the premise that the exclusive lock state is valid and stable, batch page initialization and data loading operations for the database are performed. The operating system writes the page initialization data of the data table to the pre-allocated storage space. Through the configuration file descriptor flag, the write operation bypasses the operating system's page cache, and the page initialization data is directly transferred from the pre-allocated storage space to the storage used for persistence. The above operation not only eliminates the data copy overhead of the kernel space, but also reduces CPU utilization and avoids the "double cache" problem in the prior art.
[0032] In this embodiment, after all page initialization data is successfully written to persistent storage, the database performs an atomic commit through the operating system. All metadata related to this batch expansion (such as space allocation records and page initialization status) is modified and written to the transaction log as a complete redo log record, and a forced flush to disk is performed. After confirming log persistence, the entire operation is committed, the latest log sequence number of all relevant pages is updated, and previously held table-level exclusive locks and buffer locks are released. At this point, the new pages are visible to external queries, and the batch expansion operation is complete.
[0033] It should be noted that the database also has a robust anomaly monitoring and handling mechanism throughout the entire process of performing batch page expansion. For potential anomalies such as insufficient storage space, lock wait timeouts, and operating system crashes, there are corresponding rollback or recovery procedures. If an error is detected during the write process, the allocated storage space is rolled back and the locks are released based on the allocation records and transaction logs created during the pre-allocation phase, ensuring the consistency of the database state.
[0034] Through the above steps, by pre-determining multiple memory buffer pages corresponding to the actual number of allocated pages as storage space, and allocating contiguous physical storage areas during the exclusive locking period, the continuous mapping between logical pages and physical storage space is ensured. This reduces the metadata overhead of subsequent page management and improves the I / O efficiency of sequential data access after expansion. Using a direct access method to write page initialization data to the physical storage area bypasses the dual buffering link of the database shared buffer and the operating system page cache, avoiding data copying overhead and synchronization waits between multi-level caches, and reducing CPU usage and write latency. By batch loading the initialized physical storage data into the locked memory buffer pages, the page image in memory and the content in persistent storage are made consistent in a single atomic operation, ensuring the recoverability of the expansion operation in case of failure.
[0035] Figure 2 This is a schematic flowchart illustrating the current-moment expansion process in a database page expansion method according to an embodiment of the present invention, as shown below. Figure 2 As shown, the steps to determine the actual number of pages allocated for expansion at the current moment based on the page expansion request of the data table include: Step S201: In response to the page expansion request of the data table, obtain the number of pages to be expanded as indicated by the page expansion request, and the current load status indicators of the database engine. Step S202: Determine the actual number of pages allocated for expansion at the current moment based on the number of pages to be expanded and the load status indicators.
[0036] In this embodiment, when the database kernel receives a page expansion request, its decision-making process is initiated. The database's internal request parsing module extracts the table identifier from the page expansion request to locate the specific table object, as well as the number of pages to be expanded declared by the request initiator (usually the SQL executor). The database's built-in status awareness module synchronously collects load status indicators reflecting the real-time health and pressure of the database engine. These load status indicators include at least: the number of backend processes currently waiting for the same target table's "expansion lock," the proportion of free pages in the database buffer pool and the recent page eviction frequency, the current average I / O response time and device queue depth, and the overall CPU utilization.
[0037] Through the above steps, dynamic adaptation between page expansion requests and load is achieved, avoiding resource waste (such as insufficient allocation under low load) or overload (such as excessive allocation under high load) caused by a fixed number of page allocations, thus balancing business needs and database resource capacity. Adjusting the actual number of page allocations based on real-time load status indicators can specifically alleviate problems such as lock contention, memory shortages, and disk I / O congestion, reducing the interference of expansion operations on concurrent database transactions. Matching the number of pages to be expanded with the actual allocation scale avoids frequent small expansion requests or excessive resource allocation in a single instance, reducing the total overhead of the expansion process (such as the cumulative time spent on lock acquisition and release, memory allocation, and I / O operations), and shortening the total page expansion time.
[0038] Figure 3 This is a schematic flowchart illustrating the process of obtaining the number of pages to be expanded in a database page expansion method according to an embodiment of the present invention, such as... Figure 3 As shown, the steps for obtaining the number of pages to be expanded as indicated by the page expansion request in response to a page expansion request for a data table include: Step S301: Obtain historical extension records based on the source process identifier of the page extension request; Step S302: Determine the average number of expanded pages in the historical expanded records based on a preset time window, and determine the average number of expanded pages as the number of pages to be expanded.
[0039] In this embodiment, when the interface layer of the database kernel receives a page expansion request, it will perform the identification of the request source to obtain the source process identifier. The source process identifier typically includes: the unique identifier of the backend process that initiated the request, the client session identifier served by the process, the associated user identity, and the SQL statement or transaction signature being executed.
[0040] In this embodiment, the source process identifier is used as the query key to access the historical extended record. The entries in the accessed historical extended record include: source identifier, extended behavior time sequence queue, behavior pattern fingerprint, statistical summary (total number, average number, variance, etc.), and last active timestamp.
[0041] In this embodiment, after successfully acquiring historical expansion records, a sliding time window is configured based on the current time and the business scenario. For short-term, high-concurrency batch page expansion jobs, the time window should be short to quickly reflect explosive demand; for long-term, stable analytical queries, the time window can be appropriately extended to balance fluctuations. From the time-series queue of expansion behavior in the historical expansion records, all expansion events falling within the preset time window are selected, and the average number of expanded pages is obtained based on the expansion events within the preset time window.
[0042] By following the steps above, the number of pages to be expanded is determined based on the average value of historical expansion records. This avoids estimation errors in single requests from the business side (such as overestimation leading to resource waste, and underestimation causing frequent expansions), improving the rationality and accuracy of the number of pages to be expanded. Using a preset time window as the statistical dimension, the focus is on recent effective expansion behavior data, ensuring that the number of pages to be expanded matches the recent changes in the actual storage needs of the data table (such as high-frequency small-batch expansion during peak business periods and low-frequency large-batch expansion during off-peak periods), adapting to dynamic business changes.
[0043] Figure 4 This is a schematic flowchart illustrating the determination of the actual page allocation number in a database page expansion method according to an embodiment of the present invention, such as... Figure 4 As shown, the steps to determine the actual number of pages allocated for expansion at the current moment based on the number of pages to be expanded and load status indicators include: Step S401: Determine the number of pages to be expanded as the base request quantity; Step S402: Determine the load adjustment amount based on the load status index and the preset weight factor corresponding to the load status index, wherein the preset weight factor is obtained by performing a gradient descent operation on the historical load status index data. Step S403: The number of candidate pages to be allocated is obtained by weighted summation of the basic request volume and the load adjustment volume; Step S404: Input the number of candidate page allocations and the preset expansion limit of the database into the minimum value function, and determine the output value of the minimum value function as the actual number of page allocations.
[0044] In this embodiment, the load status indicators include at least: the number of backend processes currently waiting for the same target data table "extended lock", the proportion of free pages in the database buffer pool and the recent page eviction frequency, the average I / O response time and device queue depth at the current moment, and the overall CPU utilization. A dynamic threshold method is used to normalize each load status indicator, mapping it to a value range of [0,1].
[0045] In this embodiment, historical load status index data is used as input features, and the corresponding historical optimal load adjustment amount is labeled. After data cleaning, the historical load status index and the corresponding historical optimal load adjustment amount are normalized and divided into training and validation sets. Model parameters such as weights and bias terms are initialized, and hyperparameters such as learning rate and number of iterations are set. Then, gradient descent iterative training is performed, iteratively completing the forward calculation of the predicted adjustment amount, calculation of the prediction error, solving the gradient, updating parameters, and verifying business constraints until the error converges or the maximum number of iterations is reached. Finally, the rationality of the weights is tested using the validation set, and the weight distribution is verified in conjunction with business logic. The optimal parameters are selected from the weight distribution as preset weight factors. The load adjustment amount is obtained by multiplying each load status index by its corresponding weight factor.
[0046] For example, in the process of weighted summing of the base request volume and the load adjustment volume, the weight of the base request volume is set to 1.0, and the weight of the load adjustment volume is set to a preset coefficient (e.g., 1.0). When the load is low (e.g., low lock contention, sufficient memory), the weight of the load adjustment volume is adjusted to a positive number greater than 1.0, so that the number of candidate page allocations is higher than the base request volume, to meet the business expansion needs; when the load is high (e.g., I / O congestion, memory shortage), the weight of the load adjustment volume is adjusted to a negative number, so that the number of candidate page allocations is lower than the base request volume, to avoid over-allocation leading to overload; the candidate page allocation number obtained by weighted summation is rounded (e.g., rounding up the decimal part) to ensure that the number of candidate page allocations conforms to the positive integer of the database page management rules.
[0047] Through the above steps, the number of pages to be expanded is derived from historical load status data as the base request volume. This ensures that the initial allocation scale matches actual business needs, reduces unfounded allocation deviations, and improves the rationality of the basic allocation. Preset weighting factors are obtained by training on historical load status data using a gradient descent algorithm, making the calculation of load adjustments more data-driven. Combining real-time load status indicators with dynamic calculation of load adjustments achieves precise linkage between the basic request volume and system operating status, avoiding over-allocation during high load periods leading to system overload, or under-allocation during low load periods causing frequent expansion.
[0048] Figure 5This is a schematic flowchart illustrating the batch expansion condition setting in a database page expansion method according to an embodiment of the present invention, such as... Figure 5 As shown, After determining the actual number of pages allocated for expansion at the current moment based on the page expansion requests in the data table, the process also includes: Step S501: Determine whether the actual number of pages allocated is greater than or equal to the preset batch expansion threshold; Step S502: If yes, determine that the actual number of pages allocated meets the preset batch expansion conditions; Step S503: If not, determine that the actual number of pages allocated does not meet the preset batch expansion conditions.
[0049] In this embodiment, the database page expansion method further includes: in response to the actual number of pages allocated not meeting the preset batch expansion conditions, performing cyclic single-page expansion based on the actual number of pages allocated.
[0050] Through the above steps, precise determination is made by setting a pre-defined batch expansion threshold, enabling automatic switching between expansion modes (batch expansion / single-page expansion). This avoids the inefficiency caused by using a single mode for all expansion requests (e.g., increasing lock overhead by using batch mode for small batch requests). The batch expansion process is triggered only when the actual number of pages allocated reaches the threshold, ensuring that batch optimization measures (such as contiguous storage pre-allocation and atomic locking) can fully play their role in high-yield scenarios, improving the efficiency and concurrency performance of large-batch expansion. Small-batch expansion requests still use the single-page expansion mode, avoiding additional process overhead caused by over-optimization, balancing the processing efficiency of different scale expansion scenarios, and adapting to diverse business needs.
[0051] Figure 6 This is a schematic flowchart of a database page expansion method according to an embodiment of the present invention, showing the batch page expansion process. Figure 6 As shown, the steps for directly loading the page initialization data of the data table into the storage space to complete batch page expansion include: Step S601: Determine the multiple memory buffer pages corresponding to the actual number of page allocations as storage space; Step S602: During the validity period of the exclusive lock state of the storage space, allocate a contiguous physical storage area for the data table. Step S603: Write the page initialization data of the data table to the physical storage area using direct access. Step S604: Initialize the page data that has been written to the physical storage area and load multiple locked memory buffer pages in batches to complete the batch expansion.
[0052] Through the above steps, a contiguous physical storage area is allocated within the exclusive lock period, preventing storage resource preemption during expansion, ensuring the continuity and exclusivity of physical storage, reducing disk seek time, and improving subsequent data read / write performance. Initialization data is written using direct access, bypassing the operating system kernel buffer, eliminating memory copy redundancy under the dual-caching mechanism, and reducing CPU overhead and write latency. Batch loading of locked memory buffer pages replaces the existing single-page circular loading mode, reducing the cumulative time spent on multiple lock requests and releases and page loading, significantly improving the execution speed of large-scale page expansion. The locking state is bound to the storage allocation, data writing, and batch loading processes, preventing concurrent operations from interfering with the initialization data, ensuring the atomicity and consistency of data writing, and reducing the risk of data corruption.
[0053] The flowchart provided in this embodiment is not intended to indicate that the operations of the method will be performed in any particular order, or that all operations of the method are included in every case. Furthermore, the method may include additional operations. Within the scope of the technical concept provided by the method in this embodiment, additional variations can be made to the above method.
[0054] It should be understood that in some embodiments, the components may be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented using software or firmware stored in memory and executed by a suitable instruction execution system.
[0055] This embodiment also provides a computer program product 10, a computer-readable storage medium 20, and a computer device 30. For example... Figure 7 As shown, the computer program product 10 includes a computer program 11, which, when executed by the processor 32, implements the steps of any of the above-described database page expansion methods. Figure 8 As shown, a computer-readable storage medium 20 stores the aforementioned computer program 11, which, when executed by the processor 32, implements the steps of the database page expansion method of any of the above embodiments. Figure 9 As shown, the computer device 30 may include a memory 31, a processor 32, and a computer program 11 stored on the memory 31 and running on the processor 32.
[0056] The computer program 11 used to perform the operations of this invention may be assembly instructions, Instruction Set Architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, integrated circuit configuration data, or source code or object code written in any combination of one or more programming languages and procedural programming languages. The computer program 11 may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, to perform aspects of this invention, electronic circuits, including, for example, programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), may execute computer-readable program instructions to personalize the electronic circuits by utilizing status information of the computer-readable program instructions.
[0057] For the purposes of this embodiment, computer program product 10 is a related product that includes computer program 11.
[0058] For the purposes of this embodiment, the computer-readable storage medium 20 is a tangible device capable of holding and storing a computer program 11. It can be any device capable of containing, storing, communicating, propagating, or transmitting the computer program 11 for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable storage medium 20 include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable optical disc read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical encoding device, and any suitable combination thereof.
[0059] Computer device 30 can be, for example, a server, desktop computer, laptop computer, tablet computer, or smartphone. In some examples, computer device 30 can be a cloud computing node. Computer device 30 can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., that perform specific tasks or implement specific abstract data types. Computer device 30 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can reside on local or remote computing system storage media, including storage devices.
[0060] Computer device 30 may include a processor 32 adapted to execute stored instructions and a memory 31 that provides temporary storage space for the operation of said instructions during operation. The processor 32 may be a single-core processor, a multi-core processor, a computing cluster, or any other configuration. The memory 31 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.
[0061] Computer device 30 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows external devices that can be connected to the computer device to input and output data. The network adapter / interface provides communication between the computer device and a network, typically represented as a communication network.
[0062] Therefore, those skilled in the art should recognize that although numerous exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications conforming to the principles of the present invention can be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Thus, the scope of the present invention should be understood and construed as covering all such other variations or modifications.
Claims
1. A method for expanding a database page, characterized in that, include: Determine the actual number of pages allocated for expansion at the current moment based on the page expansion requests in the data table; In response to the actual number of pages allocated meeting the preset batch expansion conditions, storage space is pre-allocated based on the actual number of pages allocated for performing atomic commit operations; During the exclusive lock period of the storage space, the page initialization data of the data table is directly loaded into the storage space to complete the batch page expansion.
2. The database page expansion method according to claim 1, characterized in that, The steps to determine the actual number of pages allocated for expansion at the current moment based on the page expansion request in the data table include: In response to a page expansion request for a data table, obtain the number of pages to be expanded as indicated by the page expansion request, as well as the current load status indicators of the database engine. The actual number of pages allocated for expansion at the current moment is determined based on the number of pages to be expanded and the load status indicators.
3. The database page expansion method according to claim 2, characterized in that, The step of obtaining the number of pages to be expanded as indicated by the page expansion request in response to a page expansion request for a data table includes: Historical extension records are obtained based on the source process identifier of the page extension request; Determine the average number of expanded pages in the historical expanded records within a preset time window, and determine the average number of expanded pages as the number of pages to be expanded.
4. The database page expansion method according to claim 2, characterized in that, The steps for determining the actual number of pages allocated for expansion at the current moment based on the number of pages to be expanded and the load status indicators include: The number of pages to be expanded is determined as the base request quantity; The load adjustment amount is determined based on the load status index and the preset weighting factor corresponding to the load status index, wherein the preset weighting factor is obtained by performing a gradient descent operation on historical load status index data. The number of candidate pages to be allocated is obtained by weighted summation of the basic request volume and the load adjustment volume. The number of candidate pages allocated and the preset expansion limit of the database are input into the minimum value function, and the output value of the minimum value function is determined as the actual number of pages allocated.
5. The database page expansion method according to claim 1, characterized in that, After determining the actual number of pages allocated for expansion at the current moment based on the page expansion requests in the data table, the process also includes: Determine whether the actual number of pages allocated is greater than or equal to a preset batch expansion threshold; If so, determine that the actual number of pages allocated meets the preset batch expansion conditions; If not, it is determined that the actual number of pages allocated does not meet the preset batch expansion conditions.
6. The database page expansion method according to claim 1, characterized in that, The steps of directly loading the page initialization data of the data table into the storage space to complete the batch page expansion include: The storage space is defined as the multiple memory buffer pages corresponding to the actual number of allocated pages. During the validity period of the exclusive lock state of the storage space, a contiguous physical storage area is allocated for the data table; The page initialization data of the data table is written to the physical storage area using a direct access method; The page initialization data already written to the physical storage area is loaded in batches into the multiple locked memory buffer pages to complete the batch expansion.
7. The database page expansion method according to claim 1, characterized in that, Also includes: In response to the actual number of pages allocated not meeting the preset batch expansion conditions, a cyclical single-page expansion is performed based on the actual number of pages allocated.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the page expansion method for the database according to any one of claims 1 to 7.
9. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the page expansion method for the database as described in any one of claims 1 to 7.
10. A computer device, characterized in that, The system includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the page expansion method for the database according to any one of claims 1 to 7.