A method for recycling a deleted index page, a readable storage medium and a computer device
By extending the transaction number length to 64 bits and using a preset threshold for judgment, the problem of deleted index pages not being reclaimed was solved, improving the reliability and performance of the database.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CETC JINCANG (BEIJING) TECH CO LTD
- Filing Date
- 2023-09-27
- Publication Date
- 2026-06-05
AI Technical Summary
In existing technologies, the reuse of transaction numbers prevents deleted index pages from being reclaimed, thus reducing the reliability of the database.
The transaction number is extended to 64 bits, and a preset threshold is used to determine whether to reclaim deleted index pages during index cleanup, preventing transaction number reuse and reducing performance loss caused by disk I/O operations.
This effectively prevents deleted index pages from being unrecoverable due to transaction number reuse, improving database reliability and performance, especially when the proportion of reread data is large.
Smart Images

Figure CN117290347B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a method for reclaiming deleted index pages, a machine-readable storage medium, and a computer device. Background Technology
[0002] When processing transactions in a database, transaction numbers are typically used to identify the corresponding transactions. Each transaction number includes the transaction number xmin for the inserted tuple and the transaction number xmax for the deleted tuple. When an index page is deleted, the transaction number xid of the corresponding transaction operation is assigned to that index page. When cleaning up deleted index pages, the system uses the transaction number xid of the corresponding transaction operation and the transaction number xmin of the inserted tuple to determine whether the deleted index page needs to be reclaimed.
[0003] In existing technologies, the transaction ID (xid) for transaction operations is 32 bits long. 2 to the power of 32 equals 4,294,967,296, so there can be a maximum of 4,294,967,296 transaction IDs, approximately 4.2 billion. As the number of transactions increases, the number of transaction IDs will eventually be exhausted. After all transaction IDs are used up, previously used transaction IDs (xids) will be reused. However, when transaction IDs (xids) are reused, it can lead to the inability to reclaim corresponding deleted index pages, resulting in reduced database reliability. Summary of the Invention
[0004] In view of the above problems, the present invention is proposed to provide a method, readable storage medium, and computer device for reclaiming deleted index pages that overcomes or at least partially solves the above problems. It can solve the problem in the prior art that deleted index pages cannot be reclaimed due to transaction number reuse, thereby improving the reliability of the database.
[0005] Specifically, to at least solve the above-mentioned technical problems, the present invention provides the following technical solutions:
[0006] In a first aspect, the present invention provides a method for reclaiming deleted index pages, comprising:
[0007] When an index page is deleted, the corresponding transaction number is assigned to the index page, wherein the transaction number is 64 bits long;
[0008] When performing index cleanup, determine whether the database parameters meet the preset conditions;
[0009] If not, a preset threshold is obtained, and a decision is made based on the preset threshold whether to perform a recycling operation on the deleted index page.
[0010] According to an embodiment of the present invention, after determining whether the database parameters meet the preset conditions, the method further includes:
[0011] If so, the deleted index pages will be recycled according to the preset cleanup ratio factor.
[0012] According to one embodiment of the present invention, the preset conditions include: the value of the preset cleanup ratio factor is less than or equal to 0, the number of remaining tuples in the heap is less than 0, the number of heap tuples during the last index cleanup is less than or equal to 0, or the value of the remaining tuples in the heap minus the number of heap tuples during the last index cleanup, divided by the number of heap tuples during the last index cleanup, is greater than or equal to the value of the preset cleanup ratio factor.
[0013] According to an embodiment of the present invention, a method for obtaining the value of the preset cleaning ratio factor includes:
[0014] Determine whether the percentage of newly inserted tuples before triggering the index cleanup is greater than or equal to 0;
[0015] If so, the value of the preset cleaning ratio factor is the percentage;
[0016] If not, the value of the preset cleanup ratio factor is the first feature value set at the global instance level.
[0017] According to an embodiment of the present invention, the method for obtaining the preset cleaning ratio factor further includes:
[0018] When the percentage of newly inserted tuples before triggering index cleanup is not greater than or equal to 0, if the preset cleanup ratio factor was specified as the second feature value when the index was created, then the value of the preset cleanup ratio factor is the second feature value.
[0019] According to an embodiment of the present invention, obtaining the preset threshold includes:
[0020] The preset threshold is read from the storage area of the index metadata.
[0021] According to an embodiment of the present invention, determining whether to perform a recycling operation on the deleted index page based on the preset threshold includes:
[0022] The cleanup threshold is obtained based on the number of deleted index pages and the preset threshold.
[0023] Deleted index pages that exceed the cleanup threshold are considered as deleted index pages that need to be reclaimed.
[0024] According to one embodiment of the present invention, after the deleted index pages are reclaimed, the method further includes:
[0025] Clean up the disk space used to reclaim the deleted index pages.
[0026] In a second aspect, the present invention provides a machine-readable storage medium having a machine-executable program stored thereon, wherein when the machine-executable program is executed by a processor, it implements the method for reclaiming deleted index pages according to any of the above embodiments.
[0027] Thirdly, the present invention provides a computer device including a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein when the processor executes the machine-executable program, it implements the method for recycling deleted index pages according to any of the above embodiments.
[0028] In the technical solution provided by this invention, when an index page is deleted, a corresponding transaction number is assigned to that index page. Since the transaction number is 64 bits long, it satisfies the usage range of transaction numbers, and it can be assumed that the transaction number will not be exhausted. Therefore, there will be no transaction number reuse, thus preventing the deleted index page from becoming unrecoverable due to transaction number reuse. Furthermore, during index cleanup, the technical solution of this invention performs a reclamation operation on deleted pages according to a preset threshold, thereby preventing performance loss caused by disk I / O operations due to frequent cleanup of deleted index pages. This is especially beneficial when the proportion of reread data is large, thus improving database performance.
[0029] 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
[0030] 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:
[0031] Figure 1 This is a schematic flowchart illustrating the existing methods for reclaiming deleted index pages;
[0032] Figure 2 This is a schematic diagram illustrating how existing technologies determine whether to reclaim deleted index pages;
[0033] Figure 3 This is a schematic flowchart of a method for recovering deleted index pages according to an embodiment of the present invention;
[0034] Figure 4This is a schematic flowchart of a method for recycling deleted index pages according to another embodiment of the present invention;
[0035] Figure 5 This is a schematic flowchart illustrating the recycling operation of deleted index pages according to an embodiment of the present invention;
[0036] Figure 6 This is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention;
[0037] Figure 7 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0038] The following reference Figure 1 and Figure 2 This describes the existing methods for reclaiming deleted index pages, referring to... Figures 3 to 7 This invention describes a method for reclaiming deleted index pages, a readable storage medium, and a computer device according to embodiments of the present invention. In this description, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature, that is, include one or more of that feature. In the description of the present invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified. When a feature "includes or contains" one or more of the features it encompasses, unless otherwise specifically described, this indicates that other features are not excluded and may be further included.
[0039] In the description of this embodiment, the terms "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0040] In KES (KingbaseES, the Kingbase database management system), there are two concepts of transaction number. One is the commonly used transaction number, such as the transaction number xmin for inserting a tuple and the transaction number xmax for deleting a tuple. The other is the virtual transaction ID.
[0041] In KES, the transaction ID is used to identify the processing order of the corresponding transaction, similar to Oracle's LSN (Logical Sequence Number). KES transaction IDs are reusable. A transaction ID is a permanent ID, signifying a sequence of changes to the database that transform it from one state to another, with the changes exhibiting durability, recoverability, and consistency. This aligns with the ACID (Atomic, Consistency, Isolation, Durability) principles of database theory. However, data query transactions do not require such permanent transaction IDs. They only need to handle MVCC (Multiversion Concurrency Control) and the acquisition and release of transaction locks. Therefore, a virtual transaction ID is sufficient, eliminating the need to acquire a transaction ID generated by XidGenLock (used to prevent two transactions from acquiring the same transaction ID), thus improving database performance.
[0042] Furthermore, using virtual transaction IDs prevents the database from rapidly reusing transaction IDs due to queries. When querying the database, the transaction number (xmin) of the inserted tuple and the transaction number (xmax) of the deleted tuple for each active process are obtained. KES's transaction implementation has three layers: top layer, middle layer, and bottom layer. The top layer stores the virtual transaction ID. Whether performing database queries or DML (Data Manipulation Language) operations, each command has a corresponding virtual transaction ID. The transaction ID is obtained in the bottom layer, only when data modification is involved. After modifying a tuple in the database, the corresponding transaction ID is stored in the tuple header. By comparing the transaction number (xmin) of the inserted tuple and the transaction number (xmax) of the deleted tuple in each tuple header, the visibility snapshot of the corresponding transaction can be obtained.
[0043] KES defines the transaction ID (xid) for a transaction operation as 32 bits long, thus allowing a maximum of 4,294,967,296 transaction IDs to be stored. Because transaction IDs are reused, they are concatenated to form a ring. Any given transaction ID (xid) needs to be divided equally, ensuring that half are larger than half are smaller; that is, there are over 210 million transactions smaller than the transaction ID (xid) and over 210 million transactions larger than the transaction ID (xid). Additionally, three transaction IDs have special meanings: "0" represents an invalid transaction ID, "1" represents a bootstrap transaction ID, "2" represents a frozen transaction ID, and "3" represents the smallest transaction ID (xid) of any transaction operation.
[0044] When an index page is deleted, the transaction number (xid) of the transaction that performed the deletion is assigned to that index page. In the vacuum process for handling deleted index pages, where vacuuming cleans up the database indexes, a value of type transaction id is used to determine when it is safe to reclaim the deleted index page. The method for determining this is as follows... Figure 1 As shown, it includes the following steps:
[0045] Step S101: When cleaning up the deleted index pages, obtain the deleted index pages;
[0046] Step S102: Determine whether the transaction number xid of the transaction operation corresponding to the deleted index page is less than the transaction number xmin of the corresponding inserted tuple. Figure 2 As shown;
[0047] If so, proceed to step S103;
[0048] In this step, the transaction ID stored in the working state BTVacState structure in btvacuumpage can be obtained to get the transaction number xid value of the corresponding transaction operation and the transaction number xmin of the corresponding insertion tuple; where btvacuumpage is the page processed by vacuum, and BTVacState is the structure on btvacuumpage used to store the transaction ID.
[0049] Step S103: Reclaim the deleted index pages.
[0050] When the transaction number xid of a transaction operation is greater than 2 to the power of 32, the transaction number xid will be reused. This can lead to a situation where the transaction number xid of the transaction operation is greater than the transaction number xmin of the corresponding inserted tuple, causing unused deleted index pages to not be reclaimed. For example, if the transaction number xid of the previously deleted index page was 10 (xid is stored in binary form, 10 is decimal for illustration), after one round of reuse, this transaction number with an xid value of 10 may be used again, preventing the already deleted index page from being reclaimed.
[0051] Please see Figure 3 , Figure 3 The diagram shown is a schematic flowchart of a method for reclaiming deleted index pages according to an embodiment of the present invention. This method can solve the problem mentioned above where the deletion of index pages cannot be reclaimed due to the reuse of transaction number xid. The following is in conjunction with... Figure 1 The flowchart shown provides a detailed description of the method for recovering deleted index pages in this embodiment.
[0052] like Figure 3 As shown, the method for reclaiming deleted index pages in this embodiment includes the following steps:
[0053] Step S1: When an index page is deleted, assign the transaction number corresponding to that index page to that index page;
[0054] Step S2: When performing index cleanup, determine whether the database parameters meet the preset conditions;
[0055] If not, proceed to step S3;
[0056] Step S3: Obtain a preset threshold and determine whether to reclaim the deleted index pages based on the preset threshold.
[0057] In step S1 above, the transaction number xid corresponding to the transaction operation of the index page is 64 bits long. The value of 2 to the power of 64 is 1844 6744 0737 0955 1616, which translates to 16 million 1TB in computer counting units. Within the current usage range, this can be considered unlikely to be fully utilized. In this embodiment, `fullTransactionid` can be used to replace the original value of type `transactionid`, that is, a 64-bit transaction number xid is used to identify the corresponding transaction, in order to determine whether the index page should be recycled and reused.
[0058] To easily check whether the transaction number xid of the corresponding transaction operation on the index page is 64 bits long, when the transaction number xid of the corresponding transaction operation on the index page is 32 bits long, the information of the transaction number xid of the relevant transaction operation can be printed in the log. For example, the displayed content can be in the form of epoch:xid, where the initial value of epoch is 0, and the value of epoch is incremented by 1 each time the transaction number xid is reused.
[0059] When the transaction number xid of a transaction operation is 64 bits long, it can solve the problem of unrecoverable deleted index pages caused by reuse when the transaction number xid of a transaction operation is 32 bits, thereby reducing disk space expansion and improving database performance.
[0060] In step S2 above, the cleaning process for the deleted index pages refers to the cleanup phase during the execution of vacuum, that is, the cleanup phase during the process of cleaning up the deleted index pages.
[0061] In step S3 above, the method for determining whether to reclaim deleted index pages based on a preset threshold includes: determining whether the proportion of deleted index pages is greater than or equal to a preset threshold; if so, reclaiming deleted index pages based on the preset threshold.
[0062] In this embodiment, when an index page is deleted, a corresponding transaction number is assigned to that index page. Since the transaction number is 64 bits long, it satisfies the usage range of transaction numbers, meaning it can be assumed that the transaction number will not be exhausted. Therefore, transaction number reuse will not occur, preventing the deleted index page from becoming unrecoverable due to transaction number reuse. Furthermore, during index cleanup, this embodiment also performs a reclamation operation on deleted pages based on a preset threshold, preventing performance degradation caused by frequent cleanup of deleted index pages due to disk I / O operations. This is especially beneficial when the proportion of reread data is high, thus improving database performance.
[0063] In one embodiment of the present invention, such as Figure 5 As shown, after determining whether the database parameters meet the preset conditions in step S2 above, the process further includes:
[0064] If so, proceed to step S4;
[0065] Step S4: Reclaim the deleted index pages according to the preset cleanup ratio factor.
[0066] The number of records in the current table is stored on the btree index meta page: the value of the meta page is updated only when no dead tuples are found in the entire table during vacuuming. The meta page is counted using a statistical counter such as KES_stat_all_tables (i.e., a table statistical counter).
[0067] In this embodiment, the method for recycling deleted index pages according to a preset cleanup ratio factor includes:
[0068] The vacuum cleanup phase only requires a Scan INDEX to scan the deleted index pages and update the INDEX stat information when ((KES_stat_all_tables insert counter value on the data table - meta page) / meta page) is greater than vacuum_cleanup_index_scale_factor. This INDEX stat uses the meta page counter for counting. Here, vacuum_cleanup_index_scale_factor is the preset cleanup scale factor, and KES_stat_all_tables insert counter is the table insertion statistics counter on the data table.
[0069] By using the configuration method of this embodiment, when the database parameters meet the preset conditions, the deleted index pages can be recycled according to the preset cleanup ratio factor, thereby improving the reliability of the recycling of deleted index pages.
[0070] In one embodiment of the present invention, when determining whether the database parameters meet the preset conditions in step S2 above, the preset conditions include:
[0071] First preset condition: The value of the preset cleanup ratio factor is less than or equal to 0;
[0072] The second precondition is that the number of remaining tuples in the heap is less than 0, where the number of remaining tuples in the heap is the number of active tuples that have not been deleted.
[0073] The third preset condition: the number of heap tuples during the last index cleanup is less than or equal to 0;
[0074] Fourth preset condition: The value of the remaining tuples in the heap minus the number of heap tuples during the last index cleanup, divided by the number of heap tuples during the last index cleanup, is greater than or equal to the value of the preset cleanup scaling factor.
[0075] In this embodiment, when the database parameters meet any one of the first, second, third, and fourth preset conditions, it is determined that the database parameters meet the preset conditions.
[0076] Take the following data as an example:
[0077] Set vacuum_cleanup_index_scale_factor=0.1;
[0078] Create table test(sno int,pno int);
[0079] Create index test_pno_idx on test(pno);
[0080] Insert into test select generate_series(1,3000),random()*1000::integer;
[0081] Delete from test where pno>12 and pno<800;
[0082] Vacuum sells;
[0083] Select *from KES_class where relname='test_pno_idx ';
[0084] Assuming the above procedure results in 11 deleted index pages out of 3000 rows (relpage count is 11), and the preset cleanup scale factor (vacuum_cleanup_index_scale_factor) is 0.1, the first preset condition is not met. The query "Delete from test where pno>12 and pno<800" yields 668 remaining tuples in the heap, failing the second preset condition. The number of heap tuples during the last index cleanup was also 668, failing the third preset condition. The value of "remaining tuples in the heap" minus "number of heap tuples during the last index cleanup" divided by "number of heap tuples during the last index cleanup" is (668-668) / 668=0, which is less than the preset cleanup scale factor of 0.1, failing the fourth preset condition. Therefore, it is determined that the database parameters do not meet the preset conditions, and the decision to reclaim the deleted index pages is based on the preset threshold.
[0085] The configuration method in this embodiment can accurately determine whether deleted index pages need to be reclaimed based on a preset threshold, thereby improving the efficiency of deleting index page reclamation.
[0086] In one embodiment of the present invention, when determining whether the database parameters meet the preset conditions in step S2 above, a method for obtaining a preset cleanup ratio factor is further included, the method comprising:
[0087] Determine if the percentage of newly inserted tuples before triggering index cleanup is greater than or equal to 0;
[0088] If so, the percentage of newly inserted tuples before triggering index cleanup will be used as the value of the preset cleanup ratio factor.
[0089] If not, the first feature value set at the global instance level will be used as the value of the preset cleanup scaling factor.
[0090] In this embodiment, the value of the vacuum_cleanup_index_scale_factor parameter can be set as the first feature value at the global instance level; when the percentage of newly inserted tuples before triggering index cleanup is not greater than or equal to 0, the value of the preset scale factor is set to this first feature value.
[0091] The setting method in this embodiment can determine the value of the preset cleanup ratio factor based on the percentage of tuples inserted before triggering index cleanup, thereby improving the accuracy and reliability of the preset cleanup ratio factor.
[0092] In one embodiment of the present invention, the method for obtaining a preset cleaning ratio factor further includes:
[0093] When the percentage of newly inserted tuples before triggering index cleanup is not greater than or equal to 0, if a preset cleanup ratio factor is specified as the second feature value when the index is created, then the value of the preset cleanup ratio factor is the second feature value instead of the first feature value.
[0094] In this embodiment, when creating the index, the parameter `vacuum_cleanup_index_scale_factor` can be set to record the second feature value. Assuming the second feature value of `vacuum_cleanup_index_scale_factor` is set to 40%, while the first feature value of `vacuum_cleanup_index_scale_factor` set globally is 0.1, the preset cleanup scale factor is 40% when the percentage of newly inserted tuples before triggering index cleanup is not greater than or equal to 0.
[0095] In this embodiment, the second feature value set when creating the index can be used as the value of the cleanup ratio factor. Therefore, the reliability of cleaning up index pages can be improved by recycling the deleted index pages according to the cleanup ratio factor.
[0096] In one embodiment of the present invention, the method for obtaining the preset threshold in step S3 above includes: reading the preset threshold from the storage area of index metadata.
[0097] In this embodiment, a feature parameter can be set in the storage area of the index metadata. For example, this feature parameter can be `vacuum_delete_not_recycled_index_scale_factor`, and a preset threshold can be recorded through this feature parameter. This preset threshold can be in the range of 0-1, for example, it can be 0.05. When executing step S3, the preset threshold can be obtained from the feature parameter `vacuum_delete_not_recycled_index_scale_factor` in the index metadata storage area by reading data.
[0098] The setting method in this embodiment allows for the reading of preset thresholds from the storage area of index metadata via data reading, thereby improving the convenience and accuracy of obtaining preset thresholds.
[0099] In one embodiment of the present invention, after determining whether to perform a recycling operation on the deleted index page based on a preset threshold in step S3 above, the method further includes: if it is determined based on the preset threshold that a recycling operation on the deleted index page is required, then using... Figure 5 The method shown performs a recycling operation on deleted index pages, and the method includes the following steps:
[0100] Step S301: Obtain the cleanup threshold based on the number of deleted index pages and the preset threshold;
[0101] Step S302: Deleted index pages that exceed the above-mentioned cleanup threshold are designated as deleted index pages that need to be reclaimed.
[0102] In step S301 above, the number of deleted index pages can be multiplied by a preset threshold to obtain the cleanup threshold. For example, if the number of deleted index pages found is 11 and the preset threshold is 0.05, then the cleanup threshold is 11 × 5% = 0.55.
[0103] In step S302 above, by comparison, if the number of deleted index pages whose content exceeds the above cleanup threshold is 6, then 6 deleted index pages need to be reclaimed. Therefore, deleted index pages whose content exceeds the cleanup threshold of 0.05 are reclaimed.
[0104] By using the configuration method of this embodiment, the deleted index pages that need to be recycled can be obtained according to a preset threshold. When the proportion of deleted index pages is greater than the preset threshold, the deleted index pages can be recycled, thereby improving the accuracy and reliability of the recycling of deleted index pages.
[0105] In one embodiment of the present invention, after the deleted index pages are reclaimed, the method further includes: cleaning up the disk space of the reclaimed deleted index pages.
[0106] By using the configuration method in this embodiment, the disk space of deleted index pages can be released, so that the disk space can be reused, thereby improving the reliability of the database.
[0107] This embodiment also provides a machine-readable storage medium and a computer device. Figure 6 This is a schematic diagram of a machine-readable storage medium 830 according to an embodiment of the present invention; Figure 7 This is a schematic diagram of a computer device 900 according to an embodiment of the present invention. A machine-readable storage medium 830 stores a machine-executable program 840 thereon, which, when executed by a processor, implements the method for reclaiming deleted index pages according to any of the above embodiments.
[0108] Computer device 900 may include memory 920, processor 910, and machine-executable program 840 stored on memory 920 and running on processor 910. When processor 910 executes machine-executable program 840, it implements the method for recycling deleted index pages of any of the above embodiments.
[0109] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by, or in conjunction with, instruction execution systems, apparatuses or devices (such as computer-based systems, processor-included systems or other systems that can fetch and execute instructions from, an instruction execution system, apparatus or device).
[0110] For the purposes of this embodiment, the machine-readable storage medium 830 can be any means capable of containing, storing, communicating, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection (electronic device) having one or more wires, a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, the machine-readable medium can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0111] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system.
[0112] Computer device 900 can be, for example, a server, desktop computer, laptop computer, tablet computer, or smartphone. In some examples, computer device 900 can be a cloud computing node. Computer device 900 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 900 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked via a communication network. In a distributed cloud computing environment, program modules can reside on local or remote computing system storage media, including storage devices.
[0113] Computer device 900 may include a processor 910 adapted to execute stored instructions and a memory 920 that provides temporary storage space for the operation of said instructions during operation. The processor 910 may be a single-core processor, a multi-core processor, a computing cluster, or any other configuration. The memory 920 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.
[0114] The processor 910 can be connected via a system interconnect (e.g., PCI, PCI-Express, etc.) to an I / O interface (input / output interface) suitable for connecting the computer device 900 to one or more I / O devices (input / output devices). I / O devices may include, for example, a keyboard and indicating devices, where indicating devices may include a touchpad or touchscreen, etc. I / O devices may be built into the computer device 900 or may be external devices connected to the computing device.
[0115] The processor 910 can also be linked via a system interconnect to a display interface suitable for connecting the computer device 900 to a display device. The display device may include a display screen as a built-in component of the computer device 900. The display device may also include an external computer monitor, television, or projector connected to the computer device 900. Furthermore, a network interface controller (NIC) may be adapted to connect the computer device 900 to a network via a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as an Internet Minicomputer System Interface) to transmit data. The network may be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, etc. Remote devices can connect to the computing device via the network.
[0116] 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 reclaiming deleted index pages, characterized in that, include: When an index page is deleted, the corresponding transaction number is assigned to the index page, wherein the transaction number is 64 bits long; When performing index cleanup, determine whether the database parameters meet the preset conditions; If not, a preset threshold is obtained, and a decision is made based on the preset threshold whether to perform a recycling operation on the deleted index page; wherein, the decision on whether to perform a recycling operation on the deleted index page based on the preset threshold includes: The cleanup threshold is obtained based on the number of deleted index pages and the preset threshold. Deleted index pages that exceed the cleanup threshold are considered as deleted index pages that need to be reclaimed.
2. The method for recovering deleted index pages according to claim 1, characterized in that, After determining whether the database parameters meet the preset conditions, the process further includes: If so, the deleted index pages will be recycled according to the preset cleanup ratio factor.
3. The method for recovering deleted index pages according to claim 1, characterized in that, The preset conditions include: the value of the remaining tuples in the heap minus the number of heap tuples during the last index cleanup, divided by the number of heap tuples during the last index cleanup, is greater than or equal to the value of the preset cleanup ratio factor.
4. The method for recovering deleted index pages according to claim 1, characterized in that, The process of obtaining the preset threshold includes: The preset threshold is read from the storage area of the index metadata.
5. The method for recovering deleted index pages according to any one of claims 1-4, characterized in that, After reclaiming the deleted index pages, the process also includes: Clean up the disk space used to reclaim the deleted index pages.
6. A machine-readable storage medium having a machine-executable program stored thereon, wherein the machine-executable program, when executed by a processor, implements the method for reclaiming deleted index pages according to any one of claims 1 to 5.
7. A computer device comprising a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein when the processor executes the machine-executable program, it implements the method for reclaiming deleted index pages according to any one of claims 1 to 5.