An index selection method, system and storage medium of a relational database

By using empirical discrimination models and optimization rules in relational databases, the problem of index failure under complex query conditions in traditional databases is solved, achieving dynamic optimization of the optimal index structure and improvement of query efficiency.

CN115470306BActive Publication Date: 2026-03-31INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Traditional relational databases often experience index failures under complex query conditions, and index structure optimization is difficult.

Method used

An empirical discrimination model is used to match the source SQL query statement with the target index structure. The optimal SQL query statement is generated by parsing and optimizing rules, and the index structure is optimized by combining preset thresholds and idle status.

Benefits of technology

It effectively solves the problem of index failure, improves the efficiency and optimization capabilities of SQL queries, adapts to changes in data volume, and provides the optimal index selection solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115470306B_ABST
    Figure CN115470306B_ABST
Patent Text Reader

Abstract

The application discloses an index selection method and system of a relational database and a storage medium. The method comprises the following steps: a relational database receives a source SQL query statement, and inputs the source SQL query statement into a preset experience discrimination model to match a target index structure; the source SQL query statement is optimized based on the target index structure to obtain an executed SQL query statement; whether the execution time of the executed SQL query statement is greater than a preset threshold is determined; in the case of being greater, the source SQL query statement is stored in a to-be-optimized statement table, and the source SQL query statement in the to-be-optimized statement table is optimized based on a preset optimization rule to obtain an optimal SQL query statement; and the optimal SQL query statement is stored in the experience discrimination model to realize updating. The method avoids the problems that the index of a traditional relational database often fails under complex query conditions, and it is difficult to optimize the index structure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to an index selection method, system, and storage medium for relational databases. Background Technology

[0002] In relational database development, to improve data retrieval speed, it is usually necessary to add indexes to fields to accelerate data retrieval capabilities. Relational database indexes use a B+ tree (or other) as a guide to locate the range of addresses of the data to be searched. Based on the narrowed range, the required data is then read from the disk. This retrieval method can minimize frequent disk reads and accelerate overall query efficiency.

[0003] However, the effectiveness of relational database indexes is not entirely under the programmer's control. When a request is submitted to the relational database, the database makes a preliminary judgment on the SQL statement. This judgment includes whether to use an index, whether to use a user-specified index, and selecting the index deemed optimal by the relational database. This judgment is often quite simple, leading to frequent index failures and full table scans in complex join queries. Therefore, the frequent index failures under complex query conditions in traditional relational databases, and the difficulty in optimizing the index structure predicted by the relational database, have become pressing technical problems that need to be addressed. Summary of the Invention

[0004] This application provides an index selection method, system, and storage medium for relational databases to solve the following technical problems: For traditional relational databases, indexes often fail under complex query conditions, and it is difficult to optimize the predicted index structure of relational databases.

[0005] In a first aspect, embodiments of this application provide an index selection method for a relational database, characterized in that the method includes: the relational database receiving a source SQL query statement and inputting the source SQL query statement into a preset empirical discrimination model for target index structure matching; if the empirical discrimination model determines that a matching target index structure exists, optimizing the source SQL query statement based on the target index structure to obtain an SQL query statement to be executed; executing the SQL query statement to be executed and determining whether the execution time of the SQL query statement to be executed is greater than a preset threshold; if the execution time is greater than the preset threshold, storing the source SQL query statement in a statement to be optimized table, and optimizing the source SQL query statements in the statement to be optimized table based on preset optimization rules to obtain an optimal SQL query statement; and storing the optimal SQL query statement in the empirical discrimination model for updating.

[0006] In one implementation of this application, the source SQL query statement is input into a preset empirical discrimination model for target index structure matching. Specifically, this includes: parsing the source SQL query statement to determine a first number of index nodes contained in the source index structure; wherein, the source index structure is the index structure contained in the source SQL query statement; matching the first number of index nodes with several optimized SQL query statements contained in the empirical discrimination model to obtain a second number of sub-index structures; and processing the second number of sub-index structures based on a preset classification discrimination module to obtain the target index structure.

[0007] In one implementation of this application, the source SQL query statement in the statement to be optimized table is optimized based on preset optimization rules. Specifically, this includes: monitoring the relational database to determine whether the relational database is in an idle state; if the relational database is determined to be in an idle state, traversing the index structure combination based on the end index node of the source index structure to obtain the optimal SQL query statement corresponding to the source SQL query statement.

[0008] In one implementation of this application, before the relational database receives the source SQL query statement, the method further includes: constructing a target SQL query statement corresponding to the source SQL query statement based on preset query requirements, and adding a priority label to the target SQL query statement; storing the target SQL query statement in an empirical discrimination model, and when the source SQL query statement is input into the preset empirical discrimination model for target index structure matching, if a sub-index structure corresponding to the target SQL query statement exists, it is selected first.

[0009] In one implementation of this application, the method further includes: determining the source SQL query statement as the SQL query statement to be executed when the empirical discrimination model determines that there is no matching target index structure.

[0010] Secondly, embodiments of this application also provide an index selection system for a relational database, characterized in that it is applied to a relational database and includes: an experience judgment module, a first optimization module, an execution module, a second optimization module, and an update module; the experience judgment module is used to receive a source SQL query statement and input the source SQL query statement into a preset experience discrimination model for target index structure matching; the first optimization module is used to optimize the source SQL query statement based on the target index structure when the experience discrimination model determines that a matching target index structure exists, so as to obtain an SQL query statement to be executed; the execution module is used to execute the SQL query statement to be executed and determine whether the execution time of the SQL query statement to be executed is greater than a preset threshold; the second optimization module is used to store the source SQL query statement in a statement to be optimized table when the execution time is greater than the preset threshold, and optimize the source SQL query statement in the statement to be optimized table based on preset optimization rules to obtain the optimal SQL query statement; the update module is used to store the optimal SQL query statement in the experience discrimination model to realize the update.

[0011] In one implementation of this application, the source SQL query statement is input into a preset empirical discrimination model for target index structure matching. Specifically, this includes: parsing the source SQL query statement to determine a first number of index nodes contained in the source index structure; wherein, the source index structure is the index structure contained in the source SQL query statement; matching the first number of index nodes with several optimized SQL query statements contained in the empirical discrimination model to obtain a second number of sub-index structures; and processing the second number of sub-index structures based on a preset classification discrimination module to obtain the target index structure.

[0012] In one implementation of this application, the source SQL query statement in the statement to be optimized table is optimized based on preset optimization rules. Specifically, this includes: monitoring the relational database to determine whether the relational database is in an idle state; if the relational database is determined to be in an idle state, traversing the index structure combination based on the end index node of the source index structure to obtain the optimal SQL query statement corresponding to the source SQL query statement.

[0013] In one implementation of this application, the system further includes: a statement construction model; the statement construction model is used to construct a target SQL query statement corresponding to the source SQL query statement based on preset query requirements, and add a priority label to the target SQL query statement; the target SQL query statement is stored in an empirical discrimination model, and when the source SQL query statement is input into the preset empirical discrimination model for target index structure matching, if a sub-index structure corresponding to the target SQL query statement exists, it is selected first.

[0014] Thirdly, embodiments of this application also provide a non-volatile computer storage medium for index selection in a relational database, storing computer-executable instructions. The computer-executable instructions are configured as follows: the relational database receives a source SQL query statement and inputs it into a preset empirical discrimination model for target index structure matching; if the empirical discrimination model determines that a matching target index structure exists, the source SQL query statement is optimized based on the target index structure to obtain an SQL query statement to be executed; the SQL query statement to be executed is executed, and it is determined whether the execution time of the SQL query statement to be executed is greater than a preset threshold; if the execution time is greater than the preset threshold, the source SQL query statement is stored in a statement to be optimized table, and the source SQL query statements in the statement to be optimized table are optimized based on preset optimization rules to obtain the optimal SQL query statement; the optimal SQL query statement is stored in the empirical discrimination model for updating.

[0015] This application provides an index selection method, system, and storage medium for relational databases. Through an empirical judgment model, it effectively addresses the problem of traditional relational databases being unable to select the optimal index in complex SQL queries. Furthermore, the optimization rule empirical model of this application can continuously find the optimal SQL query usage scheme over time and as the data volume changes. Attached Figure Description

[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0017] Figure 1 A flowchart illustrating an index selection method for a relational database provided in this application embodiment;

[0018] Figure 2 This is a schematic diagram of the internal structure of an index selection system for a relational database provided in an embodiment of this application. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0020] This application provides an index selection method, system, and storage medium for relational databases to solve the following technical problems: For traditional relational databases, indexes often fail under complex query conditions, and it is difficult to optimize the predicted index structure of relational databases.

[0021] The technical solutions proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0022] Figure 1 This is a flowchart illustrating an index selection method for a relational database, as provided in an embodiment of this application. Figure 1 As shown in the embodiment of this application, an index selection method for a relational database is provided, which specifically includes the following steps:

[0023] Step 101: The relational database receives the source SQL query statement and inputs it into a preset empirical discrimination model to match the target index structure.

[0024] In one embodiment of this application, after the relational database receives the source SQL query statement, it is first input into a preset empirical discrimination model. The empirical discrimination model parses the source SQL query statement to determine the first number of index nodes contained in the source index structure. It should be noted that the source index structure is the index structure contained in the source SQL query statement.

[0025] Furthermore, the first number of index nodes are matched with several optimized SQL queries contained in the empirical discrimination model to obtain a second number of sub-index structures. It can be understood that a sub-index structure is an index structure corresponding to any two matching index nodes in the optimized SQL query statement after the index nodes have been matched.

[0026] Furthermore, based on the preset classification and discrimination module, the second number of sub-index structures are processed to obtain the target index structure. It should be noted that the classification and discrimination module can be trained using a preset classification algorithm, such as decision tree algorithms or Bayesian classification algorithms.

[0027] Step 102: If the empirical discrimination model determines that a matching target index structure exists, optimize the source SQL query statement based on the target index structure to obtain the SQL query statement to be executed.

[0028] In one embodiment of this application, when the empirical discrimination model determines that a matching target index structure exists, the source SQL query statement is optimized based on the target index structure to replace the source index structure in the source SQL query statement with the matching target index structure, thereby obtaining the SQL query statement to be executed.

[0029] It should be noted that there are cases where a matching target index structure cannot be obtained based on the second number of sub-index structures. Therefore, this application directly determines the source SQL query statement as the SQL query statement to be executed when the empirical discrimination model determines that no matching target index structure exists.

[0030] Step 103: Execute the SQL query statement to be executed and determine whether the execution time of the SQL query statement to be executed is greater than the preset threshold.

[0031] In one embodiment of this application, since the SQL query statement to be executed obtained through empirical discrimination model matching may not necessarily be the current optimal solution, after the relational database executes the SQL query statement, it will also determine whether the execution time of the SQL query statement exceeds a preset threshold, thereby deciding whether to perform secondary optimization.

[0032] Step 104: If the execution time exceeds a preset threshold, store the source SQL query statement in the statement to be optimized table, and optimize the source SQL query statement in the statement to be optimized table based on the preset optimization rules to obtain the optimal SQL query statement.

[0033] In one embodiment of this application, if the execution time exceeds a preset threshold, it is determined that the SQL query statement to be executed is not optimal. The source SQL query statement is then stored in the statement to be optimized table, and secondary optimization is performed when the database enters an idle time slice.

[0034] Specifically, the relational database is monitored to determine if it is idle. If it is determined to be idle, the index structure combinations are traversed based on the terminal index nodes of the source index structure to obtain the optimal SQL query statement corresponding to the source SQL query statement. It can be understood that the terminal index nodes of the source index structure are the nodes corresponding to the target information to be retrieved by the source SQL query statement.

[0035] Step 105: Store the optimal SQL query statement in the empirical discrimination model for updating.

[0036] In one embodiment of this application, since the optimal solution provided by the empirical model is sometimes not the optimal solution as perceived by the user, the model also needs to support the user in actively entering the target SQL query statement. After the user enters the optimal SQL into the system, the empirical model sends it to the discrimination model. Here, the data record needs to be marked with a flag indicating whether it is the user's SQL. When the discrimination model makes a judgment, if the user's SQL flag is present among the multiple returned values, the user's SQL model is selected first.

[0037] Specifically, based on the preset query requirements, a target SQL query statement corresponding to the source SQL query statement is constructed, and a priority label is added to the target SQL query statement; the target SQL query statement is stored in the empirical discrimination model, and when the source SQL query statement is input into the preset empirical discrimination model for target index structure matching, if a sub-index structure corresponding to the target SQL query statement exists, it is selected first.

[0038] Based on the same inventive concept, embodiments of this application also provide an index selection system for a relational database, the internal structure of which is as follows: Figure 2 As shown.

[0039] Figure 2 This is a schematic diagram of the internal structure of an index selection system for a relational database, provided as an embodiment of this application. For example... Figure 2 As shown, system 200 includes: experience judgment module 201, first optimization module 202, execution module 203, second optimization module 204, update module 205, and statement construction model 206.

[0040] In one embodiment of this application, the experience judgment module 201 is used to receive the source SQL query statement and input the source SQL query statement into a preset experience discrimination model for target index structure matching; the first optimization module 202 is used to optimize the source SQL query statement based on the target index structure when the experience discrimination model determines that a matching target index structure exists, so as to obtain the SQL query statement to be executed; the execution module 203 is used to execute the SQL query statement to be executed and determine whether the execution time of the SQL query statement to be executed is greater than a preset threshold; the second optimization module 204 is used to store the source SQL query statement in the statement to be optimized table when the execution time is greater than the preset threshold, and optimize the source SQL query statement in the statement to be optimized table based on preset optimization rules to obtain the optimal SQL query statement; the update module 205 is used to store the optimal SQL query statement in the experience discrimination model to realize the update.

[0041] In one embodiment of this application, the source SQL query statement is input into a preset empirical discrimination model for target index structure matching, specifically including: parsing the source SQL query statement to determine a first number of index nodes contained in the source index structure; wherein, the source index structure is the index structure contained in the source SQL query statement; matching the first number of index nodes with several optimized SQL query statements contained in the empirical discrimination model to obtain a second number of sub-index structures; and processing the second number of sub-index structures based on a preset classification discrimination module to obtain the target index structure.

[0042] In one embodiment of this application, the source SQL query statement in the statement to be optimized table is optimized based on preset optimization rules. Specifically, this includes: monitoring the relational database to determine whether the relational database is in an idle state; if the relational database is determined to be in an idle state, traversing the index structure combination based on the end index node of the source index structure to obtain the optimal SQL query statement corresponding to the source SQL query statement.

[0043] In one embodiment of this application, the statement construction model 206 is used to construct a target SQL query statement corresponding to the source SQL query statement based on a preset query requirement, and add a priority label to the target SQL query statement; store the target SQL query statement in an empirical discrimination model, and when the source SQL query statement is input into the preset empirical discrimination model for target index structure matching, if there is a sub-index structure corresponding to the target SQL query statement, it is selected first.

[0044] In one embodiment of this application, the first optimization module 202 is further configured to determine the source SQL query statement as the SQL query statement to be executed when the empirical discrimination model determines that there is no matching target index structure.

[0045] Some embodiments of this application provide corresponding to Figure 1 A non-volatile computer storage medium for index selection in a relational database, storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:

[0046] The relational database receives the source SQL query statement and inputs it into a preset empirical discrimination model to match the target index structure.

[0047] If the empirical discrimination model determines that a matching target index structure exists, the source SQL query statement is optimized based on the target index structure to obtain the SQL query statement to be executed.

[0048] Execute the SQL query statement to be executed, and determine whether the execution time of the SQL query statement to be executed exceeds a preset threshold;

[0049] If the execution time exceeds a preset threshold, the source SQL query statement is stored in the statement to be optimized table, and the source SQL query statement in the statement to be optimized table is optimized based on the preset optimization rules to obtain the optimal SQL query statement.

[0050] The optimal SQL query is stored in the empirical discriminant model for updates.

[0051] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for IoT devices and media are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0052] The systems, media, and methods provided in this application are one-to-one correspondences. Therefore, the systems and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the systems and media will not be repeated here.

[0053] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0054] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0055] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0056] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0057] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0058] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0059] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0060] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0061] The above description is merely an embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.

Claims

1. An index selection method for a relational database, characterized by, The method comprises: The relational database receives a source SQL query statement and inputs the source SQL query statement into a preset experience discrimination model for target index structure matching; In a case where the experience discrimination model determines that there is a matching target index structure, the source SQL query statement is optimized based on the target index structure to obtain an executed SQL query statement; The executed SQL query statement is executed, and it is determined whether the execution time of the executed SQL query statement is greater than a preset threshold value; In a case where the execution time is greater than the preset threshold value, the source SQL query statement is stored in a to-be-optimized statement table, and the source SQL query statement in the to-be-optimized statement table is optimized based on a preset optimization rule to obtain an optimal SQL query statement; The optimal SQL query statement is stored in the experience discrimination model to realize updating; The source SQL query statement is input into a preset experience discrimination model for target index structure matching, specifically comprising: The source SQL query statement is parsed to determine a first number of index nodes contained in a source index structure; wherein the source index structure is an index structure contained in the source SQL query statement; The first number of index nodes are matched with a plurality of optimized SQL query statements contained in the experience discrimination model to obtain a second number of sub-index structures; The second number of sub-index structures are processed based on a preset classification discrimination module to obtain a target index structure; Before the relational database receives a source SQL query statement, the method further comprises: Based on a preset query requirement, a target SQL query statement corresponding to the source SQL query statement is constructed, and a priority label is added to the target SQL query statement; The target SQL query statement is stored in the experience discrimination model, and when the source SQL query statement is input into the preset experience discrimination model for target index structure matching, if there is a sub-index structure corresponding to the target SQL query statement, the sub-index structure is preferentially selected.

2. The index selection method of a relational database according to claim 1, wherein, Based on a preset optimization rule, the source SQL query statement in the to-be-optimized statement table is optimized, specifically comprising: The relational database is monitored to determine whether the relational database is in an idle state; In a case where it is determined that the relational database is in an idle state, based on a terminal index node of the source index structure, index structure combinations are traversed to obtain an optimal SQL query statement corresponding to the source SQL query statement.

3. The index selection method of a relational database according to claim 1, wherein, The method further comprises: In a case where the experience discrimination model determines that there is no matching target index structure, the source SQL query statement is determined to be an executed SQL query statement.

4. An index selection system for a relational database, characterized by The system is applied to a relational database and comprises an experience judgment module, a first optimization module, an execution module, a second optimization module, and an updating module; The experience judgment module is configured to receive a source SQL query statement and input the source SQL query statement into a preset experience discrimination model for target index structure matching; The first optimization module is configured to, in a case where the experience discrimination model determines that there is a matched target index structure, optimize the source SQL query statement based on the target index structure to obtain a to-be-executed SQL query statement; The execution module is configured to execute the to-be-executed SQL query statement and determine whether an execution time of the to-be-executed SQL query statement is greater than a preset threshold value; The second optimization module is configured to, in a case where the execution time is greater than the preset threshold value, store the source SQL query statement in a to-be-optimized statement table and optimize the source SQL query statement in the to-be-optimized statement table based on a preset optimization rule to obtain an optimal SQL query statement; The update module is configured to store the optimal SQL query statement in the experience discrimination model to implement updating; The source SQL query statement is input to a preset experience discrimination model for target index structure matching, specifically including: The source SQL query statement is parsed to determine a first number of index nodes contained in a source index structure; wherein the source index structure is an index structure contained in the source SQL query statement; The first number of index nodes are matched with a plurality of optimized SQL query statements contained in the experience discrimination model to obtain a second number of sub-index structures; The second number of sub-index structures are processed based on a preset classification discrimination module to obtain a target index structure; The system further includes a statement construction model; The statement construction model is configured to construct a target SQL query statement corresponding to the source SQL query statement based on a preset query requirement and add a priority label to the target SQL query statement; The target SQL query statement is stored in the experience discrimination model, and when the source SQL query statement is input to the preset experience discrimination model for target index structure matching, if there is a sub-index structure corresponding to the target SQL query statement, the sub-index structure is preferentially selected.

5. The index selection system for a relational database of claim 4, wherein, The source SQL query statement in the to-be-optimized statement table is optimized based on a preset optimization rule, specifically including: The relational database is listened to to determine whether the relational database is in an idle state; In a case where it is determined that the relational database is in the idle state, index structure combinations are traversed based on a terminal index node of the source index structure to obtain an optimal SQL query statement corresponding to the source SQL query statement. 6.A non-transitory computer storage medium storing computer-executable instructions for indexing selection of a relational database, the computer-executable instructions comprising: The computer executable instructions are configured to: The relational database receives a source SQL query statement and inputs the source SQL query statement to a preset experience discrimination model for target index structure matching; In a case where the experience discrimination model determines that there is a matched target index structure, the source SQL query statement is optimized based on the target index structure to obtain a to-be-executed SQL query statement; The to-be-executed SQL query statement is executed, and it is determined whether an execution time of the to-be-executed SQL query statement is greater than a preset threshold value; In a case that the execution time is greater than a preset threshold, the source SQL query statement is stored in a to-be-optimized statement table, and the source SQL query statement in the to-be-optimized statement table is optimized based on a preset optimization rule to obtain an optimal SQL query statement; The optimal SQL query statement is stored in the experience discrimination model to realize updating; The source SQL query statement is input to a preset experience discrimination model for target index structure matching, specifically including: The source SQL query statement is parsed to determine a first number of index nodes contained in a source index structure; wherein the source index structure is an index structure contained in the source SQL query statement; The first number of index nodes are matched with a plurality of optimal SQL query statements contained in the experience discrimination model to obtain a second number of sub-index structures; The second number of sub-index structures are processed based on a preset classification discrimination module to obtain a target index structure; Before a relational database receives a source SQL query statement, further including: Based on a preset query requirement, a target SQL query statement corresponding to the source SQL query statement is constructed, and a priority label is added to the target SQL query statement; The target SQL query statement is stored in the experience discrimination model, and when the source SQL query statement is input to the preset experience discrimination model for target index structure matching, if there is a sub-index structure corresponding to the target SQL query statement, the sub-index structure is preferentially selected.

Citation Information

Patent Citations

  • SQL optimization system and automatic SQL optimization method

    CN108595721A

  • Database query method, terminal equipment and storage medium

    CN109947770A