Index updating method and device

By obtaining and analyzing query operation data in real time and generating new indexes based on the index evaluation model, the problem of difficult index management in the existing technology is solved, dynamic optimization of indexes and reduction of resource overhead, and the query performance and database management efficiency are improved.

CN119961266APending Publication Date: 2025-05-09LENOVO (BEIJING) LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510100395.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

In the prior art, index management usually adopts static design or relies on manual adjustment, making it difficult to adapt to dynamically changing query patterns and data distribution, resulting in reduced query efficiency and system performance bottlenecks.

Method used

It provides an index update method, which can obtain the running data of the query statement in real time, and obtain the target data in response to the running data meeting the trigger conditions, and generate new index and resource overhead prediction information based on the index evaluation model, optimize the index to reduce resource overhead.

Benefits of technology

Through technical means of dynamic monitoring and conditional triggering, we ensure the timeliness and targetedness of index adjustment, reduce the cost of index adjustment, improve query performance, reduce maintenance costs, and improve database management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119961266A_ABST
    Figure CN119961266A_ABST
Patent Text Reader

Abstract

The invention provides an index updating method. The index updating method comprises the steps of obtaining operation data when a query statement is executed in real time; in response to the operation data meeting the triggering condition, target data are obtained, and the target data comprise a query mode corresponding to the query statement and target data queried by the query statement; based on an index evaluation model, generating a first index according to the target data and querying first resource overhead prediction information of the target data through the first index in a query mode; and in response to the fact that the first resource overhead prediction information is superior to the resource overhead for executing the query statement, updating the index for the target data into the first index.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to an index updating method and device. Background Art

[0002] With the rapid development of big data technology and database applications, efficient management and query of massive data has become a key technical problem. In database management systems, index design is an important means to improve query performance. However, in the prior art, index management usually adopts static design or relies on manual adjustment, which is difficult to adapt to dynamically changing query patterns and data distribution. Even if some database optimization tools can provide index suggestions, they cannot adjust the index in real time to meet the performance requirements of high-frequency queries or complex scenarios due to their reliance on static analysis. These deficiencies can easily lead to reduced query efficiency, system performance bottlenecks, and high maintenance costs. Summary of the invention

[0003] In view of this, the present disclosure provides an index updating method, device, electronic device, medium and program product.

[0004] One aspect of the present disclosure provides an index updating method, including: acquiring running data when executing a query statement in real time; in response to the running data satisfying a trigger condition, acquiring target data, the target data including a query method corresponding to the query statement and the target data queried by the query statement; based on an index evaluation model, generating a first index according to the target data and first resource overhead prediction information for querying the target data through the first index in a query manner; in response to the first resource overhead prediction information being better than the resource overhead of executing the query statement, updating the index for the target data to the first index.

[0005] According to an embodiment of the present disclosure, the first resource overhead prediction information is better than the resource overhead of executing the query statement, including at least one of the following: the running overhead corresponding to querying the target data through the first index in a query manner is less than the running overhead corresponding to executing the query statement; the resource overhead required to create the first index is less than a preset resource overhead threshold.

[0006] According to an embodiment of the present disclosure, executing the query statement includes executing the query statement based on a preset second index.

[0007] According to an embodiment of the present disclosure, the resource overhead prediction information is superior to the resource overhead of executing the query statement, including at least one of the following: the running overhead corresponding to querying the target data through the first index in a query manner is less than the running overhead corresponding to querying the target data through the second index in a query manner; the resource overhead required to maintain the first index is less than the resource overhead required to maintain the second index.

[0008] According to an embodiment of the present disclosure, the target operation data also includes a second index, and generating a first index according to the target operation data includes: based on an index evaluation model, generating the first index according to a query method, target data, and at least a part of the second index; or, obtaining an associated index of the second index, and based on the index evaluation model, generating the first index according to a query method, target data, the second index, and at least a part of the associated index, wherein the associated index has an associated query field with the second index.

[0009] According to an embodiment of the present disclosure, generating a first index according to target operation data includes: generating at least one first index according to the target operation data; wherein, the index field corresponding to the first index is at least a part of the multiple index fields corresponding to each second index, or, the index field corresponding to the first index includes the associated index corresponding to each second index and at least a part of the multiple index fields corresponding to each second index; wherein, the associated index has an associated query field with the second index.

[0010] According to an embodiment of the present disclosure, the index updating method further includes: performing a data consistency check on the first index; updating the index for the target data to the first index includes: updating the index for the target data to the first index when the first index satisfies the data consistency.

[0011] According to an embodiment of the present disclosure, the operation data includes at least one of the following: resource usage data of running query statements, operation indicator data of running query statements, data query frequency of target data queried by the query statements, and usage frequency of the query mode corresponding to the query statements; the trigger condition includes at least one of the following:

[0012] The resource usage data is greater than or equal to the resource usage threshold; the operation index data is greater than or equal to the operation index threshold; the data query frequency is greater than or equal to the data query frequency preset value; the usage frequency is greater than or equal to the usage frequency preset value.

[0013] According to an embodiment of the present disclosure, the index update method also includes: in response to data update in a database, obtaining an index field corresponding to the updated data; in the case where there is a corresponding third index for the updated data, based on an index evaluation model, obtaining first resource overhead prediction information corresponding to the first index; based on the index evaluation model, obtaining second resource overhead prediction information corresponding to the third index; in response to the second resource overhead prediction information satisfying a preset resource condition, based on the index evaluation model, generating a fourth index and third resource overhead prediction information corresponding to the fourth index according to the third index; in response to the third resource overhead prediction information being better than the second resource overhead prediction information, updating the third index to the fourth index.

[0014] Another aspect of the present disclosure provides an index updating device, including: a first acquisition module, used to acquire in real time the running data when executing a query statement; a second acquisition module, used to acquire target data in response to the running data satisfying a trigger condition, the target data including a query method corresponding to the query statement and the target data queried by the query statement; a generation module, used to generate a first index according to the target data based on an index evaluation model and first resource cost prediction information for querying the target data through the first index in a query manner; and an update module, used to update the index for the target data to the first index in response to the first resource cost prediction information being better than the resource cost of executing the query statement.

[0015] Another aspect of the present disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0016] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.

[0017] Another aspect of the present disclosure provides a computer program product, which includes computer executable instructions, and when the instructions are executed, are used to implement the method as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0019] Figure 1 A flowchart of an index updating method according to an embodiment of the present disclosure is schematically shown;

[0020] Figure 2 The conditions for determining resource overhead in the index updating method according to the embodiment of the present disclosure are schematically shown;

[0021] Figure 3 A flowchart of another index updating method according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 4 Schematically shows a flow chart of updating a first index according to an embodiment of the present disclosure;

[0023] Figure 5 A flowchart of generating a first index in an index updating method according to an embodiment of the present disclosure is schematically shown;

[0024] Figure 6Another flowchart of generating a first index in an index updating method according to an embodiment of the present disclosure is schematically shown;

[0025] Figure 7 Another flow chart of the index updating method according to an embodiment of the present disclosure is schematically shown;

[0026] Figure 8 Another flow chart of the index updating method according to an embodiment of the present disclosure is schematically shown;

[0027] Fig. 9 A block diagram schematically shows an index updating device according to an embodiment of the present disclosure; and

[0028] Fig.10 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0029] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0030] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0031] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0032] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0033] An embodiment of the present disclosure provides an index updating method, including: acquiring running data when executing a query statement in real time; in response to the running data satisfying a trigger condition, acquiring target data, the target data including a query method corresponding to the query statement and the target data queried by the query statement; based on an index evaluation model, generating a first index according to the target data and first resource overhead prediction information for querying the target data through the first index in a query manner; in response to the first resource overhead prediction information being better than the resource overhead of executing the query statement, updating the index for the target data to the first index.

[0034] Figure 1 The flowchart of the index updating method according to the embodiment of the present disclosure is schematically shown.

[0035] like Figure 1 As shown, the method includes operations S110 to S140.

[0036] In operation S110, the operation data when executing the query statement is obtained in real time. The operation data refers to the performance indicators and resource usage information related to the query generated when the database executes the query statement, including but not limited to the execution time of the query statement, resource occupancy (such as CPU, memory, storage, etc.), query mode, query frequency, etc. The acquisition of the operation data can be achieved through the logging module or performance monitoring module of the database system.

[0037] Real-time acquisition refers to obtaining operation data immediately during or after the query statement is executed to ensure the timeliness and accuracy of the data. By obtaining operation data in real time, the current query load and performance status of the database can be dynamically reflected, providing a reliable basis for subsequent index adjustments.

[0038] In operation S120 , in response to the running data satisfying the trigger condition, target data is acquired, where the target data includes a query method corresponding to the query statement and target data queried by the query statement.

[0039] Trigger conditions refer to a set of conditions used to determine whether index adjustment is required, including but not limited to whether the resource usage in the running data exceeds the preset threshold, whether the execution time of the query statement exceeds expectations, etc. The setting of trigger conditions can be dynamically adjusted according to the performance requirements and query load of the database. Target data refers to key information related to the query statement, including query method and query target data. Query method refers to the structure and conditions of the query statement, such as the filtering conditions and sorting conditions used in the query. Query target data refers to the specific data set involved in the query statement, such as fields and record ranges in the table.

[0040] In response to the satisfaction of the trigger condition, the system can extract the query statement and its target data related to the trigger condition by analyzing the running data. For example, when the trigger condition detects that the execution time of a query statement is too long, the target data includes the query method and query target data of the query statement.

[0041] In operation S130, based on the index evaluation model, a first index is generated according to the target data, and first resource cost prediction information for querying the target data through the first index in a query manner is generated. The index evaluation model refers to a mathematical model or algorithm for evaluating index performance and resource cost. The model can generate a new index (first index) based on factors such as the query method, the distribution characteristics of the target data, the storage cost and maintenance cost of the index, and predict the performance and resource consumption of the first index. The first index refers to a new index generated according to the target data, and its design purpose is to optimize the performance of a specific query method. For example, if the target data involves a field, the first index can be a single field index for the field, or a composite index containing the field. The first resource cost prediction information refers to the resource consumption of the first index in the query predicted based on the index evaluation model, including but not limited to the query execution time, resource occupancy rate, etc. The first resource cost prediction information can indicate that the resource consumption of executing the query through the first index is better than the existing solution, thereby proving that the performance of the first index is better.

[0042] In operation S140, in response to the first resource overhead prediction information being better than the resource overhead for executing the query statement, the index for the target data is updated to the first index. The resource overhead for executing a query statement refers to the system resources consumed when executing the query statement, including but not limited to CPU, memory, storage, etc. The pros and cons of resource overhead can be judged by comparing indicators such as query execution time and resource occupancy rate. Index update refers to replacing the existing index in the database with the first index to optimize query performance. The index update process includes deleting the old index and creating a new index. When the first resource overhead prediction information corresponding to the created first index is better than the resource overhead for executing the query statement, it proves that the newly created first index is more suitable for the existing scenario.

[0043] According to the embodiments of the present disclosure, by acquiring operating data in real time and screening out query statements and target data that need to be optimized based on trigger conditions, dynamic monitoring and conditional triggering technical means are adopted, so that the timeliness and pertinence of index adjustment can be ensured, and unnecessary index adjustment operations can be avoided; on the other hand, by generating a first index based on an index evaluation model and predicting its resource overhead, index optimization technical means based on cost-benefit analysis are adopted, so that the cost-effectiveness of index adjustment can be ensured and query performance can be improved; in addition, by automatically updating the index and adopting the technical means of automated index adjustment, manual intervention can be reduced, and the efficiency and intelligence level of database management can be improved, thereby optimizing the overall operating efficiency of the database.

[0044] Figure 2 The conditions for determining resource overhead in the index updating method according to an embodiment of the present disclosure are schematically shown.

[0045] like Figure 2 As shown, the determination of resource overhead includes: Operation S140 may include at least one of operations S210 to S220.

[0046] Resource cost judgment refers to the process of determining whether to use the first index by comparing the resource consumption of different index schemes during query execution and index creation. Resource cost can include two types of results: static and dynamic. Static results refer to resource consumption that can be directly obtained through analysis or calculation, such as the storage space required for index creation, the cost of index maintenance, and the number of rows expected to be scanned during query; dynamic results refer to resource consumption measured by actually running queries or index creation operations, such as query execution time, disk I / O, CPU usage, etc. By combining static and dynamic results, the resource cost of the first index can be more comprehensively evaluated.

[0047] In operation S210, the operation overhead corresponding to querying the target data through the first index in a query manner is less than the operation overhead corresponding to executing the query statement. Operation overhead refers to the system resources consumed during the query execution process, including but not limited to query execution time, CPU usage, memory usage, disk I / O, etc. The operation overhead of querying the target data through the first index can be measured by actually running the query statement and recording relevant performance indicators. For example, the query execution time can be calculated by recording the timestamps of the start and end of the query, and the disk I / O can be evaluated by monitoring the number of data blocks read during the query process.

[0048] When comparing the running costs, for example, a dynamic comparison method can be used, that is, under the same query conditions, the existing index and the first index are used to execute the query respectively, and the running costs of the two are recorded. For example, if the query execution time of the existing index is 2 seconds, and the query execution time of the first index is 1 second, it can be determined that the running cost of the first index is better than that of the existing index.

[0049] For another example, static comparison can be used. Static comparison means analyzing the structure of the query statement and the distribution characteristics of the target data, combined with the design characteristics of the index, to predict the operating costs of different index schemes. For example, in a query statement, the field of the target data has a high uniqueness (such as a primary key field or a nearly unique field), then the number of rows expected to be scanned when querying through the first index may be significantly less than the existing index, so it can be statically determined that the operating cost of the first index is lower.

[0050] In some embodiments, a combination of dynamic comparison and static comparison may be used. Those skilled in the art may select a suitable comparison method according to actual conditions, which will not be elaborated here.

[0051] In operation S220, the resource overhead required to create the first index is less than the preset resource overhead threshold. The resource overhead of index creation refers to the system resources consumed when creating the first index, including but not limited to CPU usage, memory usage, disk I / O, network bandwidth, etc. Index creation usually requires scanning the entire table to extract the data of the target field and build the index structure, so the resource overhead of index creation is closely related to factors such as the size of the table and the data distribution of the target field. The preset resource overhead threshold refers to the upper limit of resource consumption used to determine whether index creation is acceptable, which can be dynamically adjusted according to the performance requirements and system load of the database. For example, the preset resource overhead threshold can be set to an index creation time of no more than 5 seconds, or a CPU occupancy rate of no more than 80% during index creation. In the scenario of dynamic index adjustment, since the index creation operation may be executed concurrently with other query operations, the resource overhead of index creation needs to be controlled within a reasonable range to avoid negatively affecting the real-time performance of the database. For example, if the index creation time is too long, it may cause the query response time to increase, thereby reducing the real-time performance of the system.

[0052] According to the embodiments of the present disclosure, because a technical means of comprehensively evaluating resource overhead is adopted by combining static analysis and dynamic comparison, the performance advantage of the first index in query execution can be accurately judged to ensure the effectiveness of index adjustment; on the other hand, through dynamic monitoring of index creation resource overhead and comparison with preset thresholds, a technical means of real-time control of index creation costs is adopted, so the negative impact of index creation on the real-time performance of the system can be avoided, thereby achieving a balance between performance and efficiency in the scenario of dynamic index adjustment.

[0053] It should be noted that Figure 2 S210 to S220 are schematically shown, but in actual situations, those skilled in the art may select one or more of them according to actual situations.

[0054] Figure 3 The flowchart of another index updating method according to an embodiment of the present disclosure is schematically shown.

[0055] like Figure 3 As shown, executing a query statement may include operation S310. Executing a query statement refers to the process in which the database system retrieves target data from the database according to the query request input by the user and the logical structure and conditions of the query statement. The efficiency and resource consumption of executing a query statement are closely related to the index used.

[0056] In operation S310, executing the query statement includes executing the query statement based on a preset second index. The second index refers to an index that already exists in the database before the first index is generated to support the execution of the query statement. The second index can be a single-field index, a composite index, or another type of index, and its design may be based on historical query patterns or the experience of the database administrator. Executing the query statement based on the second index means that during the query execution process, the database system uses the second index to accelerate the data retrieval process. For example, when the query statement contains a WHERE condition, the database system can quickly locate records that meet the condition through the second index without scanning the entire table.

[0057] In combination with the foregoing embodiments, in the scenario of dynamic index adjustment, the existence of the second index provides preliminary optimization for the execution of the query statement, but due to changes in the query pattern or data distribution, the second index may not meet the performance requirements of the current query, and therefore it is necessary to replace the second index with the first index through index update.

[0058] The second index may not meet the performance requirements of the current query, for example, the field combination of the second index is not suitable for the current query mode. For example, the second index is a single-field index for field A, and the current query statement contains filtering conditions for both field A and field B, resulting in insufficient performance of the second index.

[0059] The second index may not meet the performance requirements of the current query, for example, the maintenance cost of the second index is high. Specifically, for example, the field of the second index contains a large number of repeated values, resulting in high storage and maintenance costs of the index structure.

[0060] The second index may not meet the performance requirements of the current query, for example, the query performance of the second index is degraded. Specifically, for example, due to changes in data distribution, the query efficiency of the second index is lower than expected and cannot meet the query response time requirements.

[0061] Figure 4 The flowchart of updating the first index according to an embodiment of the present disclosure is schematically shown.

[0062] like Figure 4 As shown, operation S140 may include at least one of operations S410 to S420 and operation S430.

[0063] In operation S410, the operation overhead corresponding to querying the target data through the first index in a query manner is less than the operation overhead corresponding to querying the target data through the second index in a query manner.

[0064] For example, by means of static analysis, by analyzing the structure of the query statement, the distribution characteristics of the target data, and the design characteristics of the index, the query performance of the first index and the second index can be predicted, the running overhead corresponding to querying the target data through the first index in a query manner, and the running overhead corresponding to querying the target data through the second index in a query manner can be calculated, and the comparison results can be obtained. For example, if the field of the target data has a high uniqueness, and the first index contains the field as an index field, it can be predicted that the query performance of the first index is better than that of the second index. For example: Assume that the second index is a single-field index for field A, and the first index is a composite index for field A and field B. In the query statement, the filter condition of field A will match a large number of records, while the filter condition of field B can further narrow the range of the result set. Through static analysis, it can be concluded that the expected number of scan rows of the first index is significantly less than that of the second index, so it is judged that the running overhead of the first index is lower.

[0065] For another example, through dynamic analysis, under the same query conditions, the first index and the second index are used to execute the query respectively, and the running costs of the two can be recorded. For example, if the query execution time of the first index is 1 second, and the query execution time of the second index is 2 seconds, it can be determined that the running cost of the first index is better than that of the second index.

[0066] In operation S420, resource overhead required for maintaining the first index is less than resource overhead required for maintaining the second index.

[0067] The resource overhead of index maintenance can refer to the system resources consumed to maintain the integrity and consistency of the index structure during database operation. The resource overhead of index maintenance is closely related to factors such as the number of index fields, data distribution of the fields, and the storage structure of the index.

[0068] For example, the resource overhead of index maintenance can be the number of fields that need to be maintained. If the number of fields in the first index is less than that in the second index, the maintenance cost of the first index may be lower, because the more fields there are, the more records need to be modified when the index is updated. For example, suppose the second index is a composite index for field A, field B, and field C, while the first index is only for field A and field B. When the data is updated, the first index needs to adjust fewer fields, so its maintenance cost is lower than that of the second index.

[0069] For example, the resource overhead of index maintenance can be the data distribution corresponding to the index. If the field of the first index has high uniqueness, the storage and maintenance cost of the index structure may be lower. For example, the maintenance cost of an index for a field with high repetition values ​​may be high because each data update may involve the adjustment of a large number of repetition values. For example, suppose the second index is a single-field index for field A (with more repetition values), and the first index is a single-field index for field B (with higher uniqueness). When updating data, the maintenance cost of the first index may be significantly lower than that of the second index.

[0070] For example, the resource overhead of index maintenance may be the storage structure corresponding to the index. For example, if the first index uses a more efficient storage structure (such as a B+ tree or a hash index), its maintenance cost may be lower than that of the second index.

[0071] In operation S430 , the index for the target data is updated to the first index.

[0072] Figure 5 The flowchart of generating the first index in the index updating method according to the embodiment of the present disclosure is schematically shown.

[0073] like Figure 5 As shown, operation S130 may include at least one of operations S510 to S520.

[0074] In operation S510, based on the index evaluation model, a first index is generated according to the query method, target data, and at least part of the second index. Generating the first index refers to the process of designing and creating a new index structure to optimize query performance based on the query method, target data, and characteristics of the existing index. The generation of the first index can be based on the index evaluation model, which comprehensively considers factors such as query mode, data distribution, relevance of index fields, and storage and maintenance costs of the index to ensure that the generated first index can strike a balance between performance and resource consumption. Generating the first index based on the index evaluation model means designing a new index structure to optimize query performance by analyzing the query method, target data, and field combinations of the second index, such as field combination optimization, field order optimization, etc.

[0075] Field combination optimization: if the query method involves filtering conditions for multiple fields, and the second index only contains some fields, the first index can cover the query method by adding fields. For example, if the second index is a single-field index for field A, and the query method involves filtering conditions for field A and field B, the first index can be designed as a composite index containing field A and field B.

[0076] Field order optimization: If the field filter conditions in the query method have a specific priority, the first index can adjust the order of the fields to improve query efficiency. For example, if the filter condition of field A in the query method is more commonly used than field B, the first index can put field A before field B.

[0077] In operation S520, an associated index of the second index is obtained, and based on the index evaluation model, a first index is generated according to at least part of the query method, the target data, the second index, and the associated index, and the associated index has an associated query field with the second index. An associated index refers to an index that has an associated query field with the second index, and its field may have a certain logical relationship with the target data or the query method. For example, there is a one-to-one correspondence or a partial association relationship between the two fields, or the two fields are often used together in the same query. Obtaining an associated index means that when generating the first index, not only the fields of the second index itself are considered, but also other indexes associated with the second index are analyzed to comprehensively optimize the query performance.

[0078] For example, if field A and field B have a one-to-one correspondence (such as the "name" and "ID" fields), and the query frequency of field A exceeds the threshold to meet the trigger condition, the associated index of field B can also be included in the optimization scope, even if the query frequency of field B does not meet the trigger condition. Assume that the query frequency of the "name" field is high, which meets the trigger condition, and the second index corresponding to the "name" field needs to be updated. At the same time, the "name" field has a one-to-one correspondence with the "ID" field, and the query frequency of the "ID" field is low but still has certain usage scenarios. In this case, the associated index of the "ID" field can be included in the optimization scope to generate a first index that includes both the "name" and "ID" fields to improve the overall query performance.

[0079] For example, if the fields of the second index and the associated index are often used together in the same query, the first index can be designed to cover these fields. For example, the second index is a single-field index for field A, the associated index is a single-field index for field B, and the query method often involves both field A and field B, then the first index can be designed as a composite index containing field A and field B.

[0080] According to the embodiments of the present disclosure, by analyzing the query method, target data and field combination of the second index based on the index evaluation model and adopting technical means for single index optimization, it is possible to generate a first index that is more in line with the current query mode, thereby improving query performance; on the other hand, by obtaining the associated index of the second index and comprehensively considering the query characteristics of the associated fields, joint optimization technical means are adopted, so that the query efficiency can be further improved in complex query scenarios, and the resource consumption of multiple index scans can be reduced, thereby achieving overall performance optimization.

[0081] Figure 6 Another flowchart of generating a first index in an index updating method according to an embodiment of the present disclosure is schematically shown.

[0082] like Figure 6 As shown, operation S130 may include operation S610.

[0083] In operation S610, at least one first index is generated according to the target running data, wherein the index field corresponding to the first index is at least a part of the multiple index fields corresponding to each second index, or the index field corresponding to the first index includes the associated index corresponding to each second index and at least a part of the multiple index fields corresponding to each second index, wherein the associated index has an associated query field with the second index.

[0084] In operation S610, at least one first index is generated according to target operation data, wherein an index field corresponding to the first index is at least a part of a plurality of index fields corresponding to each second index.

[0085] Generating a first index refers to the process of designing and creating a new index structure to optimize query performance based on the target running data and the field combination of the existing index. In operation S610, the generation of the first index can be based on the segmentation or reorganization of the existing index fields to ensure that the new index can more efficiently support the current query mode. When the second index contains multiple fields, its field combination may not be completely suitable for the current query mode. For example, some fields are rarely used in queries, or the order of the fields does not meet the priority of the query conditions. In this case, a first index that is more suitable for the current query requirements can be generated by segmenting the field combination of the second index.

[0086] The process of generating the first index may include field segmentation, field priority adjustment, etc. Field segmentation: if the second index is a composite index for field A, field B, and field C, and the query method mainly involves field A and field B, a first index containing only field A and field B may be generated to reduce unnecessary field overhead and improve query efficiency. Field priority adjustment: if the filter condition of field A in the query method is more commonly used than field B, the order of the fields may be adjusted to generate a first index headed by field A to optimize query performance.

[0087] Or, in operation S610, at least one first index is generated according to the target running data, wherein the index field corresponding to the first index includes the associated index corresponding to each second index and at least part of the multiple index fields corresponding to each second index, wherein the associated index has an associated query field with the second index. An associated index refers to an index that has an associated query field with a second index, and its field may have a certain logical relationship with the target data or the query method. For example, there is a one-to-one correspondence or a partial association relationship between the two fields, or the two fields are often used jointly in the same query. In some cases, the field combination of the second index may not be sufficient to support complex queries, and the fields of the associated index can supplement the deficiencies of the second index.

[0088] For example, if the second index is a composite index for field A and field B, and the associated index is a single field index for field C, and the query method involves field A, field B, and field C, a first index containing field A, field B, and field C can be generated to cover all fields in the query method.

[0089] For example, if the fields of the second index and the associated index are often used together in the same query, the fields of the two can be combined to generate a new first index. For example, if the second index is a composite index for fields A and B, the associated index is a composite index for fields C and D, and the query method involves fields A, B, C, and D, then a first index containing fields A, B, C, and D can be generated.

[0090] According to the embodiments of the present disclosure, because the field combination of the second index is segmented and optimized and a technical means based on field reorganization is adopted, a first index that is more in line with the current query pattern can be generated, thereby improving query performance and reducing index maintenance costs; on the other hand, by combining the fields of the second index and the associated index and a technical means based on field merging is adopted, a more comprehensive first index can be generated in complex query scenarios, thereby optimizing the performance of complex queries and reducing resource consumption of multiple index scans.

[0091] Figure 7Another flow chart of the index updating method according to an embodiment of the present disclosure is schematically shown.

[0092] like Figure 7 As shown, the index updating method may further include operations S710 to S720.

[0093] In operation S710, a data consistency check is performed on the first index. In order to ensure that the index update operation does not have a negative impact on the stability and data integrity of the database, it is necessary to perform a data consistency check on the first index before updating, and complete the index update if the consistency requirements are met. Before updating the index, verify whether the first index can correctly reflect the current state of the target data and ensure that the content of the index is consistent with the actual data in the database. The purpose of the data consistency check is to avoid inaccurate query results or abnormal database operation due to incorrect or incomplete index content.

[0094] Data consistency checks may include index content verification, index range verification, and index structure verification.

[0095] Index content verification: Check whether the key values ​​stored in the first index are consistent with the actual values ​​of the target data. For example, after generating the first index, you can verify whether the key values ​​in the first index and the field values ​​in the target data table are consistent. If you find that some key values ​​in the first index do not match the target data, you need to regenerate the index or repair the data. For example, if the target data contains a value of "100" for field A, the key value of the corresponding field A in the first index should also be "100".

[0096] Index range verification: Check whether the first index covers all records of the target data. For example, after generating the first index, you can count the number of key values ​​in the first index and compare it with the number of records in the target data. If the number of key values ​​in the first index is less than the number of records in the target data, there may be index omissions and the index needs to be regenerated. For example, if the target data contains 1,000 records, the first index should contain key values ​​corresponding to these 1,000 records.

[0097] Index structure verification: Check whether the storage structure of the first index meets the requirements of the database. For example, after the first index is generated, the index structure can be checked through the database's built-in tools to ensure that the index storage structure is complete and error-free. For example, verify whether the B+ tree structure of the first index is complete and whether there are damaged nodes or duplicate key values.

[0098] In operation S720, updating the index for the target data to the first index includes: updating the index for the target data to the first index when the first index satisfies data consistency. For example, operation S720 may specifically include: deactivation of the old index, activation of the first index, and deletion of the old index. Deactivation of the old index: before updating the index, first mark the existing old index (such as the second index) as unavailable to avoid query conflicts during the update process. For example, at the beginning of the index update, the second index can be set to read-only or disabled through the index management function of the database to ensure that no new queries use the second index during the update process. Activation of the first index: after the first index passes the data consistency check, set it to an available state and associate it with the target data. For example, during the index update process, the first index can be set as the default index through the index management function of the database to support subsequent query operations. Deletion of the old index: after the first index is successfully enabled, the old index can be deleted to free up storage space.

[0099] According to the embodiment of the present disclosure, by performing a data consistency check on the first index and adopting technical means based on content verification, range verification and structure verification, it is possible to ensure that the content and structure of the first index are consistent with the target data, thereby providing a reliable basis for index updating; on the other hand, by completing the index update when the first index satisfies the data consistency, the technical means of phased update and state switching are adopted, so that the negative impact on the database operation during the index update process can be avoided, thereby ensuring the stability of the database and the accuracy of the query results.

[0100] According to an embodiment of the present disclosure, the operation data includes at least one of the following: resource occupancy data of running a query statement, operation index data of running a query statement, data query frequency of the target data queried by the query statement, and usage frequency of the query mode corresponding to the query statement; the trigger condition includes at least one of the following: resource occupancy data is greater than or equal to the resource occupancy threshold; the operation index data is greater than or equal to the operation index threshold; the data query frequency is greater than or equal to the data query frequency preset value; the usage frequency is greater than or equal to the usage frequency preset value.

[0101] Resource usage data may refer to the system resources consumed during the execution of a query statement, including but not limited to CPU usage, memory usage, disk I / O, network bandwidth, etc. For example, in a certain query, the CPU usage reaches 85% and the memory usage reaches 70%. These resource usage data can be used as a basis for judging query performance.

[0102] Operational indicator data may refer to performance indicators generated during the execution of a query statement, including but not limited to query execution time, number of rows scanned, size of the returned result set, etc. For example, if a query statement takes 3 seconds to execute, scans 1 million rows of data, but only returns 100 results, these operational indicator data indicate that the query efficiency is low.

[0103] Data query frequency can refer to the frequency at which the target data is queried, that is, the number of times a field or a data set is queried within a certain period of time. For example, the field "material_name" is queried 500 times within 1 minute, which indicates that the field is a hotspot data for query.

[0104] Query pattern usage frequency: refers to the number of times a query pattern (such as a specific WHERE condition or JOIN condition) is used within a certain period of time. For example, a query pattern "SELECT * FROM materials WHERE material_type = 'A'" is executed 200 times within 1 minute, which indicates that the query pattern is a high-frequency query pattern.

[0105] The trigger condition refers to a set of conditions used to determine whether index adjustment is required. By comparing the operating data with the preset threshold, it is determined whether the index adjustment operation is triggered. The setting of the trigger condition can be dynamically adjusted according to the performance requirements and query load of the database. The trigger condition includes at least one of the following: resource occupancy data is greater than or equal to the resource occupancy threshold; operating index data is greater than or equal to the operating index threshold; data query frequency is greater than or equal to the data query frequency preset value; usage frequency is greater than or equal to the usage frequency preset value.

[0106] Resource usage data is greater than or equal to the resource usage threshold. For example, when the system resource usage reaches or exceeds a certain preset value, index adjustment is triggered. For example, the CPU usage threshold can be set to 80%, and the memory usage threshold can be set to 75%. In a certain query, the CPU usage reaches 85%, exceeding the resource usage threshold of 80%, thus triggering the index adjustment operation.

[0107] The operation index data is greater than or equal to the operation index threshold. For example, when the query performance index reaches or exceeds a certain preset value, the index adjustment is triggered. For example, the query execution time threshold can be set to 2 seconds, and the scanned row threshold can be set to 500,000 rows. The execution time of a query statement is 3 seconds, which exceeds the 2-second operation index threshold, so the index adjustment operation is triggered.

[0108] The data query frequency is greater than or equal to the preset value of the data query frequency. For example, when the query frequency of the target data reaches or exceeds a preset value, index adjustment is triggered. For example, the query frequency threshold of a field can be set to 100 times per minute. A field "material_name" is queried 500 times in 1 minute, which exceeds the preset value of 100 times, thus triggering the index adjustment operation.

[0109] The usage frequency is greater than or equal to the preset usage frequency value. For example, when the usage frequency of a query pattern reaches or exceeds a preset value, index adjustment is triggered. For example, the usage frequency threshold of a query pattern can be set to 50 times per minute. A query pattern "SELECT * FROM materials WHERE material_type = 'A'" is executed 200 times in 1 minute, which exceeds the preset usage frequency value of 50 times, thus triggering an index adjustment operation.

[0110] According to the embodiments of the present disclosure, through multi-dimensional analysis of operating data, a comprehensive evaluation technical means based on resource occupancy, operating indicators, query frequency and usage frequency is adopted, so that the bottleneck of query performance can be fully identified, providing a reliable basis for index adjustment; on the other hand, by setting trigger conditions and dynamically adjusting thresholds, a trigger mechanism based on dynamic monitoring is adopted, so that query performance problems can be responded to in a timely manner under high-load scenarios, thereby achieving high efficiency and pertinence of index adjustment.

[0111] Figure 8 Another flow chart of the index updating method according to an embodiment of the present disclosure is schematically shown.

[0112] like Figure 8 As shown, the index updating method may further include operations S810 to S850.

[0113] In operation S810, in response to data update in the database, the index field corresponding to the updated data is obtained. Data update in the database refers to the process of inserting, deleting or modifying the data stored in the database. Data update may affect the content and performance of the existing index, so it is necessary to analyze the index field corresponding to the updated data to determine whether the index needs to be adjusted. The index field corresponding to the updated data refers to the field associated with the update operation, which may be part of the existing index (such as the third index). For example: if the update operation involves field A, and field A is the index field of the third index, it is necessary to obtain field A and analyze its impact on the third index. For another example, if the update operation involves a range of data (such as the value of field A is updated from 100 to 200), it is necessary to check whether the data in the range has a significant impact on the performance of the third index.

[0114] In operation S820, when there is a corresponding third index for the updated data, first resource overhead prediction information corresponding to the first index is obtained based on the index evaluation model.

[0115] In operation S830, second resource cost prediction information corresponding to the third index is obtained based on the index evaluation model.

[0116] The third index may cause performance degradation or increase in resource overhead due to data update, so it needs to be evaluated. Specifically, based on the index evaluation model, the first index is generated according to the third index, and the second resource overhead prediction information corresponding to the third index and the first resource overhead prediction information corresponding to the first index are predicted. By comparing the resource overhead prediction information of the first index and the third index, it can be determined whether the third index needs to be optimized. For example, if the resource overhead of the third index increases significantly, it may be necessary to generate a new index to replace the third index.

[0117] In operation S840, in response to the second resource cost prediction information satisfying the preset resource condition, based on the index evaluation model, according to the third index, a fourth index and third resource cost prediction information corresponding to the fourth index are generated. The preset resource condition refers to a set of conditions for determining whether a new index needs to be generated, such as whether the query execution time exceeds a threshold, whether the index maintenance cost is too high, etc. For details, please refer to the relevant content of the trigger condition in the aforementioned embodiment.

[0118] In operation S850, in response to the third resource cost prediction information being superior to the second resource cost prediction information, the third index is updated to a fourth index. By analyzing the index field corresponding to the updated data, an index evaluation technique based on data update is adopted, so that the impact of the data update on the existing index performance can be identified; on the other hand, by generating the fourth index based on the index evaluation model and completing the index update, a dynamic optimization technique is adopted, so that the index structure can be adjusted in time after the data is updated, thereby improving the query performance and reducing the resource consumption.

[0119] Fig. 9 A block diagram of an index updating device according to an embodiment of the present disclosure is schematically shown.

[0120] like Fig. 9 As shown, the index updating device 900 includes a first acquisition module 910 , a second acquisition module 920 , a generation module 930 and an update module 940 .

[0121] The first acquisition module 910 is used to acquire the operation data when the query statement is executed in real time; in some embodiments, the first acquisition module 910 is used to perform operation S110 in the above method.

[0122] The second acquisition module 920 is used to acquire target data in response to the running data satisfying the trigger condition, where the target data includes the query method corresponding to the query statement and the target data queried by the query statement; in some embodiments, the second acquisition module 920 is used to execute operation S120 in the aforementioned method.

[0123] The generation module 930 is used to generate a first index according to the target data based on the index evaluation model and to query the first resource overhead prediction information of the target data through the first index in a query manner; in some embodiments, the generation module 930 is used to perform operation S130 in the aforementioned method.

[0124] The updating module 940 is configured to update the index for the target data to the first index in response to the first resource cost prediction information being better than the resource cost of executing the query statement. In some embodiments, the updating module 940 is configured to perform operation S140 in the aforementioned method.

[0125] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging circuits, or can be implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.

[0126] For example, any multiple of the first acquisition module 910, the second acquisition module 920, the generation module 930, and the update module 940 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present disclosure, at least one of the first acquisition module 910, the second acquisition module 920, the generation module 930, and the update module 940 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, at least one of the first acquisition module 910 , the second acquisition module 920 , the generation module 930 , and the update module 940 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.

[0127] It should be noted that the data processing system part in the embodiments of the present disclosure corresponds to the data processing method part in the embodiments of the present disclosure. The description of the data processing system part specifically refers to the data processing method part, which will not be repeated here.

[0128] Fig.10 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. Fig.10 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0129] like Fig.10 As shown, the electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 to a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0130] In RAM 1003, various programs and data required for the operation of electronic device 1000 are stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other via bus 1004. Processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1002 and / or RAM 1003. It should be noted that the program can also be stored in one or more memories other than ROM 1002 and RAM 1003. Processor 1001 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0131] According to an embodiment of the present disclosure, the electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The electronic device 1000 may further include one or more of the following components connected to the input / output (I / O) interface 1005: an input portion 1006 including a keyboard, a mouse, etc.; an output portion 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk, etc.; and a communication portion 1009 including a network interface card such as a LAN card, a modem, etc. The communication portion 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the input / output (I / O) interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage portion 1008 as needed.

[0132] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0133] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0134] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

[0135] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 1002 and / or the RAM 1003 described above and / or one or more memories other than the ROM 1002 and the RAM 1003 .

[0136] An embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains a program code for executing the method provided by the embodiment of the present disclosure. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the index update method provided by the embodiment of the present disclosure.

[0137] When the computer program is executed by the processor 1001, the above functions defined in the system / device of the embodiment of the present disclosure are executed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0138] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1009, and / or installed from the removable medium 1011. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0139] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0141] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. An index updating method, comprising: Get real-time operation data when executing query statements; In response to the running data satisfying a trigger condition, acquiring target data, the target data including a query method corresponding to the query statement and the target data queried by the query statement; Based on the index evaluation model, generating a first index according to the target data and querying first resource cost prediction information of the target data through the first index in the query manner; In response to the first resource cost prediction information being better than the resource cost of executing the query statement, the index for the target data is updated to the first index.

2. The method according to claim 1, wherein the first resource cost prediction information is better than the resource cost of executing the query statement, and includes at least one of the following: The operation overhead corresponding to querying the target data through the first index in the query mode is less than the operation overhead corresponding to executing the query statement; The resource overhead required to create the first index is less than a preset resource overhead threshold. 3 . The method according to claim 1 , wherein executing the query statement comprises executing the query statement based on a preset second index.

4. The method according to claim 3, wherein the resource cost prediction information is better than the resource cost of executing the query statement, and comprises at least one of the following: The operation overhead corresponding to querying the target data through the first index in the query mode is less than the operation overhead corresponding to querying the target data through the second index in the query mode; The resource overhead required to maintain the first index is less than the resource overhead required to maintain the second index.

5. The method according to claim 3, wherein the target operation data further includes the second index, and the step of generating the first index according to the target operation data comprises: Based on the index evaluation model, generating the first index according to the query mode, the target data and at least part of the second index; or Obtain an associated index of the second index, and based on an index evaluation model, generate the first index according to the query method, the target data, the second index, and at least part of the associated index, wherein the associated index has an associated query field with the second index.

6. The method according to claim 3, wherein generating a first index according to the target operation data comprises: generating at least one first index according to the target operation data; The index field corresponding to the first index is at least part of the multiple index fields corresponding to each of the second indexes, or the index field corresponding to the first index includes the associated index corresponding to each of the second indexes and at least part of the multiple index fields corresponding to each of the second indexes; The associated index and the second index have associated query fields.

7. The method according to claim 1, further comprising: Performing a data consistency check on the first index; The updating the index for the target data to the first index includes: when the first index satisfies data consistency, updating the index for the target data to the first index.

8. According to the method of claim 1, the operation data includes at least one of the following: resource usage data of running the query statement, operation index data of running the query statement, data query frequency of the target data queried by the query statement, and usage frequency of the query mode corresponding to the query statement; the trigger condition includes at least one of the following: The resource occupancy data is greater than or equal to the resource occupancy threshold; the operation index data is greater than or equal to the operation index threshold; The data query frequency is greater than or equal to a preset data query frequency value; The usage frequency is greater than or equal to a preset usage frequency value.

9. The method according to claim 1, further comprising: In response to data update in the database, obtaining an index field corresponding to the updated data; In a case where the update data has a corresponding third index, obtaining first resource overhead prediction information corresponding to the first index based on an index evaluation model; Based on the index evaluation model, obtaining second resource overhead prediction information corresponding to the third index; In response to the second resource overhead prediction information satisfying a preset resource condition, based on an index evaluation model and according to the third index, generating a fourth index and third resource overhead prediction information corresponding to the fourth index; In response to the third resource overhead prediction information being superior to the second resource overhead prediction information, the third index is updated to the fourth index.

10. An index updating device, comprising: The first acquisition module is used to acquire the running data when executing the query statement in real time; A second acquisition module, configured to acquire target data in response to the running data satisfying a trigger condition, wherein the target data includes a query method corresponding to the query statement and target data queried by the query statement; A generating module, configured to generate a first index according to the target data based on an index evaluation model and query first resource cost prediction information of the target data through the first index in the query manner; as well as An updating module is used to update the index for the target data to the first index in response to the first resource cost prediction information being better than the resource cost of executing the query statement.

Citation Information

Cited By

  • Index optimization method and device

    CN120596488A