Idle page management method and device based on B+ tree database and storage medium

By combining the incremental data writing process for free pages with the full data writing process in the B+ tree database, the write performance problem caused by free page management under large data volumes in the B+ tree database is solved, and efficient free page management and write performance optimization are achieved.

CN115510060BActive Publication Date: 2026-07-14BEIJING YUNSIZHIXUE TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING YUNSIZHIXUE TECH CO LTD
Filing Date
2022-09-22
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

In B+ tree databases, the performance bottleneck caused by free page management is particularly prominent with frequent data writing and deletion, especially in scenarios with large data volumes, where existing free page management methods lead to a severe decline in write performance.

Method used

A combination of incremental data writing and full data writing processes for free pages is adopted. By performing incremental data writing at each transaction commit and full data writing under trigger conditions, the amount of data managed by free pages is separated, thus optimizing write performance.

Benefits of technology

It effectively reduces the execution time of writing idle pages for each write transaction, optimizes the performance bottleneck under large data volumes, improves write performance, and ensures timely processing of write transactions and efficient system operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115510060B_ABST
    Figure CN115510060B_ABST
Patent Text Reader

Abstract

The application discloses a B+ tree database-based idle page management method and device and a storage medium. The B+ tree database-based idle page management method comprises an idle page incremental data writing process, a write transaction is started to be executed, an idle page is operated according to the write transaction, and incremental page data information of the idle page is recorded; and an idle page full-amount data writing process, when a configuration condition for starting the idle page full-amount data writing process is triggered, full-amount idle page data information is acquired to be written, and corresponding incremental page data information is emptied after the full-amount idle page data information is written. The application proposes the idle page incremental data writing process + the idle page full-amount data writing process method aiming at the problem that when a large amount of data exists in a B+ tree and a large idle page exists, a great performance loss exists in idle page writing when a write transaction is submitted, solves the write performance problem when data is added or deleted under the B+ tree large data amount, and has high innovation and use value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, specifically to a method, apparatus, and storage medium for managing free pages based on a B+ tree database. Background Technology

[0002] B+ tree database: A database created using a B+ tree data structure. It is a persistent database that provides efficient write / query / update / delete capabilities.

[0003] Free pages: After a database has been running continuously for a period of time, and data has been frequently written to / deleted, a large amount of non-contiguous space will be generated in memory / files. This space can be used to reallocate data, and this released non-contiguous space is called a free page.

[0004] In the field of disk storage, B+ trees are a technology that supports high-performance read and write operations and range queries. When storing data in a B+ tree, disk and memory can be mapped to each other, allowing applications to operate on the disk by reading and writing to memory. At this point, the application needs to manage not only data page information but also free page information simultaneously. Because with continuous write and delete operations, data pages are frequently written, erased, and rewritten. It's crucial to accurately record which data pages are currently in use and which are unused and reusable; this is what free page management needs to accomplish. Current free page management synchronously writes free page information to disk files with each write / delete operation. When the system needs to store large amounts of data, free pages may reach the MB level, while the amount of data written each time may only be in the KB level, while free pages are thousands of times larger than the data volume. This can lead to a severe performance bottleneck during writes.

[0005] In view of this, this invention patent is hereby proposed. Summary of the Invention

[0006] To address the performance issues mentioned above, this invention proposes a free page management method based on a B+ tree database. This method offers higher performance in scenarios with large data volumes and frequent writes / deletions. Specifically, the following technical solution is adopted:

[0007] Free page management methods based on B+ tree databases include:

[0008] Incremental data writing process for free pages: The write transaction begins execution, and operations are performed on the free pages according to the write transaction, and the incremental page data information of the free pages is recorded;

[0009] Full data writing process for free pages: When the configuration conditions for starting the full data writing process for free pages are triggered, the full free page data information is obtained and written, and the corresponding incremental page data information is cleared after the full free page data information is written.

[0010] As an optional embodiment of the present invention, in the free page management method based on a B+ tree database, the free page incremental data writing process includes: a write transaction begins execution, operations are performed on the free page according to the write transaction, and the incremental page data information of the free page is recorded, including:

[0011] Start writing the transaction;

[0012] Execute each statement in the write transaction one by one: if it is a put operation, allocate the page space required for the current put operation; if it is a delete operation, find the corresponding page space.

[0013] Write transaction commit: Do not record all free pages; incremental page data information of free pages is written to disk during the corresponding process of executing the write transaction.

[0014] As an optional embodiment of the present invention, in the free page management method based on B+ tree database of the present invention, if a put operation is performed during the execution of each statement of a write transaction, the allocation of page space to meet the needs of the current put operation includes:

[0015] Search among the free pages; if available free page space is found, release the corresponding free page space.

[0016] If not found in a free page, then start looking for available page space from unused addresses in the application;

[0017] Record the incremental page data of the free page and write it to disk. The incremental page data includes the transaction ID, the free page ID, and the operation mode: remove.

[0018] As an optional embodiment of the present invention, in the free page management method based on B+ tree database of the present invention, if a deletion operation is performed during the execution of each statement of a write transaction, finding the corresponding page space includes:

[0019] Traverse the current data page information of the B+ tree database to find the page to be deleted;

[0020] If the search fails, ignore it; if the search succeeds, add the page to be deleted to the free page list.

[0021] Record the incremental page data of the free page and write it to disk. The incremental page data includes the transaction ID, the free page ID, and the operation mode: join.

[0022] As an optional embodiment of the present invention, in the free page management method based on B+ tree database of the present invention, the free page full data writing process includes: when the configuration condition for starting the free page full data writing process is triggered, acquiring full free page data information and writing it, and clearing the corresponding incremental page data information after the full free page data information is written, including:

[0023] Start writing the transaction;

[0024] Execute an empty transaction;

[0025] Transaction commit: Record all free pages and transaction IDs, and write them to disk. Clear all incremental page data recorded between the current free page full data write process and the previous free page full data write process.

[0026] As an optional embodiment of the present invention, in the free page management method based on B+ tree database of the present invention, the configuration conditions for triggering the start of the full data writing process of the free page include:

[0027] The configuration condition is whether the time interval between two adjacent idle page full data write processes reaches the preset time interval T0. When the time interval reaches T0 after the previous idle page full data write process is completed, the configuration condition is triggered and the current idle page full data write process begins to execute. The preset time interval T0 is configured according to the database write peak.

[0028] And / or, the configuration condition is whether a call instruction is received. When a call instruction is received that the program actively triggers the full data writing process of the free page, the configuration condition is triggered and the full data writing process of the free page begins to execute.

[0029] As an optional embodiment of the present invention, the free page management method based on a B+ tree database of the present invention further includes a B+ tree database restart process:

[0030] First, read all free page data into the global free page list, and simultaneously read the current transaction ID;

[0031] Then read all the incremental page data and integrate the incremental page data with the same free page data in the full free page data to determine the transaction to be executed for the free page after the B+ tree database restarts.

[0032] As an optional embodiment of the present invention, in the free page management method based on B+ tree database of the present invention, the step of integrating incremental page data with the same free page data in the full free page data to determine the transaction to be executed for the free page after the B+ tree database restarts includes:

[0033] Check the incremental transaction ID of each free page in the incremental page data one by one;

[0034] If the incremental transaction ID is recorded no later than the current transaction ID, then the incremental transaction ID is ignored.

[0035] If the incremental transaction ID is recorded later than the current transaction ID, the current incremental page data is applied. If the transaction operation is a remove, the free page ID is removed from the global free page list. If the transaction operation is an add, the free page ID is added to the global free page list.

[0036] This invention also provides a free page management device based on a B+ tree database, comprising:

[0037] Incremental data writing module for free pages: When a write transaction begins, it performs operations on the free pages according to the write transaction and records the incremental page data information of the free pages;

[0038] The module for writing full data to idle pages: When the configuration conditions for starting the full data writing process to idle pages are triggered, it acquires and writes full data information to idle pages, and clears the corresponding incremental data information after the full data writing to idle pages is completed.

[0039] The present invention also provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer-executable program, and when the computer program is executed by the processor, the processor executes the free page management method based on the B+ tree database.

[0040] The present invention also provides a computer-readable storage medium storing a computer-executable program, which, when executed, implements the free page management method based on a B+ tree database.

[0041] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0042] The improved process of the free page management method based on B+ tree database of the present invention consists of two steps:

[0043] 1. Incremental data writing to free pages: This is executed with every transaction commit.

[0044] 2. Full data write of idle pages: When the configured conditions are triggered, a full commit of idle pages is performed.

[0045] Thus, the purpose of the free page management method based on B+ tree database of the present invention is to reduce the execution time of free page writing for each write transaction by splitting the data volume of free pages, thereby optimizing the performance bottleneck of free pages under large data volumes.

[0046] This invention addresses the significant performance overhead of writing to free pages during write transaction commits when storing a large number of B+ tree data with a substantial amount of free pages. It proposes a free page management method that combines an incremental data writing process for free pages with a full data writing process for free pages. This solves the write performance problem when adding or deleting data in large B+ tree datasets, demonstrating high innovation and practical value. Attached image description:

[0047] Figure 1 The flowchart of the free page management method based on B+ tree database in this invention embodiment Figure 1 ;

[0048] Figure 2 The flowchart of the free page management method based on B+ tree database in this invention embodiment Figure 2 ;

[0049] Figure 3 The flowchart of the free page management method based on B+ tree database in this invention embodiment Figure 3 ;

[0050] Figure 4 The flowchart of the free page management method based on B+ tree database in this invention embodiment Figure 4 . Detailed Implementation

[0051] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0052] Therefore, the following detailed description of embodiments of the present invention is not intended to limit the scope of the claimed invention, but merely illustrates some embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0053] It should be noted that, unless otherwise specified, the embodiments and features and technical solutions in the present invention can be combined with each other.

[0054] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0055] In the description of this invention, it should be noted that the terms "upper," "lower," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use, or the orientation or positional relationship commonly understood by those skilled in the art. These terms are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention. In addition, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0056] See Figure 1 As shown, the free page management method based on a B+ tree database in this embodiment includes:

[0057] Incremental data writing process for free pages: The write transaction begins execution, and operations are performed on the free pages according to the write transaction, and the incremental page data information of the free pages is recorded;

[0058] Full data writing process for free pages: When the configuration conditions for starting the full data writing process for free pages are triggered, the full free page data information is obtained and written, and the corresponding incremental page data information is cleared after the full free page data information is written.

[0059] The improved process of the free page management method based on B+ tree database in this embodiment consists of two steps:

[0060] 1. Incremental data writing to free pages: This is executed with every transaction commit.

[0061] 2. Full data write of idle pages: When the configured conditions are triggered, a full commit of idle pages is performed.

[0062] Thus, the purpose of the free page management method based on B+ tree database in this embodiment is to reduce the execution time of writing free pages for each write transaction by splitting the data volume of free pages, thereby optimizing the performance bottleneck of free pages under large data volumes.

[0063] This embodiment addresses the significant performance overhead of writing to free pages during write transaction commits when storing a large number of B+ tree data with a substantial number of free pages. It proposes a free page management method that combines an incremental data writing process for free pages with a full data writing process for free pages. This method solves the write performance problem when adding or deleting data in B+ tree data with large volumes, demonstrating high innovation and practical value.

[0064] See Figure 2As shown, as an optional implementation of this embodiment, the free page management method based on a B+ tree database described in this embodiment includes the following free page incremental data writing process: A write transaction begins execution, operations are performed on the free pages according to the write transaction, and the incremental page data information of the free pages is recorded, including:

[0065] Start writing the transaction;

[0066] Execute each statement in the write transaction one by one: if it is a put operation, allocate the page space required for the current put operation; if it is a delete operation, find the corresponding page space.

[0067] Write transaction commit: Do not record all free pages; incremental page data information of free pages is written to disk during the corresponding process of executing the write transaction.

[0068] In the B+ tree-based free page management method described in this embodiment, the application not only needs to manage data page information but also needs to manage free page information synchronously. During write transactions, data pages and free pages are managed according to the specific operations of the write transaction, and information is updated synchronously. Specifically, the put operation in the write transaction first writes a batch of data to a temporary buffer, checks if there is a free space in memory, and if so, passes the data; otherwise, it rolls the data back to the temporary buffer. The delete operation in the write transaction deletes the information from the data page, and after deletion, adds the data page to the free page for free page management.

[0069] Specifically, see Figure 2 As shown, in the free page management method based on B+ tree database in this embodiment, if a put operation is performed during the execution of each statement of a write transaction, the allocation of page space to meet the needs of the current put operation includes:

[0070] Search among the free pages; if available free page space is found, release the corresponding free page space.

[0071] If not found in a free page, then start looking for available page space from unused addresses in the application;

[0072] Record the incremental page data of the free page and write it to disk. The incremental page data includes the transaction ID, the free page ID, and the operation mode: remove.

[0073] Specifically, see Figure 2 As shown, in the free page management method based on B+ tree database in this embodiment, if a deletion operation is performed during the execution of each statement of a write transaction, finding the corresponding page space includes:

[0074] Traverse the current data page information of the B+ tree database to find the page to be deleted;

[0075] If the search fails, ignore it; if the search succeeds, add the page to be deleted to the free page list.

[0076] Record the incremental page data of the free page and write it to disk. The incremental page data includes the write transaction ID, the free page ID, and the operation mode: join.

[0077] The free page management method based on a B+ tree database in this embodiment records incremental data writing for each space allocation operation and the operation of adding data to a free page.

[0078] 1. For space allocation operations, record incremental page data (transaction ID, free page ID, operation: remove);

[0079] 2. For operations involving adding to a free page, record the incremental page data (transaction ID, free page ID, operation: add).

[0080] The free page management method based on B+ tree database in this embodiment only incrementally writes the data to be processed in the current write transaction during each write transaction, ensuring that each write transaction can be processed in a timely manner and avoiding the problems of long execution time and low performance caused by writing all the data in each write transaction.

[0081] Specifically, see Figure 3 As shown, in the free page management method based on B+ tree database in this embodiment, the free page full data writing process includes: when the configuration condition for starting the free page full data writing process is triggered, acquiring and writing the full free page data information, and clearing the corresponding incremental page data information after the full free page data information is written, including:

[0082] Start writing the transaction;

[0083] Execute an empty transaction;

[0084] Transaction commit: Record all free pages and transaction IDs, and write them to disk. Clear all incremental page data recorded between the current free page full data write process and the previous free page full data write process.

[0085] Meanwhile, in order to achieve comprehensive management of free pages and ensure the efficiency of free page queries, this embodiment requires full data writing to update the incremental free page data into the full free page data. In this way, the program can manage free pages through the full free page data. However, the full data writing process for free pages is time-consuming. This can be mitigated by triggering configuration conditions to reduce the performance overhead and impact of the full data writing process for free pages on the system.

[0086] As an optional implementation of this embodiment, when implementing the free page management method based on B+ tree database in this embodiment, the recorded ID can be a transaction ID or other IDs.

[0087] As an optional implementation of this embodiment, in the free page management method based on B+ tree database of this embodiment, the configuration conditions for the start of the full data writing process of the free page are triggered as follows:

[0088] Configuration condition 1: The configuration condition is whether the time interval between two adjacent full data write processes of the idle page reaches the preset time interval T0. When the time interval reaches T0 after the previous full data write process of the idle page is completed, the configuration condition is triggered and the current full data write process of the idle page begins to execute. The preset time interval T0 is configured according to the peak write speed of the database.

[0089] Configuration condition two: The configuration condition is whether a call instruction is received. When a call instruction is received that the program actively triggers the process of writing all data to the free page, the configuration condition is triggered and the process of writing all data to the free page begins to execute.

[0090] Configuration condition 3: The configuration condition is whether the number of executions of the idle page incremental data writing process between two adjacent idle page full data writing processes reaches the preset number N0. When the number of executions of the idle page incremental data writing process reaches N0 after the previous idle page full data writing process is completed, the configuration condition is triggered and the current idle page full data writing process begins to execute.

[0091] In this embodiment, configuration conditions one, two, and three can be set simultaneously. The program is triggered to execute the full data writing process of the free page when either configuration condition one or configuration condition two is applied. At the same time, the program can also actively issue a trigger command to execute the full data writing process of the free page according to its specific running requirements.

[0092] As an optional implementation of this embodiment, the incremental free page data in this embodiment can be plain data structure, compressed data, or a variant thereof.

[0093] Therefore, the free page management method based on B+ tree database in this embodiment improves upon the existing free page management method for B+ tree databases. Before the improvement, the complete process of a write transaction is as follows:

[0094] 1. Start writing the transaction.

[0095] 2. Execute line by line, writing each statement of the transaction.

[0096] a. If it is a put operation, allocate page space to meet the current put operation requirements;

[0097] a.1 First, search the free pages. If available page space is found, release the corresponding page space from the free pages.

[0098] a.2 If not found in a free page, then start looking for available page space from unused addresses in the application;

[0099] b. If it is a deletion operation, find the corresponding page space. If it is not found, ignore it. If it is found, add this space to the free page.

[0100] 3. Transaction commit.

[0101] a. The data portion has already been written to the corresponding page space during each put operation, so this part is ignored;

[0102] b) Allocate space for free pages, write free page information into this space, and record the page ID of this space in the database meta information.

[0103] In this embodiment of the free page management method based on a B+ tree database, the improved free page management process consists of two steps:

[0104] 1. Incremental write: This is executed with every commit;

[0105] 2. Full write: Perform a full free page commit every n seconds (n is configurable and depends on the peak write volume of the database).

[0106] The purpose of the free page management method based on B+ tree database in this embodiment is to reduce the execution time of writing free pages for each write transaction by splitting the data volume of free pages, thereby optimizing the performance bottleneck of free pages under large data volumes.

[0107] For example, if the amount of free page data has reached 20GB, assuming each page is 4KB and the page ID is uint64, occupying 8 bytes, then using the previous solution, each commit of 1KB of data would require writing 20GB / 4KB*8B = 40MB, and just 10 write transactions would require writing 400MB.

[0108] The improved scheme commits 1KB each time and allocates 1 page. Assuming that only one full write is performed in 10 write transactions, the total write volume is approximately 40MB + 10 * 8B.

[0109] Therefore, it can be seen that, with a 10-fold difference in the amount of data written and a constant writing time, the total writing time of the free page management method based on the B+ tree database in this embodiment is 1 / 10 of that before the improvement.

[0110] As an optional implementation method in this embodiment, see Figure 4As shown, the free page management method based on a B+ tree database in this embodiment also includes a B+ tree database restart process:

[0111] First, read all free page data into the global free page list, and simultaneously read the current transaction ID;

[0112] Then read all the incremental page data and integrate the incremental page data with the same free page data in the full free page data to determine the transaction to be executed for the free page after the B+ tree database restarts.

[0113] The free page management method based on B+ tree database in this embodiment solves the write performance problem when adding and deleting data under large data volume in B+ tree databases by using a free page incremental data writing process and a free page full data writing process. It has high innovation and application value. When restarting the B+ tree database, it is necessary to unify the full free page data and incremental page data to avoid errors caused by inconsistency between the full free page data and incremental page data.

[0114] Specifically, in the B+ tree database-based free page management method of this embodiment, the step of integrating incremental page data with the same free page data in the full free page data to determine the transaction to be executed for the free page after the B+ tree database restarts includes:

[0115] Check the incremental transaction ID of each free page in the incremental page data one by one;

[0116] If the incremental transaction ID is recorded no later than the current transaction ID, then the incremental transaction ID is ignored.

[0117] If the incremental transaction ID is recorded later than the current transaction ID, the current incremental page data is applied. If the transaction operation is a remove, the free page ID is removed from the global free page list. If the transaction operation is an add, the free page ID is added to the global free page list.

[0118] This embodiment of the free page management method based on B+ tree database proposes a free page incremental data writing process + free page full data writing process. It changes the way that the full free page data is written every time a write transaction is executed. This process change enables B+ tree storage to have good performance even with large data volumes, and makes B+ tree storage highly available.

[0119] This embodiment also provides a free page management device based on a B+ tree database, including:

[0120] Incremental data writing module for free pages: When a write transaction begins, it performs operations on the free pages according to the write transaction and records the incremental page data information of the free pages;

[0121] The module for writing full data to idle pages: When the configuration conditions for starting the full data writing process to idle pages are triggered, it acquires and writes full data information to idle pages, and clears the corresponding incremental data information after the full data writing to idle pages is completed.

[0122] The free page management device based on a B+ tree database in this embodiment improves the free page management process in two steps:

[0123] 1. Incremental data writing to free pages: This is executed with every transaction commit.

[0124] 2. Full data write of idle pages: When the configured conditions are triggered, a full commit of idle pages is performed.

[0125] Thus, the free page management device based on B+ tree database in this embodiment reduces the execution time of writing free pages for each write transaction by splitting the data volume of free pages, thereby optimizing the performance bottleneck of free pages under large data volumes.

[0126] This embodiment is a free page management device based on a B+ tree database. Addressing the significant performance overhead of writing free pages during write transaction commits when storing a large number of free pages in a B+ tree, this device combines an incremental data writing module for free pages with a full data writing module for free pages. This solves the write performance problem when adding or deleting data in a B+ tree with large datasets, demonstrating high innovation and practical value.

[0127] As an optional implementation of this embodiment, in the free page management device based on a B+ tree database described in this embodiment, the free page incremental data writing module includes:

[0128] Transaction execution unit: When a write transaction begins, each statement in the write transaction is executed one by one: if it is a put operation, the page space required for the current put operation is allocated; if it is a delete operation, the corresponding page space is found.

[0129] Incremental page data writing unit: It does not record all free pages. The incremental page data information of free pages is written to disk in the corresponding process of executing the write transaction.

[0130] In the B+ tree database-based free page management device described in this embodiment, the application not only needs to manage data page information, but also needs to manage free page information synchronously. When the transaction execution unit executes a write transaction, the incremental page data writing unit manages data pages and free pages according to the specific operation of the write transaction and updates the information synchronously.

[0131] Specifically, the `put` operation in a write transaction first writes the batch of data to a temporary buffer, checks if there is any free space in memory, and if so, passes the data; otherwise, it rolls the data back to the temporary buffer. The `delete` operation in a write transaction deletes the information from the data page, and then adds the data page to the free page for free page management.

[0132] Specifically, in this embodiment, if a put operation is performed during the execution of each statement of a write transaction by the transaction execution unit, the allocation of page space to meet the needs of the current put operation includes:

[0133] Search among the free pages; if available free page space is found, release the corresponding free page space.

[0134] If not found in a free page, then start looking for available page space from unused addresses in the application;

[0135] The incremental page data writing unit records the incremental page data of the free page and writes it to disk. The incremental page data includes the transaction ID, the free page ID, and the operation mode: removal.

[0136] Specifically, in the free page management device based on the B+ tree database in this embodiment, if a deletion operation is performed during the process of the transaction execution unit executing each statement of a write transaction, the corresponding page space is located as follows:

[0137] Traverse the current data page information of the B+ tree database to find the page to be deleted;

[0138] If the search fails, ignore it; if the search succeeds, add the page to be deleted to the free page list.

[0139] The incremental page data writing unit records the incremental page data of the free page and writes it to disk. The incremental page data includes the write transaction ID, the free page ID, and the operation mode: join.

[0140] In this embodiment, the free page management device based on a B+ tree database records incremental page data for each space allocation operation and addition operation to a free page.

[0141] 1. For space allocation operations, record incremental page data (transaction ID, free page ID, operation: remove);

[0142] 2. For operations involving adding to a free page, record the incremental page data (transaction ID, free page ID, operation: add).

[0143] In this embodiment, the free page management device based on a B+ tree database only performs incremental writing of the operation data of the current write transaction during each write transaction. This ensures that each write transaction can be processed in a timely manner and avoids the problems of long execution time and low execution performance caused by writing all the data in each write transaction.

[0144] Specifically, in this embodiment of the free page management device based on a B+ tree database, the free page full data writing module includes:

[0145] Transaction execution unit: A write transaction begins, followed by the execution of an empty transaction;

[0146] Full page data write unit: Records all free pages and transaction IDs, writes them to disk, and clears all incremental page data recorded between the current free page full data write process and the previous free page full data write process.

[0147] Meanwhile, in order to achieve comprehensive management of free pages and ensure the efficiency of free page queries, this embodiment requires full data writing to update the incremental free page data into the full free page data. In this way, the program can manage free pages through the full free page data. However, the full data writing process for free pages is time-consuming. This can be mitigated by triggering configuration conditions to reduce the performance overhead and impact of the full data writing process for free pages on the system.

[0148] As an optional implementation of this embodiment, the ID recorded by the B+ tree database-based free page management device in this embodiment when writing incremental free page data and full free page data can be a transaction ID or other IDs.

[0149] As an optional implementation of this embodiment, the configuration conditions for the start of the free page full data writing module in the B+ tree database-based free page management device of this embodiment to be triggered include:

[0150] Configuration condition 1: The configuration condition is whether the time interval between two adjacent full data write processes of the idle page reaches the preset time interval T0. When the time interval reaches T0 after the previous full data write process of the idle page is completed, the configuration condition is triggered and the current full data write process of the idle page begins to execute. The preset time interval T0 is configured according to the peak write speed of the database.

[0151] Configuration condition two: The configuration condition is whether a call instruction is received. When a call instruction is received that the program actively triggers the process of writing all data to the free page, the configuration condition is triggered and the process of writing all data to the free page begins to execute.

[0152] Configuration condition 3: The configuration condition is whether the number of executions of the idle page incremental data writing process between two adjacent idle page full data writing processes reaches the preset number N0. When the number of executions of the idle page incremental data writing process reaches N0 after the previous idle page full data writing process is completed, the configuration condition is triggered and the current idle page full data writing process begins to execute.

[0153] In this embodiment, configuration conditions one, two, and three can be set simultaneously. The program is triggered to execute the full data writing process of the free page when either configuration condition one or configuration condition two is applied. At the same time, the program can also actively issue a trigger command to execute the full data writing process of the free page according to its specific running requirements.

[0154] As an optional implementation of this embodiment, the incremental free page data in this embodiment can be plain data structure, compressed data, or a variant thereof.

[0155] This embodiment also provides a computer-readable storage medium storing a computer-executable program. When the computer-executable program is executed, it implements the free page management method based on a B+ tree database as described above.

[0156] The computer-readable storage medium described in this embodiment may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0157] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer-executable program, and when the computer program is executed by the processor, the processor executes the free page management method based on the B+ tree database.

[0158] The electronic device is manifested in the form of a general-purpose computing device. It may contain one or more processors that work collaboratively. This invention also does not preclude distributed processing, meaning that processors may be distributed across different physical devices. The electronic device of this invention is not limited to a single entity, but may also be the sum of multiple physical devices.

[0159] The memory stores a computer-executable program, typically machine-readable code. The computer-readable program can be executed by the processor to enable the electronic device to perform the method of the present invention, or at least some steps of the method.

[0160] The memory includes volatile memory, such as random access memory (RAM) and / or cache memory, and may also be non-volatile memory, such as read-only memory (ROM).

[0161] It should be understood that the electronic device of the present invention may also include elements or components not shown in the examples above. For example, some electronic devices also include display units such as a display screen, and some electronic devices also include human-computer interaction elements such as buttons and keyboards. Any electronic device capable of executing a computer-readable program in its memory to implement the method of the present invention or at least some steps of the method can be considered as an electronic device covered by the present invention.

[0162] From the above description of the embodiments, those skilled in the art will readily understand that the present invention can be implemented by hardware capable of executing specific computer programs, such as the system of the present invention, and the electronic processing unit, server, client, mobile phone, control unit, processor, etc. included in the system. The present invention can also be implemented by computer software that executes the methods of the present invention, for example, by control software executed by a microprocessor, electronic control unit, client, server, etc. However, it should be noted that the computer software executing the methods of the present invention is not limited to execution in one or a specific set of hardware entities; it can also be implemented in a distributed manner by unspecified hardware. For computer software, the software product can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or distributed across a network, as long as it enables electronic devices to execute the methods according to the present invention.

[0163] The above embodiments are only used to illustrate the present invention and are not intended to limit the technical solutions described herein. Although the present invention has been described in detail with reference to the above embodiments, the present invention is not limited to the specific embodiments described above. Therefore, any modifications or equivalent substitutions to the present invention, as well as all technical solutions and improvements that do not depart from the spirit and scope of the invention, are covered within the scope of the claims of the present invention.

Claims

1. A free page management method based on a B+ tree database, characterized in that, include: Incremental data writing process for free pages: The write transaction starts to execute, operates on the free pages according to the write transaction, and records the incremental page data information of the free pages. The incremental page data information includes the transaction ID, the free page ID, and the operation mode, which is "remove" or "add". Full data write process for free pages: When the configuration conditions for starting the full data write process for free pages are triggered, the full free page data information is obtained and written, and the corresponding incremental page data information is cleared after the full free page data information is written. The full free page data information is the recorded full free pages and transaction IDs.

2. The free page management method based on a B+ tree database according to claim 1, characterized in that, The incremental data writing process for free pages is as follows: A write transaction begins execution, operations are performed on the free pages according to the write transaction, and the incremental page data information of the free pages is recorded, including: Start writing the transaction; Execute each statement in the write transaction one by one: if it is a put operation, allocate the page space required for the current put operation; if it is a delete operation, find the corresponding page space. Write transaction commit: Do not record all free pages; incremental page data information of free pages is written to disk during the corresponding process of executing the write transaction.

3. The free page management method based on a B+ tree database according to claim 2, characterized in that, If a put operation is performed during the execution of each statement in a write transaction, the allocation of page space to satisfy the current put operation includes: If a free page is found in the free page list, the corresponding free page space is released from the free page list; if it is not found in the free page list, the available page space is searched starting from the unused address in the application. Record the incremental page data of the free page and write it to disk. The incremental page data includes the transaction ID, the free page ID, and the operation mode: remove.

4. The free page management method based on a B+ tree database according to claim 2, characterized in that, If a deletion operation is performed during the execution of each statement in a write transaction, the corresponding page space is located as follows: Traverse the current data page information of the B+ tree database to find the page to be deleted; If the search fails, ignore it; if the search succeeds, add the page to be deleted to the free page list. Record the incremental page data of the free page and write it to disk. The incremental page data includes the transaction ID, the free page ID, and the operation method: join.

5. The free page management method based on a B+ tree database according to claim 1, characterized in that, The free page full data writing process is as follows: When the configuration condition for starting the free page full data writing process is triggered, the full free page data information is acquired and written, and the corresponding incremental page data information is cleared after the full free page data information is written, including: Start writing the transaction; Execute an empty transaction; Transaction commit: Record all free pages and transaction IDs, and write them to disk. Clear all incremental page data recorded between the current free page full data write process and the previous free page full data write process.

6. The free page management method based on a B+ tree database according to claim 5, characterized in that, The configuration conditions for triggering the start of the full data write process for the free page include: The configuration condition is whether the time interval between two adjacent idle page full data write processes reaches the preset time interval T0. When the time interval reaches T0 after the previous idle page full data write process is completed, the configuration condition is triggered and the current idle page full data write process begins to execute. The preset time interval T0 is configured according to the database write peak. And / or, the configuration condition is whether a call instruction is received. When a call instruction is received that the program actively triggers the full data writing process of the free page, the configuration condition is triggered and the full data writing process of the free page begins to execute.

7. The free page management method based on a B+ tree database according to any one of claims 1-6, characterized in that, It also includes the B+ tree database restart process: First, read all free page data into the global free page list, and simultaneously read the current transaction ID; Then read all the incremental page data and integrate the incremental page data with the same free page data in the full free page data to determine the transaction to be executed for the free page after the B+ tree database restarts.

8. The free page management method based on a B+ tree database according to claim 7, characterized in that, The process of integrating incremental page data with the same free page data from the full free page data to determine the transaction to be executed for the free page after the B+ tree database restarts includes: Check the incremental transaction ID of each free page in the incremental page data one by one; If the incremental transaction ID is recorded no later than the current transaction ID, then the incremental transaction ID is ignored. If the incremental transaction ID is recorded later than the current transaction ID, the current incremental page data is applied. If the transaction operation is a remove, the free page ID is removed from the global free page list. If the transaction operation is an add, the free page ID is added to the global free page list.

9. A free page management device based on a B+ tree database, characterized in that, include: Incremental data writing module for free pages: When a write transaction starts, it performs operations on the free pages according to the write transaction and records the incremental page data information of the free pages. The incremental page data information includes the transaction ID, the free page ID and the operation mode, which is "remove" or "add". The module for writing full data to free pages: When the configuration conditions for starting the full data writing process to free pages are triggered, it acquires and writes full free page data information, and clears the corresponding incremental page data information after the full free page data information is written. The full free page data information is the recorded full free pages and transaction IDs.

10. A computer-readable storage medium storing a computer-executable program, characterized in that, When the computer-executable program is executed, it implements the free page management method based on a B+ tree database as described in any one of claims 1-8.