Index bloat suppression method and apparatus, and computing device cluster
By identifying and recycling recyclable pages in indexes and reusing these pages when needed, the index bloating problem is solved, and effective management of database storage space and performance stability is achieved.
Patent Information
- Application Number
- PCT/CN2024/115745
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-08
- Filing Date
- 2024-08-30
- Publication Date
- 2025-06-12
AI Technical Summary
The existing technology is difficult to perceive and suppress index inflation in a timely manner, resulting in continuous index inflation and waste of database storage space.
By determining the index inflation, identifying recyclable pages and adding them to the page recovery queue, multiplexing the pages in the recycling queue to achieve suppression of index inflation.
Effectively suppress index bloat, prevent waste of storage space, and ensure stable database performance.
Smart Images

Figure CN2024115745_12062025_PF_FP_ABST
Abstract
Description
Index expansion suppression method, device and computing device cluster
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on December 8, 2023, with application number 202311690375.0 and application name “A method, device and computing device cluster for suppressing index expansion”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of information technology (IT), and in particular to an index expansion suppression method, apparatus, and computing device cluster. Background Art
[0003] Indexes are key components for accelerating database queries, but over time, they can become bloated, leading to performance degradation and wasted storage resources. For example, if a business has index skew, indexes are written and deleted out of order, or indexes are marked for deletion and the space is not promptly reclaimed and reused, the indexes can occupy far more storage space than required for the amount of data they store. This in turn wastes a significant amount of database storage space and leads to index bloat. To maintain database stability, it's often necessary to suppress index bloat. However, index bloat often goes undetected, resulting in persistent index bloat.
[0004] Summary of the Invention
[0005] The present application provides an index expansion suppression method, apparatus, computing device cluster, computer storage medium, and computer product, which can effectively suppress index expansion.
[0006] In a first aspect, the present application provides a method for suppressing index expansion, comprising: determining that an index has expanded; identifying reclaimable pages contained in the index; and sequentially adding each reclaimable page to a page recycling queue, where reclaimable pages include sparse pages or empty pages; and, when the index requires a new page, sequentially reusing pages contained in the page recycling queue. Thus, when an index expands, reclaimable pages in the index are sequentially added to the page recycling queue, and the pages in the page recycling queue are sequentially reused, thereby suppressing index expansion.
[0007] In some embodiments, determining whether an index has experienced bloat includes: obtaining a first size of a key inserted into the index by an insert operation, a second size of a key deleted from the index by a delete operation, and a third size of an extended page generated by a split in the index; and determining whether an index has experienced bloat based on the first, second, and third sizes, and the bloat size contained in statistical information in the database. This eliminates the need to rely solely on statistical information as the sole source of bloat awareness, and instead incorporates bloat awareness into the index insertion and deletion processes. Index bloat awareness is derived from the integration of insertion, deletion, and statistical information, ensuring real-time awareness while addressing the issue of delayed statistical bloat awareness.
[0008] In some embodiments, determining whether an index has expanded based on the first size, the second size, the third size, and the expansion size contained in statistical information in a database includes: determining the expansion space size of the index based on the first size, the second size, the third size, and the expansion size; determining the expansion rate of the index based on the expansion space size of the index, the total number of pages in the index, and the size of each page in the index; and determining that the index has expanded if the expansion space of the index is greater than a preset space size and the expansion rate of the index is greater than a preset ratio threshold. In this way, whether the index has expanded is determined based on the expansion space size and the expansion rate of the index.
[0009] In some embodiments, the method further includes: the size of the expansion space of the persistent index. This can prevent the expansion information from being lost in situations such as abnormal restarts, which would cause inaccurate expansion perception.
[0010] In some embodiments, adding any reclaimable page to a page reclaim queue includes: if the commit / modify timestamp of the latest transaction on any reclaimable page is greater than the maximum commit / modify timestamp in the metadata of the index, updating the maximum commit / modify timestamp to the commit / modify timestamp of the latest transaction; adding a reclaim timestamp to any reclaimable page; and updating the reuse timestamp in the metadata to the reclaim timestamp; and adding any reclaimable page to the page reclaim queue. In this way, the reclaiming of pages in the index is achieved through the two timestamps in the metadata.
[0011] In some embodiments, reusing any page included in the page recycling queue includes: reusing any page, and updating the reuse timestamp in the metadata to the recycling timestamp of the any page, thereby achieving page reuse.
[0012] In some embodiments, the method further includes allowing access to / modification of the index if the time of accessing / modifying the index is greater than or equal to the maximum commit timestamp, and the time of accessing / modifying a page in the index is greater than or equal to the reclaim time. This ensures that index expansion is suppressed and concurrent services accessing and modifying the index do not interfere with or block each other.
[0013] In the second aspect, the present application provides an index expansion suppression device, including: a determination module for determining whether an index has expanded; a recycling module for identifying recyclable pages contained in the index, and adding each recyclable page to a page recycling queue in turn, where the recyclable pages include: sparse pages or empty pages; and a multiplexing module for reuse of the pages contained in the page recycling queue in turn when the index requires a new page.
[0014] In some embodiments, when determining that an index has expanded, the determination module is specifically used to: obtain a first size of a key inserted by an insert operation in the index, a second size of a key deleted by a delete operation in the index, and a third size of an extended page generated by splitting the index; and determine that the index has expanded based on the first size, the second size, the third size and the expansion size contained in the statistical information in the database.
[0015] In some embodiments, when the determination module determines that the index has expanded based on the first size, the second size, the third size, and the expansion size contained in the statistical information in the database, it is specifically used to: determine the expansion space size of the index based on the first size, the second size, the third size, and the expansion size; determine the expansion rate of the index based on the expansion space size of the index, the total number of pages of the index, and the size of each page of the index; if the expansion space of the index is greater than the preset space size and the expansion rate of the index is greater than the preset ratio threshold, determine that the index has expanded.
[0016] In some embodiments, the determination module is further configured to: determine the expansion space size of the persistent index.
[0017] In some embodiments, when the recycling module adds any reclaimable page to the page recycling queue, it is specifically used to: if the commit / modify timestamp of the latest transaction on any reclaimable page is greater than the maximum commit / modify timestamp in the metadata of the index, update the maximum commit / modify timestamp to the commit / modify timestamp of the latest transaction; add a recycling timestamp to any reclaimable page, and update the reuse timestamp in the metadata to the recycling timestamp; add any reclaimable page to the page recycling queue.
[0018] In some embodiments, when reusing any page included in the page recycling queue, the multiplexing module is specifically configured to: reuse the any page, and update the reuse timestamp in the metadata to the recycling timestamp of the any page.
[0019] In some embodiments, the multiplexing module is further used to: allow access / modification of the index if the time of accessing / modifying the index is greater than or equal to the maximum commit timestamp, and the time of accessing / modifying a page in the index is greater than or equal to the recycle time.
[0020] In a third aspect, the present application provides a computing device cluster comprising at least one computing device, each computing device comprising a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster performs the method described in the first aspect or any possible implementation of the first aspect.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method described in the first aspect or any possible implementation of the first aspect. The computing device cluster may include one or more computing devices.
[0022] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, causes the computing device cluster to perform the method described in the first aspect or any possible implementation of the first aspect. The computing device cluster may include one or more computing devices.
[0023] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] FIG1 is a schematic diagram of the logical architecture of a database management system provided in an embodiment of the present application;
[0025] FIG2 is a flow chart of a method for suppressing index expansion provided in an embodiment of the present application;
[0026] FIG3 is a schematic diagram of a step of adding a recyclable page to a page recycling queue according to an embodiment of the present application;
[0027] FIG4 is a schematic diagram of a process of page recycling and reuse provided by an embodiment of the present application;
[0028] FIG5 is a schematic structural diagram of an index expansion suppression device provided in an embodiment of the present application;
[0029] FIG6 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0030] FIG7 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application;
[0031] FIG8 is a schematic diagram of the structure of another computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The term "and / or" as used herein describes an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. The symbol " / " as used herein indicates that the related objects are in an "or" relationship, for example, A / B means either A or B.
[0033] The terms "first" and "second" in this specification and claims are used to distinguish different objects rather than to describe a specific order of objects. For example, "first response message" and "second response message" are used to distinguish different response messages rather than to describe a specific order of response messages.
[0034] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0035] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more, for example, multiple processing units means two or more processing units, etc.; multiple elements means two or more elements, etc.
[0036] First, the relevant technical terms involved in the embodiments of this application are introduced.
[0037] (1) Index expansion
[0038] Index bloat occurs when the index structure gradually grows over time, causing the index to occupy more storage space than the actual data stored. Index bloat is typically caused by frequent data deletion and update operations, coupled with delayed index maintenance operations (such as rebuilding the index and cleaning up fragments). This results in the index structure becoming less compact and a large amount of invalid or redundant data remaining.
[0039] (2) Swelling inhibition
[0040] Bloat suppression refers to taking measures or performing operations (such as reclaiming and reusing free index space) to limit or slow down the expansion of the index structure so that the storage space occupied by the index is close to the space required for the actual data stored in the index.
[0041] Next, the technical solutions provided in the embodiments of the present application are introduced.
[0042] For example, Figure 1 is a schematic diagram of the logical architecture of a database management system provided in an embodiment of the present application. As shown in Figure 1, the database management system may include a client 100 and a database 200. Database 200 may include an execution engine 210 and a storage engine 220. Client 100 refers to various forms of database connection, such as the ActiveX data objects (ADO) connection used in .NET and the Java database connection (JDBC) connection used in Java.
[0043] The execution engine 210 is mainly responsible for generating an efficient execution plan for the structured query language (SQL) statement input by the client 110 under the current load scenario, and running the execution plan. In addition, when accessing and modifying the index in the storage engine 220, the execution engine 210 can also count the expansion of the index, and / or persist the counted index expansion to the storage engine 220. The execution engine 210 may include: a connector 211, a query cache 212, a parser 213, an optimizer 214 and an executor 215. The connector 211 is mainly responsible for communicating with the client 110, as well as business logic processing such as connection authentication, connection number judgment, and connection pool processing. The main function of the query cache 212 is to improve the efficiency of the query. The cache is stored in the form of a hash table of key and value. The key is a specific SQL statement and the value is a collection of results. When a SQL statement arrives, if the query cache function is turned on, the execution engine 210 can first check whether there is a data match in the query cache 212. If there is a match, the matching data will be directly returned to the client 110 without parsing the corresponding SQL statement. However, if the SQL statement contains user-defined functions, stored functions, user variables or temporary tables, it will not pass through the query cache 212. If there is no match in the query cache 212, the parser 213 will be used to parse the corresponding SQL statement. The parser 213 is mainly responsible for parsing the SQL statement according to grammatical rules and generating an internally recognizable parse tree. The optimizer 214 is responsible for optimizing the parse tree generated by the parser 213 to find an optimal execution plan. The executor 215 is mainly responsible for calling the interface of the storage engine 220 to execute the query or other operations according to the optimal execution plan after the optimizer 214 finds the optimal execution plan, and finally returning the query result set to the client 110.
[0044] The storage engine 220 is primarily responsible for data storage, retrieval, and management. It defines how the database management system organizes data, executes queries and transactions, and important features such as data security and reliability. Additionally, the storage engine 220 may also be responsible for storing indexes or the size of index expansion space.
[0045] For example, FIG2 shows a flow chart of an index expansion suppression method provided by an embodiment of the present application. It is understood that the method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities. As shown in FIG2 , the index expansion suppression method may include the following steps:
[0046] S201: Determine whether an index is expanded, and add the index to a queue to be suppressed.
[0047] In this embodiment, statistical information in the database associated with the index can be used to determine whether the index has expanded. The statistical information includes the statistically determined index expansion size. When the index expansion size in the statistical information exceeds a preset size threshold, the index is determined to have expanded. Furthermore, to improve the accuracy of the determination, the index expansion rate can also be incorporated into the determination. When the index expansion size exceeds a preset size threshold and the index expansion rate exceeds a preset expansion rate threshold, the index is determined to have expanded. The index expansion rate can be determined based on the index expansion size, the total number of index pages, and the size of each index page. Specifically, the index expansion rate is: expand_ration = expand_size ÷ (real_total_pages × pages_size), where expand_size is the index expansion size, real_total_pages is the total number of index pages, and page_size is the size of each index page. After determining that an index has expanded, the index can be added to a queue for expansion suppression. Exemplarily, the queue for expansion suppression can include identifiers of each index experiencing expansion. Exemplarily, the index can be, but is not limited to, a Btree / B+tree.
[0048] As a possible implementation, to achieve real-time awareness of index expansion, when performing an insert operation in the index, a first size of the inserted key can be obtained. When performing a delete operation in the index, a second size of the deleted key can be obtained. Furthermore, a third size of the expanded page generated by splitting the index can be obtained. Then, based on the first, second, and third sizes, and the expanded size of the index in the statistical information, a determination is made as to whether the index has expanded. An expanded size can be determined based on the first, second, and third sizes. Exemplarily, this expanded size is: expanded_size + deleted_size - insert_size, where expanded_size is the third size, deleted_size is the second size, and insert_size is the first size. This expanded size is then compared with the expanded sizes in the statistical information, and the largest expanded size is selected as the index expansion headroom size. When this expanded headroom size exceeds a preset size threshold, the index is determined to have expanded. Furthermore, the index expansion rate can also be incorporated into this determination. At this time, the expansion rate of the index is determined by the size of the index's expansion space, the total number of index pages, and the size of each index page.
[0049] Furthermore, after determining the expansion space size of the index, the expansion space size can be persisted to prevent the expansion information from being lost in situations such as abnormal restart, which would cause inaccurate expansion perception.
[0050] S202 : Identify at least one reclaimable page included in the index in the queue to be suppressed from expansion, and sequentially add each reclaimable page to the page reclaim queue, wherein the reclaimable page includes: a sparse page or an empty page.
[0051] In this embodiment, the reclaimable pages included in the index in the expansion suppression queue can be identified in sequence. During the identification, all pages in the index can be traversed. After the reclaimable pages are identified, the reclaimable pages in the identified index can be added to the page reclaim queue in sequence. Reclaimable pages include sparse pages or empty pages. Sparse pages refer to pages where the space occupied by data on the page is less than a preset space threshold. In some embodiments, adding any reclaimable page to the page reclaim queue may include the following steps: S301. When the commit / modify timestamp of the latest transaction on any reclaimable page is greater than the maximum commit / modify timestamp in the metadata of the index, the maximum commit / modify timestamp in the metadata is updated to the commit / modify timestamp of the latest transaction. S302. Adding a reclaim timestamp to the any reclaimable page, and updating the reuse timestamp in the metadata to the reclaim timestamp. S303. Adding the any reclaimable page to the page reclaim queue. For ease of understanding, the following example is used for explanation. Refer to Figure 4. As shown in Figure 4(A), index a has expanded, and the reclaimable pages within it are pages 1, 3, and 4. The commit time of the latest transaction on page 1 is T1, the commit time of the latest transaction on page 3 is T2, and the commit time of the latest transaction on page 4 is T3, with T2 < T1 < T3. Furthermore, in Figure 4(A), the maximum commit timestamp (Max_commit_time) and the reuse timestamp (Reused_time) in the metadata area of index a are initialized. When traversing the reclaimable pages in index a, page 1 is first identified and can be reclaimed. During reclaim, as shown in Figure 4(B), the Max_commit_time in the metadata area of index a is updated to T1, and the Reused_time is updated to the reclaim timestamp t1 of page 1. Furthermore, t1 is added to page 1 and page 1 is added to the page reclaim queue, completing the reclaim of page 1. When traversing to page 2, it is determined that this page is not reclaimable, and page 3 is then identified. Page 3 is identified as a recyclable page, and page 3 is recycled. During recycling, as shown in (C) of Figure 4, since T2 < T1, the Max_commit_time in the metadata area can remain unchanged, and the Reused_time can be updated to the recycling timestamp t2 of page 3, and t2 is added to page 3, and page 3 is added to the page recycling queue, thus completing the recycling of page 3. When traversing to page 4, it is identified that the page is a recyclable page, and page 4 is recycled. During recycling, as shown in (D) of Figure 4, since T1 < T3, T1 of the Max_commit_time in the metadata area is updated to T3, and the Reused_time is updated to the recycling timestamp t3 of page 4, and t3 is added to page 4, and page 4 is added to the page recycling queue, thus completing the recycling of page 4.In some embodiments, access / modification of the index is allowed when the time to access / modify the index is greater than or equal to the maximum commit timestamp, and the time to access / modify a page in the index is greater than or equal to the recycle time, thereby ensuring that index expansion is suppressed and concurrent business access and modification of the index do not interfere with or block each other.
[0052] S203: When a new page is needed for the index, the pages contained in the page recycling queue are reused in sequence.
[0053] In this embodiment, when a new page is needed in the index, the pages contained in the page recycling queue can be reused in sequence, so that there is no need to wait for the end of a long transaction or a long query, and the expansion caused by applying for new space can be avoided. Exemplarily, when reusing any page contained in the page recycling queue, the reuse timestamp in the metadata can be updated to the recycling timestamp of the reused page after the page is reused. For example, referring to Figure 4, as shown in (E) of Figure 4, when reusing page 4, since the Reused_time in the metadata area is the recycling timestamp t3 of page 4, the Reused_time does not need to be updated. As shown in (F) of Figure 4, when reusing page 3, t3 in the Reused_time in the metadata area can be updated to the recycling timestamp t2 of page 3. As shown in (G) of Figure 4, when reusing page 1, t2 in the Reused_time in the metadata area can be updated to the recycling timestamp t1 of page 1.
[0054] In this way, when the index expands, the recyclable pages in the index are added to the page recycling queue in sequence, and the pages in the page recycling queue are reused in sequence, thereby suppressing the expansion of the index.
[0055] It is understood that in Figure 2 , each time an index is determined to be bloated, reclaimable pages in that index can be identified. Alternatively, the bloated index can be added to a queue to be suppressed, and then reclaimable pages in the indexes in the queue can be identified sequentially. The specific method can be determined based on actual circumstances and is not limited here. Furthermore, the different steps in Figure 2 can be executed by different threads, but are not limited to, to improve the efficiency of index bloat detection and suppression.
[0056] It should be understood that the order of execution of the steps in the above embodiments does not necessarily imply a specific order of execution. The order of execution of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of this application. In addition, the various embodiments described above can be combined according to actual circumstances, and the combined solutions are still within the scope of protection of this application.
[0057] Based on the method in the above embodiment, an embodiment of the present application provides an index expansion suppression device.
[0058] For example, FIG5 shows a schematic structural diagram of an index expansion suppression device provided by an embodiment of the present application. As shown in FIG5 , the index expansion suppression device 500 includes: a determination module 501, a recycling module 502, and a reuse module 503. Among them, the determination module 501 is used to determine whether the index has expanded. The recycling module 502 is used to identify the recyclable pages contained in the index, and to add each recyclable page to the page recycling queue in turn. The recyclable pages include: sparse pages or empty pages. The reuse module 503 is used to reuse the pages contained in the page recycling queue in turn when the index requires a new page.
[0059] In some embodiments, when determining that an index has expanded, the determination module 501 is specifically used to: obtain a first size of a key inserted by an insert operation in the index, a second size of a key deleted by a delete operation in the index, and a third size of an extended page generated by splitting the index; and determine that the index has expanded based on the first size, the second size, the third size and the expansion size contained in the statistical information in the database.
[0060] In some embodiments, when the determination module 501 determines that the index has expanded based on the first size, the second size, the third size and the expansion size contained in the statistical information in the database, it is specifically used to: determine the expansion space size of the index based on the first size, the second size, the third size and the expansion size; determine the expansion rate of the index based on the expansion space size of the index, the total number of pages of the index and the size of each page of the index; when the expansion space of the index is greater than the preset space size and the expansion rate of the index is greater than the preset ratio threshold, determine that the index has expanded.
[0061] In some embodiments, the determination module 501 is further configured to: determine the expansion space size of the persistent index.
[0062] In some embodiments, when adding any reclaimable page to the page reclaim queue, the recycling module 502 is specifically used to: update the maximum commit / modify timestamp to the commit / modify timestamp of the latest transaction on any reclaimable page when the commit / modify timestamp of the latest transaction is greater than the maximum commit / modify timestamp in the metadata of the index; add a reclaim timestamp to any reclaimable page, and update the reuse timestamp in the metadata to the reclaim timestamp; add any reclaimable page to the page reclaim queue.
[0063] In some embodiments, when reusing any page included in the page recycling queue, the multiplexing module 503 is specifically configured to: reuse any page, and update the reuse timestamp in the metadata to the recycling timestamp of the any page.
[0064] In some embodiments, the reuse module 503 is further used to allow access / modification of the index if the time of accessing / modifying the index is greater than or equal to the maximum commit timestamp and the time of accessing / modifying a page in the index is greater than or equal to the recycle time.
[0065] In some embodiments, the determination module 501, recycling module 502, and reuse module 503 shown in FIG5 can all be implemented by software or hardware. Exemplarily, the implementation of the determination module 501 will be described below using the determination module 501 as an example. Similarly, the implementation of the recycling module 502 and reuse module 503 can also refer to the implementation of the determination module 501.
[0066] As an example of a software functional unit, the module 501 can be determined to include code running on a computing instance. The computing instance can include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance can be one or more. For example, the module 501 can be determined to include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code can be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code can be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Generally, a region can include multiple AZs.
[0067] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0068] As an example of a hardware functional unit, the determination module 501 may include at least one computing device, such as a server. Alternatively, the determination module 501 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0069] The multiple computing devices included in the determination module 501 can be distributed in the same region or in different regions. The multiple computing devices included in the determination module 501 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the determination module 501 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0070] It should be noted that, in other embodiments, determination module 501 can be used to execute any step in the index bloat suppression method described in the above embodiments, recovery module 502 can also be used to execute any step in the index bloat suppression method described in the above embodiments, and reuse module 503 can also be used to execute any step in the index bloat suppression method described in the above embodiments. The steps implemented by determination module 501, recovery module 502, and reuse module 503 can be specified as needed. By having determination module 501, recovery module 502, and reuse module 503 respectively implement different steps in the index bloat suppression method described in the above embodiments, the full functionality of index bloat suppression device 500 shown in FIG. 5 is achieved.
[0071] This application also provides a computing device 600. As shown in Figure 6, computing device 600 includes a bus 602, a processor 604, a memory 606, and a communication interface 608. Processor 604, memory 606, and communication interface 608 communicate with each other via bus 602. Computing device 600 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 600.
[0072] Bus 602 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG6 shows a single bus line, but this does not imply a single bus or type of bus. Bus 604 may include a path for transmitting information between various components of computing device 600 (e.g., memory 606, processor 604, and communication interface 608).
[0073] The processor 604 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0074] The memory 606 may include volatile memory, such as random access memory (RAM). The processor 1004 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0075] Memory 606 stores executable program code. Processor 604 executes this executable program code to implement the functions of determination module 501, recycling module 502, and reuse module 503 shown in FIG5 , thereby implementing the index bloat suppression method described in the above embodiment. Specifically, memory 606 stores instructions for executing the index bloat suppression method described in the above embodiment.
[0076] Alternatively, the memory 606 stores executable code, and the processor 604 executes the executable code to implement the functions of the index bloat suppression device 500 shown in FIG. 5 , thereby implementing the index bloat suppression method described in the above embodiment. That is, the memory 606 stores instructions for executing the index bloat suppression method described in the above embodiment.
[0077] The communication interface 603 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 600 and other devices or a communication network.
[0078] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0079] As shown in Figure 7, the computing device cluster includes at least one computing device 600. The memory 606 in one or more computing devices 600 in the computing device cluster may store the same instructions for executing the index expansion suppression method described in the above embodiment.
[0080] In some possible implementations, the memory 606 of one or more computing devices 600 in the computing device cluster may also store some instructions for executing the index bloat suppression method described in the above embodiment. In other words, the combination of one or more computing devices 600 can jointly execute the instructions for executing the index bloat suppression method described in the above embodiment.
[0081] It should be noted that the memory 606 in different computing devices 600 in the computing device cluster can store different instructions, each for executing a portion of the functions of the index expansion suppression device 500 shown in FIG5 . In other words, the instructions stored in the memory 606 in different computing devices 600 can implement the functions of one or more of the determination module 501, the recycling module 502, and the reuse module 503.
[0082] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network (WAN) or a local area network (LAN), etc. FIG8 illustrates a possible implementation. As shown in FIG8 , two computing devices 600A and 600B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 606 in the computing device 600A stores instructions for executing the functions of the determination module 501. Simultaneously, the memory 606 in the computing device 600B stores instructions for executing the functions of the recovery module 502 and the reuse module 503.
[0083] It should be understood that the functionality of the computing device 600A shown in FIG8 may also be implemented by multiple computing devices 600. Similarly, the functionality of the computing device 600B may also be implemented by multiple computing devices 600.
[0084] The present application also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similar to the connection method of the computing device cluster described in Figures 7 and 8. However, the memory 606 in one or more computing devices 600 in this computing device cluster can store the same instructions for executing the method described in the above embodiment.
[0085] In some possible implementations, the memory 606 of one or more computing devices 600 in the computing device cluster may also store some instructions for executing the aforementioned index bloat suppression method. In other words, the combination of one or more computing devices 600 can jointly execute the instructions for executing the aforementioned index bloat suppression method.
[0086] Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is run on a computing device cluster including at least one computing device, the computing device cluster executes the method described in the above embodiment. Exemplarily, the computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state drive), etc.
[0087] Based on the method in the above embodiment, an embodiment of the present application provides a computer program product containing instructions. When the computer program product is run on a computing device cluster including at least one computing device, the computing device cluster executes the method in the above embodiment.
[0088] It is understood that the processor in the embodiments of the present application may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0089] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0090] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted via the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)).
[0091] It will be understood that the various numerical numbers involved in the embodiments of the present application are merely distinctions for the convenience of description and are not intended to limit the scope of the embodiments of the present application.
[0092] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for suppressing index expansion, characterized in that: include: Determine if index bloat occurs; Identify recyclable pages included in the index, and sequentially add each of the recyclable pages to a page recycling queue, wherein the recyclable pages include: sparse pages or empty pages; In the case where the index requires a new page, the pages contained in the page recycling queue are reused in sequence.
2. The method according to claim 1, characterized in that The determining that the index is expanded includes: Obtaining a first size of a key inserted by an insert operation in the index, a second size of a key deleted by a delete operation in the index, and a third size of an extended page generated by a split in the index; It is determined that expansion occurs in the index based on the first size, the second size, the third size, and an expansion size included in statistical information in a database.
3. The method according to claim 2, characterized in that The determining that the index is expanded based on the first size, the second size, the third size, and the expansion size included in the statistical information in the database includes: Determine an expansion space size of the index based on the first size, the second size, the third size, and the expansion size; Determining an expansion rate of the index based on the expansion space size of the index, the total number of pages of the index, and the size of each page of the index; When the expansion space of the index is larger than a preset space size and the expansion rate of the index is larger than a preset ratio threshold, it is determined that the index expands.
4. The method according to claim 3, characterized in that Also includes: The size of the expansion space for persisting the index.
5. The method according to any one of claims 1 to 4, characterized in that: Add any reclaimable page to the page recycling queue, including: When the commit / modify timestamp of the latest transaction on any recyclable page is greater than the maximum commit / modify timestamp in the metadata of the index, updating the maximum commit / modify timestamp to the commit / modify timestamp of the latest transaction; Adding a recycling timestamp to any of the recyclable pages, and updating the reuse timestamp in the metadata to the recycling timestamp; Adding any one of the reclaimable pages to the page reclaim queue.
6. The method according to claim 5, characterized in that Reusing any page contained in the page recycling queue includes: The arbitrary page is reused, and the reuse timestamp in the metadata is updated to the recycling timestamp of the arbitrary page.
7. The method according to claim 5 or 6, characterized in that: Also includes: Accessing / modifying the index is allowed if the time for accessing / modifying the index is greater than or equal to the maximum commit timestamp, and the time for accessing / modifying a page in the index is greater than or equal to the recycle time.
8. An index expansion suppression device, characterized in that: include: A determination module, used to determine if an index has expanded; A recycling module, used for identifying recyclable pages included in the index, and sequentially adding each of the recyclable pages to a page recycling queue, wherein the recyclable pages include: sparse pages or empty pages; The multiplexing module is used to reuse the pages contained in the page recycling queue in sequence when the index needs a new page.
9. The device according to claim 8, characterized in that When determining that the index is expanded, the determining module is specifically used to: Obtaining a first size of a key inserted by an insert operation in the index, a second size of a key deleted by a delete operation in the index, and a third size of an extended page generated by a split in the index; It is determined that expansion occurs in the index based on the first size, the second size, the third size, and an expansion size included in statistical information in a database.
10. The device according to claim 9, characterized in that When the determination module determines that the index is expanded based on the first size, the second size, the third size, and the expansion size included in the statistical information in the database, the determination module is specifically configured to: Determine an expansion space size of the index based on the first size, the second size, the third size, and the expansion size; Determining an expansion rate of the index based on the expansion space size of the index, the total number of pages of the index, and the size of each page of the index; When the expansion space of the index is larger than a preset space size and the expansion rate of the index is larger than a preset ratio threshold, it is determined that the index expands.
11. The device according to claim 10, characterized in that The determining module is further used for: The size of the expansion space for persisting the index.
12. The device according to any one of claims 8 to 11, characterized in that: When adding any recyclable page to the page recycling queue, the recycling module is specifically used to: When the commit / modify timestamp of the latest transaction on any recyclable page is greater than the maximum commit / modify timestamp in the metadata of the index, updating the maximum commit / modify timestamp to the commit / modify timestamp of the latest transaction; Adding a recycling timestamp to any of the recyclable pages, and updating the reuse timestamp in the metadata to the recycling timestamp; Adding any one of the reclaimable pages to the page reclaim queue.
13. The device according to claim 12, characterized in that When the multiplexing module multiplexes any page contained in the page recycling queue, it is specifically used to: The arbitrary page is reused, and the reuse timestamp in the metadata is updated to the recycling timestamp of the arbitrary page.
14. The device according to claim 12 or 13, characterized in that The multiplexing module is also used for: Accessing / modifying the index is allowed if the time for accessing / modifying the index is greater than or equal to the maximum commit timestamp, and the time for accessing / modifying a page in the index is greater than or equal to the recycle time.
15. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1-7.
16. A computer-readable storage medium storing a computer program, which, when executed on a computing device cluster comprising at least one computing device, enables the computing device cluster to execute the method according to any one of claims 1 to 7.
17. A computer program product, characterized in that When the computer program product is run on a computing device cluster including at least one computing device, the computing device cluster is enabled to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Index expansion suppression method and device and computing device cluster
CN120123332A
Memory multiplexing method and device in audio recording equipment, equipment and medium
CN112882682A
Data processing method and device, electronic equipment and computer readable storage medium
CN114328526A
Data retrieval establishment processing method and device and server
CN114547044A
Memory management method and related device
CN116541156A