Index expansion suppression method and device and computing device cluster
By identifying and multiplexing the recyclable pages in the index, the problem of timely perception and suppression of index inflation in the prior art is solved, real-time perception and effective suppression of index inflation are achieved, and database performance and storage resource utilization are improved.
Patent Information
- Application Number
- CN202311690375.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-08
- Publication Date
- 2025-06-10
AI Technical Summary
The existing technology is difficult to perceive and suppress index inflation problems in a timely manner, resulting in degradation of database performance and waste of storage resources.
By determining index bloat, recyclable pages are identified and added to the page recycling queue, and multiplexed those pages when needed to reduce the storage space occupied by the index.
Real-time perception and effective suppression of index bloat is achieved, avoiding waste of storage resources and improving database performance.
Smart Images

Figure CN120123332A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information technology (IT), and particularly to a method and apparatus for suppressing index bloat, and a computing device cluster. Background Art
[0002] An index is a key component for accelerating database query operations. However, over time, the index may experience bloat problems, resulting in performance degradation and waste of storage resources. For example, in cases where there is index skew in the business, or disordered writes and deletes are performed on the index, or mark deletion is used for the index and the space is not recycled and reused in a timely manner after deletion, etc., it will cause the index to occupy much more storage space than the space required for storing its data volume, thereby causing a large amount of storage space waste in the database and resulting in index bloat problems. In order to maintain the stability of the database, it is often necessary to suppress index bloat. However, there is often a situation where index bloat cannot be detected in a timely manner, resulting in the problem of continuous index bloat. Summary of the Invention
[0003] This application provides a method and apparatus for suppressing index bloat, a computing device cluster, a computer storage medium, and a computer product, which can effectively suppress index bloat.
[0004] In a first aspect, this application provides a method for suppressing index bloat, including: determining that the index has bloat; identifying recyclable pages included in the index, and successively adding each recyclable page to a page recycling queue, where the recyclable pages include: sparse pages or empty pages; and when the index requires a new page, successively reusing the pages included in the page recycling queue. In this way, when the index has bloat, the recyclable pages in the index are successively added to the page recycling queue, and the pages in the page recycling queue are successively reused, thereby realizing the suppression of index bloat.
[0005] In some embodiments, determining that the index has bloat includes: obtaining a first size of keys inserted by performing an insert operation in the index, a second size of keys deleted by performing a delete operation in the index, and a third size of extended pages generated by splitting in the index; and determining that the index has bloat based on the first size, the second size, the third size, and the bloat size included in the statistical information in the database. In this way, it no longer relies solely on statistical information as the only source of bloat information perception, but instead increases the bloat perception ability during the index insertion and deletion processes. The index bloat perception comes from the integration of insertion, deletion, and statistical information, ensuring real-time perception while solving the problem of untimely bloat perception of statistical information.
[0006] In some embodiments, determining that an index is inflated based on a first size, a second size, a third size, and an inflation size included in statistical information in a database includes: determining an inflation space size of the index based on the first size, the second size, the third size, and the inflation size; determining an inflation rate of the index based on the inflation space size of the index, the total number of pages of the index, and the page size of each page of the index; and determining that the index is inflated when the inflation space of the index is greater than a preset space size and the inflation rate of the index is greater than a preset ratio threshold. In this way, it is determined whether the index is inflated by the inflation space size and the inflation rate of the index.
[0007] In some embodiments, it further includes: persisting the inflation space size of the index. In this way, it is possible to prevent the loss of inflation information in the case of abnormal restart or the like, resulting in inaccurate inflation perception.
[0008] In some embodiments, adding any recyclable page to a page recycling queue includes: when the commit / modification timestamp of the latest transaction on any recyclable page is greater than the maximum commit / modification timestamp in the metadata of the index, updating the maximum commit / modification timestamp to the commit / modification timestamp of the latest transaction; adding a recycling timestamp to any recyclable page, and updating the reuse timestamp in the metadata to the recycling timestamp; and adding any recyclable page to the page recycling queue. In this way, the recycling of pages in the index is achieved through two timestamps in the metadata.
[0009] 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 any page. In this way, the reuse of pages is achieved.
[0010] In some embodiments, it further includes: allowing access to / modification of the index when 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 recycling time. This ensures that index inflation suppression and concurrent business access to / modification of the index do not interfere with or block each other.
[0011] In a second aspect, the present application provides an index inflation suppression device, including: a determination module for determining that an index is inflated; a recycling module for identifying recyclable pages included in the index and sequentially adding each recyclable page to a page recycling queue, where the recyclable pages include: sparse pages or empty pages; and a reuse module for sequentially reusing the pages included in the page recycling queue when the index requires new pages.
[0012] In some embodiments, when determining that the index is inflated, the determination module is specifically configured to: obtain a first size of the key inserted by the insert operation performed on the index, a second size of the key deleted by the delete operation performed on the index, and a third size of the extended page generated by splitting in the index; determine that the index is inflated based on the first size, the second size, the third size, and the inflation size included in the statistical information in the database.
[0013] In some embodiments, when determining that the index is inflated based on the first size, the second size, the third size, and the inflation size included in the statistical information in the database, the determination module is specifically configured to: determine the inflation space size of the index based on the first size, the second size, the third size, and the inflation size; determine the inflation rate of the index based on the inflation space size of the index, the total number of pages of the index, and the page size of the index; determine that the index is inflated when the inflation space of the index is greater than the preset space size and the inflation rate of the index is greater than the preset ratio threshold.
[0014] In some embodiments, the determination module is further configured to: persist the inflation space size of the index.
[0015] In some embodiments, when adding any recyclable page to the page recycling queue, the recycling module is specifically configured to: update the maximum commit / modification timestamp to the commit / modification timestamp of the latest transaction when the commit / modification timestamp of the latest transaction on any recyclable page is greater than the maximum commit / modification timestamp in the metadata of the index; add a recycling timestamp to any recyclable page, and update the reuse timestamp in the metadata to the recycling timestamp; add any recyclable page to the page recycling queue.
[0016] In some embodiments, when reusing any page included in the page recycling queue, the reuse module is specifically configured to: reuse any page, and update the reuse timestamp in the metadata to the recycling timestamp of any page.
[0017] In some embodiments, the reuse module is further configured to: allow accessing / modifying the index when the time for accessing / modifying the index is greater than or equal to the maximum commit timestamp and the time for accessing / modifying the page in the index is greater than or equal to the recycling time.
[0018] In a third aspect, the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processors of at least one computing device are configured to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method described in the first aspect or any possible implementation manner of the first aspect.
[0019] Fourthly, the present application provides a computer-readable storage medium, including computer program instructions. When the computer program instructions are executed by a cluster of computing devices, the cluster of computing devices executes the method described in the first aspect or any possible implementation manner of the first aspect. Among them, the cluster of computing devices may include one or more computing devices.
[0020] Fifthly, the present application provides a computer program product containing instructions. When the instructions are run by a cluster of computing devices, the cluster of computing devices is caused to execute the method described in the first aspect or any possible implementation manner of the first aspect. Among them, the cluster of computing devices may include one or more computing devices.
[0021] It can be understood that the beneficial effects of the above second aspect to fifth aspect can be referred to the relevant descriptions in the first aspect, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a schematic diagram of the logical architecture of a database management system provided by an embodiment of the present application;
[0023] Figure 2 is a schematic flowchart of a method for suppressing index inflation provided by an embodiment of the present application;
[0024] Figure 3 is a schematic diagram of steps for adding recyclable pages to a page recycling queue provided by an embodiment of the present application;
[0025] Figure 4 is a schematic diagram of the process of page recycling and reuse provided by an embodiment of the present application;
[0026] Figure 5 is a schematic diagram of the structure of a device for suppressing index inflation provided by an embodiment of the present application;
[0027] Figure 6 is a schematic diagram of the structure of a computing device provided by an embodiment of the present application;
[0028] Figure 7 is a schematic diagram of the structure of a cluster of computing devices provided by an embodiment of the present application;
[0029] Figure 8 is a schematic diagram of the structure of another cluster of computing devices provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] As used herein, the term "and / or" describes the relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent three cases: A exists alone, A and B exist simultaneously, and B exists alone. The symbol " / " in this text indicates that the associated objects are in an "or" relationship. For example, A / B means A or B.
[0031] The terms "first", "second", etc. in the description and claims of this application are used to distinguish different objects, rather than to describe a specific order of the objects. For example, the first response message and the second response message are used to distinguish different response messages, rather than to describe the specific order of the response messages.
[0032] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0033] In the description of the embodiments of this application, unless otherwise specified, the meaning of "a plurality of" refers to two or more. For example, a plurality of processing units refers to two or more processing units, and a plurality of elements refers to two or more elements.
[0034] First, the relevant technical terms involved in the embodiments of this application are introduced.
[0035] (1) Index expansion
[0036] Index expansion refers to the gradual increase of the index structure over time, resulting in the storage space occupied by the index becoming larger than the actual data stored. Index expansion is usually due to frequent data deletion and update operations, but index maintenance operations (such as rebuilding the index, cleaning up fragmentation) are not executed in a timely manner, resulting in the index structure becoming less compact and having a large amount of invalid or redundant data that has not been cleaned up.
[0037] (2) Expansion suppression
[0038] Expansion suppression refers to taking measures or performing operations (such as reclaiming and reusing the free space of the index) to limit or slow down the expansion process of the index structure, so that the storage space occupied by the index is close to the space required for the index to actually store the data.
[0039] Next, the technical solutions provided by the embodiments of this application are introduced.
[0040] Exemplarily, Figure 1 is a schematic diagram of the logical architecture of a database management system provided by the embodiments of this application. AsFigure 1 As shown, the database management system may include: a client 100 and a database 200. The database 200 may include: an execution engine 210 and a storage engine 220. The client 100 refers to various forms of connecting to the database, such as the activeX data objects (ADO) connection used in.Net, the Java database connect (JDBC) connection used in Java, etc.
[0041] The execution engine 210 is mainly responsible for generating an efficient execution plan for the structured query language (SQL) statements input by the client 110 under the current load scenario, and running the execution plan. In addition, during the process of accessing and modifying the indexes in the storage engine 220, the execution engine 210 can also count the index inflation situation, and / or persist the counted index inflation situation 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, and for handling business logic such as connection authentication, connection count judgment, and connection pool processing. The main function of the query cache 212 is to improve the query efficiency. The cache is stored in the form of a hash table of key and value. The key is the specific SQL statement, and the value is the set of results. When an SQL statement arrives, if the query cache function is enabled, the execution engine 210 can first check the query cache 212 to see if there is a data match. If there is a match, the matched data will be directly returned to the client 110 without having to parse the corresponding SQL statement again. However, if there are user-defined functions, stored functions, user variables, or temporary tables, etc. in the SQL statement, it will not pass through the query cache 212. If no match is found 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 grammar rules, etc., and generating an internal 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, after the optimizer 214 finds the optimal execution plan, calling the interface of the storage engine 220 to execute the query or other operations, and finally returning the query result set to the client 110.
[0042] The storage engine 220 is mainly responsible for data storage, retrieval, and management, and defines important features such as how the database management system organizes data, how to execute queries and transactions, and data security and reliability. In addition, the storage engine 220 can also be responsible for storing indexes or the size of the inflated space of the indexes, etc.
[0043] Exemplarily, Figure 2 FIG. shows a schematic flow chart of an index inflation suppression method provided by an embodiment of the present application. It can be understood that this method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities. As Figure 2 shown, the index inflation suppression method may include the following steps:
[0044] S201. Determine that the index is inflated, and add the index to the queue for inflation suppression.
[0045] In this embodiment, the statistics in the database associated with the index can be used to determine whether the index is inflated. Among them, the inflated size of the index obtained by statistics is included in the statistics. When the inflated size of the index in the statistics is greater than the preset size threshold, it can be determined that the index is inflated. In addition, in order to improve the accuracy of the judgment, the inflation rate of the index can also be introduced when making the judgment. When the inflated size of the index is greater than the preset size threshold and the inflation rate of the index exceeds the preset inflation rate threshold, it can be determined that the index is inflated. Among them, the inflation rate of the index can be determined by the inflated size of the index, the total number of pages of the index, and the size of each page of the index. Specifically, the inflation rate expand_ration = expand_size ÷ (real_total_pages × page_size), where expand_size is the inflated size of the index, real_total_pages is the total number of pages of the index, and page_size is the size of each page of the index. After determining that the index is inflated, the index can be added to the queue for inflation suppression. Exemplarily, the queue for inflation suppression may include the identifiers of each inflated index. Exemplarily, the index can be but is not limited to Btree / B+tree.
[0046] As a possible implementation, in order to achieve real-time perception of index expansion, when performing an insertion operation on an index, the first size of the inserted key can be obtained. Also, when performing a deletion operation on the index, the second size of the deleted key can be obtained, and the third size of the extended page generated by splitting in the index can be obtained. Then, based on the first size, the second size, the third size, and the expansion size of the index in the statistical information, it is determined whether the index expands. Among them, an expansion size can be determined first from the first size, the second size, and the third size. Exemplarily, the expansion 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. Then, this expansion size is compared with the expansion size in the statistical information, and the largest of them is selected as the expansion space size of the index. When this expansion space size is greater than a preset size threshold, it is determined that the index expands. Additionally, when making the determination, the expansion rate of the index can also be introduced. At this time, the expansion rate of the index is determined by the expansion space size of the index, the total number of pages of the index, and the size of each page of the index.
[0047] Further, after determining the expansion space size of the index, the expansion space size can be persisted to prevent the loss of expansion information in cases such as abnormal restart, resulting in inaccurate expansion perception.
[0048] S202. Identify at least one recyclable page included in the index in the queue to be suppressed from expansion, and sequentially add each recyclable page to the page recycling queue, where the recyclable page includes: a sparse page or an empty page.
[0049] In this embodiment, the recyclable pages included in the index in the queue to be suppressed from expansion can be identified sequentially. When identifying, all pages in the index can be traversed. After identifying a recyclable page, the identified recyclable page in the index can be sequentially added to the page recycling queue. Among them, the recyclable page includes a sparse page or an empty page. A sparse page refers to a page where the space occupied by data on the page is less than a preset space threshold. In some embodiments, adding any recyclable page to the page recycling queue may include the following steps: S301. When the commit / modification timestamp of the latest transaction on any recyclable page is greater than the maximum commit / modification timestamp in the metadata of the index, update the maximum commit / modification timestamp in the metadata to the commit / modification timestamp of the latest transaction. S302. Add a recycling timestamp to the any recyclable page, and update the reuse timestamp in the metadata to the recycling timestamp. S303. Add the any recyclable page to the page recycling queue. For ease of understanding, an example is given below for explanation. Please refer to Figure 4 , such as Figure 4As shown in (A) of, the index a has expanded. The recyclable pages within it are page 1, page 3, and page 4. The commit time of the latest transaction in page 1 is T1, the commit time of the latest transaction in page 3 is T2, and the commit time of the latest transaction in page 4 is T3, and T2 < T1 < T3. Additionally, in Figure 4 In (A) of, the maximum commit timestamp (Max_commit_time) in the metadata area of index a is the initial value, and the reused timestamp (Reused_time) is also the initial value. When traversing the recyclable pages in index a, page 1 is recognized first, and at this time, this page can be recycled. When recycling, as Figure 4 shown in (B) of, update Max_commit_time in the metadata area of index a to T1, update Reused_time to the recycle timestamp t1 of page 1, and add t1 to page 1 and add page 1 to the page recycle queue. In this way, the recycling of page 1 is completed. When traversing to page 2, it is recognized that this page is not a recyclable page, and then page 3 is recognized. It is recognized that page 3 is a recyclable page and page 3 is recycled. When recycling, as Figure 4 shown in (C) of, since T2 < T1, the Max_commit_time in the metadata area can remain unchanged. At the same time, Reused_time can be updated to the recycle timestamp t2 of page 3, and add t2 to page 3 and add page 3 to the page recycle queue. In this way, the recycling of page 3 is completed. When traversing to page 4, it is recognized that this page is a recyclable page and page 4 is recycled. When recycling, as Figure 4 shown in (D) of, since T1 < T3, update T1 in Max_commit_time in the metadata area to T3, at the same time update Reused_time to the recycle timestamp t3 of page 4, and add t3 to page 4 and add page 4 to the page recycle queue. In this way, the recycling of page 4 is completed. In some embodiments, when the time for accessing / modifying the index is greater than or equal to the maximum commit timestamp, and the time for accessing / modifying the page in the index is greater than or equal to the recycle time, accessing / modifying the index is allowed, thereby ensuring that index expansion inhibition and concurrent business access and modification of the index do not interfere with each other or cause blocking.
[0050] S203. When a new page is required in the index, the pages included in the page recycle queue are reused in sequence.
[0051] In this embodiment, when a new page is needed in the index, the pages included in the page recycle queue can be reused in sequence, so that it is not necessary to wait for a long transaction or a long query to end, and avoiding the expansion caused by applying for new space. Exemplarily, when reusing any page included in the page recycle queue, after reusing the page, the reused timestamp in the metadata can be updated to the recycle timestamp of the reused page. For example, continue to refer to Figure 4 , asFigure 4 As shown in (E), when page 4 is reused, since Reused_time in the metadata area is the recycle timestamp t3 of page 4, it is not necessary to process Reused_time. For example, Figure 4 As shown in (F), when page 3 is reused, t3 in Reused_time in the metadata area can be updated to the recycle timestamp t2 of page 3. For example, Figure 4 As shown in (G), when page 1 is reused, t2 in Reused_time in the metadata area can be updated to the recycle timestamp t1 of page 1.
[0052] In this way, when index expansion occurs, the recyclable pages in the index are successively added to the page recycle queue, and the pages in the page recycle queue are successively reused, thus realizing the suppression of index expansion.
[0053] It can be understood that in Figure 2 , it is also possible to identify the recyclable pages in an index every time an index expansion is determined, or the indexes with expansion can be first added to the queue for expansion suppression, and then the recyclable pages in the indexes in the queue for expansion suppression are successively identified. It can be determined according to the actual situation and is not limited here. In addition, Figure 2 in
[0054] the different steps can be but are not limited to being executed by different threads, thereby improving the efficiency of index expansion perception and suppression.
[0055] Based on the method in the above embodiments, an index expansion suppression device is provided in an embodiment of the present application.
[0056] Exemplarily, Figure 5 shows a schematic structural diagram of an index expansion suppression device provided in an embodiment of the present application. As Figure 5 shown, the index expansion suppression device 500 includes: a determination module 501, a recycle module 502, and a reuse module 503. Among them, the determination module 501 is used to determine that index expansion occurs. The recycle module 502 is used to identify the recyclable pages included in the index, and successively add each recyclable page to the page recycle queue. The recyclable pages include: sparse pages or empty pages. The reuse module 503 is used to successively reuse the pages included in the page recycle queue when the index needs new pages.
[0057] In some embodiments, when determining that the index is inflated, the determining module 501 is specifically configured to: obtain a first size of the key inserted by performing an insert operation in the index, a second size of the key deleted by performing a delete operation in the index, and a third size of the extended page generated by splitting in the index; determine that the index is inflated based on the first size, the second size, the third size, and the inflation size included in the statistical information in the database.
[0058] In some embodiments, when determining that the index is inflated based on the first size, the second size, the third size, and the inflation size included in the statistical information in the database, the determining module 501 is specifically configured to: determine the inflation space size of the index based on the first size, the second size, the third size, and the inflation size; determine the inflation rate of the index based on the inflation space size of the index, the total number of pages of the index, and the size of each page of the index; determine that the index is inflated when the inflation space of the index is greater than a preset space size and the inflation rate of the index is greater than a preset ratio threshold.
[0059] In some embodiments, the determining module 501 is further configured to: persist the inflation space size of the index.
[0060] In some embodiments, when adding any recyclable page to the page recycling queue, the recycling module 502 is specifically configured to: update the maximum commit / modification timestamp to the commit / modification timestamp of the latest transaction when the commit / modification timestamp of the latest transaction on any recyclable page is greater than the maximum commit / modification timestamp in the metadata of the index; add a recycling timestamp to any recyclable page, and update the reuse timestamp in the metadata to the recycling timestamp; add any recyclable page to the page recycling queue.
[0061] In some embodiments, when reusing any page included in the page recycling queue, the reuse module 503 is specifically configured to: reuse any page, and update the reuse timestamp in the metadata to the recycling timestamp of any page.
[0062] In some embodiments, the reuse module 503 is further configured to: allow accessing / modifying the index when the time of accessing / modifying the index is greater than or equal to the maximum commit timestamp and the time of accessing / modifying the page in the index is greater than or equal to the recycling time.
[0063] In some embodiments, Figure 5 The determining module 501, the recycling module 502, and the reuse module 503 shown in can be implemented by software or by hardware. Exemplarily, taking the determining module 501 as an example, the implementation manner of the determining module 501 is introduced below. Similarly, the implementation manners of the recycling module 502 and the reuse module 503 can also refer to the implementation manner of the determining module 501.
[0064] As an example of a software functional unit, it is determined that module 501 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above computing instance may be one or more. For example, it is determined that module 501 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers for running this code may be distributed in the same region, or may be distributed in different regions. Further, the multiple hosts / virtual machines / containers for running this code may be distributed in the same availability zone (AZ), or may be distributed in different AZs, and each AZ includes one data center or multiple geographically proximate data centers. Usually, one region may include multiple AZs.
[0065] Similarly, the multiple hosts / virtual machines / containers for running this code may be distributed in the same virtual private cloud (VPC), or may be distributed in multiple VPCs. Usually, one VPC is set within one region. For cross-region communication between two VPCs within the same region and between VPCs in different regions, a communication gateway needs to be set in each VPC, and the interconnection between VPCs is realized through the communication gateway.
[0066] As an example of a hardware functional unit, it is determined that module 501 may include at least one computing device, such as a server, etc. Or, it is determined that module 501 may also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). Among them, the above PLD may be implemented by a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0067] The multiple computing devices included in the determination module 501 may be distributed in the same region or in different regions. The multiple computing devices included in the determination module 501 may be distributed in the same availability zone (AZ) or in different AZs. Similarly, the multiple computing devices included in the determination module 501 may be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Among them, the multiple computing devices may be any combination of computing devices such as servers, application-specific integrated circuits (ASICs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), and generic array logic (GALs).
[0068] It should be noted that in other embodiments, the determination module 501 may be used to execute any step in the index inflation suppression method described in the above embodiments, the recycling module 502 may also be used to execute any step in the index inflation suppression method described in the above embodiments, and the reuse module 503 may also be used to execute any step in the index inflation suppression method described in the above embodiments. The steps to be implemented by the determination module 501, the recycling module 502, and the reuse module 503 can be specified as needed, and the different steps in the index inflation suppression method described in the above embodiments are respectively implemented by the determination module 501, the recycling module 502, and the reuse module 503 to implement Figure 5 all the functions of the index inflation suppression device 500 shown.
[0069] This application also provides a computing device 600. As Figure 6 shown, the computing device 600 includes: a bus 602, a processor 604, a memory 606, and a communication interface 608. The processor 604, the memory 606, and the communication interface 608 communicate with each other through the bus 602. The computing device 600 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 600.
[0070] The bus 602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation,[[]] Figure 6 only one line is shown here, but it does not mean that there is only one bus or one type of bus. The bus 604 may include a path for transmitting information between various components of the computing device 600 (for example, the memory 606, the processor 604, and the communication interface 608).
[0071] The processor 604 may include any one or more of processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0072] 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, a hard disk drive (HDD), or a solid state drive (SSD).
[0073] The memory 606 stores executable program code, and the processor 604 executes the executable program code to respectively implement the functions of the determination module 501, the recycling module 502, and the reuse module 503 shown in the foregoing Figure 5 , thereby implementing the index expansion suppression method described in the foregoing embodiments. That is, the memory 606 stores instructions for executing the index expansion suppression method described in the foregoing embodiments.
[0074] Alternatively, the memory 606 stores executable code, and the processor 604 executes the executable code to respectively implement the functions of the index expansion suppression device 500 shown in the foregoing Figure 5 , thereby implementing the index expansion suppression method described in the foregoing embodiments. That is, the memory 606 stores instructions for executing the index expansion suppression method described in the foregoing embodiments.
[0075] 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.
[0076] The embodiments of the present application further provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device may 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 may also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0077] As Figure 7As shown, the computing device cluster includes at least one computing device 600. Instructions for executing the index expansion suppression method described in the foregoing embodiments may be stored in the memories 606 of one or more of the computing devices 600 in the computing device cluster.
[0078] In some possible implementation manners, partial instructions for executing the index expansion suppression method described in the foregoing embodiments may also be stored separately in the memories 606 of one or more of the computing devices 600 in the computing device cluster. In other words, a combination of one or more computing devices 600 may jointly execute the instructions for executing the index expansion suppression method described in the foregoing embodiments.
[0079] It should be noted that different memories 606 in different computing devices 600 in the computing device cluster may store different instructions, respectively for executing partial functions of the foregoing Figure 5 index expansion suppression apparatus 500 shown. That is, the instructions stored in the memories 606 of different computing devices 600 may implement the functions of one or more of the determination module 501, the recycling module 502, and the reuse module 503.
[0080] In some possible implementation manners, one or more computing devices in the computing device cluster may be connected through a network. Among them, the network may be a wide area network or a local area network, etc. Figure 8 A possible implementation manner is shown. As Figure 8 shown, two computing devices 600A and 600B are connected through a network. Specifically, they are connected to the network through the communication interfaces in each computing device. In this type of possible implementation manners, instructions for executing the function of the determination module 501 are stored in the memory 606 of the computing device 600A. At the same time, instructions for executing the functions of the recycling module 502 and the reuse module 503 are stored in the memory 606 of the computing device 600B.
[0081] It should be understood that Figure 8 the function of the computing device 600A shown in
[0082] may also be completed by multiple computing devices 600. Similarly, the function of the computing device 600B may also be completed by multiple computing devices 600. Figure 7 and Figure 8 the connection manner of the computing device cluster. The difference is that instructions for executing the method in the foregoing embodiments may be stored in the memories 606 of one or more of the computing devices 600 in this computing device cluster.
[0083] 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 foregoing index expansion suppression method respectively. In other words, the combination of one or more computing devices 600 may jointly execute the instructions for executing the foregoing index expansion suppression method.
[0084] Based on the method in the foregoing embodiments, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program runs on a computing device cluster including at least one computing device, the computing device cluster is caused to execute the method described in the foregoing embodiments. Exemplarily, the computer-readable storage medium may be any available medium that can be stored by the computing device or a data storage device such as a data center including one or more available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state drive), etc.
[0085] Based on the method in the foregoing embodiments, an embodiment of the present application provides a computer program product including instructions. When the computer program product runs on a computing device cluster including at least one computing device, the computing device cluster is caused to execute the method in the foregoing embodiments.
[0086] It can be understood that the processor in the embodiments of the present application may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), 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.
[0087] The method steps in the embodiments of the present application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory (RAM), flash memory, read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically EPROM (EEPROM), registers, hard disks, removable hard disks, CD-ROMs, or any other form of storage medium well-known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to 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.
[0088] 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 processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted through 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 in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0089] It can be understood that the various numerical numbers involved in the embodiments of the present application are only for convenience of description and are not used to limit the scope of the embodiments of the present application.
[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. An index expansion suppression method, characterized in that, it includes: Determine that the index has expanded; Identify the recyclable pages included in the index, and sequentially add each of the recyclable pages to the page recycling queue, where the recyclable pages include: sparse pages or empty pages; When the index requires new pages, sequentially reuse the pages included in the page recycling queue.
2. The method according to claim 1, characterized in that, The determination that the index has expanded includes: Obtain the first size of the key inserted during the insert operation in the index, the second size of the key deleted during the delete operation in the index, and the third size of the extended page generated by splitting in the index; Based on the first size, the second size, the third size and the expansion size included in the statistical information in the database, determine that the index has expanded.
3. The method according to claim 2, characterized in that, The determination that the index has 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: Based on the first size, the second size, the third size and the expansion size, determine the expansion space size of the index; Based on the expansion space size of the index, the total number of pages of the index and the page size of the index, determine the expansion rate 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.
4. The method according to claim 3, characterized in that, It further includes: Persist the expansion space size of the index.
5. The method according to any one of claims 1-4, characterized in that, Adding any one recyclable page to the page recycling queue includes: When the commit / modification timestamp of the latest transaction on the any one recyclable page is greater than the maximum commit / modification timestamp in the metadata of the index, update the maximum commit / modification timestamp to the commit / modification timestamp of the latest transaction; Add a recycling timestamp to the any one recyclable page, and update the reuse timestamp in the metadata to the recycling timestamp; Add the any one recyclable page to the page recycling queue.
6. The method according to claim 5, characterized in that, Reusing any one page included in the page recycling queue includes: Reusing the any one page, and updating the reuse timestamp in the metadata to the recycling timestamp of the any one page.
7. The method according to claim 5 or 6, characterized in that, It further includes: When the time of accessing / modifying the index is greater than or equal to the maximum commit timestamp, and the time of accessing / modifying the page in the index is greater than or equal to the recycling time, allow accessing / modifying the index.
8. An index expansion suppression device, characterized in that, it includes: A determination module for determining that the index has expanded; A recycling module, configured to identify recyclable pages included in the index, and sequentially add each of the recyclable pages to a page recycling queue, where the recyclable pages include: sparse pages or empty pages; A reuse module, configured to sequentially reuse pages included in the page recycling queue when a new page is required for the index.
9. The apparatus according to claim 8, wherein, when determining that the index is inflated, the determining module is specifically configured to: obtain a first size of keys (keys) inserted by performing an insert operation in the index, a second size of keys deleted by performing a delete operation in the index, and a third size of extended pages generated by splitting in the index; determine that the index is inflated based on the first size, the second size, the third size, and an inflation size included in statistical information in the database.
10. The apparatus according to claim 9, wherein, when determining that the index is inflated based on the first size, the second size, the third size, and an inflation size included in statistical information in the database, the determining module is specifically configured to: determine an inflation space size of the index based on the first size, the second size, the third size, and the inflation size; determine an inflation rate of the index based on the inflation space size of the index, the total number of pages of the index, and the page size of the index; determine that the index is inflated when the inflation space of the index is greater than a preset space size and the inflation rate of the index is greater than a preset ratio threshold.
11. The apparatus according to claim 10, wherein, the determining module is further configured to: persist the inflation space size of the index.
12. The apparatus according to any one of claims 8-11, wherein, when adding any recyclable page to the page recycling queue, the recycling module is specifically configured to: update the maximum commit / modification timestamp to the commit / modification timestamp of the latest transaction when the commit / modification timestamp of the latest transaction on the any recyclable page is greater than the maximum commit / modification timestamp in the metadata of the index; add a recycling timestamp to the any recyclable page, and update the reuse timestamp in the metadata to the recycling timestamp; add the any recyclable page to the page recycling queue.
13. The apparatus according to claim 12, wherein, when reusing any page included in the page recycling queue, the reuse 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.
14. The apparatus according to claim 12 or 13, wherein, the reuse module is further configured to: allow access to / modification of the index when 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 recycling time.
15. A computing device cluster, wherein, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is configured 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 running on a computing device cluster including at least one computing device, causes the computing device cluster to execute the method according to any one of claims 1-7.
17. A computer program product characterized in that when the computer program product runs on a computing device cluster including at least one computing device, it causes the computing device cluster to execute the method according to any one of claims 1-7.
Citation Information
Cited By
Index bloat suppression method and apparatus, and computing device cluster
EP4814738A1
Index bloat suppression method and apparatus, and computing device cluster
WO2025118716A1