Data processing method and device, electronic equipment, storage medium and product

CN123011315APending Publication Date: 2026-10-30TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510497461.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0003]本公开实施例提供了一种数据处理方法、装置、电子设备、计算机可读存储介质及计算机程序产品,可以解决现有技术用户使用门槛高,数据处理效果不好的问题

Benefits of technology

[0051]本公开实施例的方法,在执行数据库操作指令的过程中,会为该指令生成多个执行计划,并从用于选择执行计划的多个选择策略集中确定与多个执行计划中的至少一个执行计划相匹配的目标策略集,其中,每个选择策略集中包括计划确定策略或执行代价调整策略。基于选择策略集与执行计划之间的匹配机制,基于目标策略集中的选择策略从多个执行计划中确定出最优的执行计划,执行数据库操作指令。该方法是一种自动化确定最优执行计划的方式,对于用户的技术水平要求低,用户的使用门槛低,且基于本公开实施例确定出的目标执行计划执行数据库操作指令的执行效果较好。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011315A_ABST
    Figure CN123011315A_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a data processing method and device, electronic equipment, computer readable storage medium and product, and relate to the technical field of databases. The method comprises: receiving a database operation instruction for a target data table, generating a plurality of execution plans of the database operation instruction; obtaining a plurality of selection strategy sets for selecting the execution plans, and at least one operation operator sequence matched with each selection strategy set, each selection strategy set comprising at least one selection strategy; determining, from the plurality of selection strategy sets, a target strategy set matched with the plurality of execution plans; determining, from the plurality of execution plans, a target execution plan according to the selection strategies in the target strategy set; and executing the database operation instruction on the target data table based on the target execution plan. The method provided by the embodiments of the present disclosure has a low user threshold and can obtain a good execution effect of the database operation instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the fields of data processing technology and database technology. Specifically, this disclosure relates to a data processing method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology

[0002] With the rapid development of information technology, database systems have been widely and deeply applied in many fields, and their performance and efficiency are crucial for the stable operation of various business systems. For a database operation command input by a user, there may be multiple different execution plans. Current technology uses the method of adding hints to the database operation command to determine the final execution plan from multiple plans. However, this method of determining the execution plan has a high user threshold, limiting its promotion and use in practical applications. Furthermore, the performance of database operation commands determined in this way is not ideal. Therefore, the method for determining the optimal execution plan needs improvement. Summary of the Invention

[0003] This disclosure provides a data processing method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can solve the problems of high user barriers and poor data processing effects in the prior art. The technical solution provided by this disclosure is as follows:

[0004] According to one aspect of the embodiments of the present disclosure, a data processing method is provided, the method comprising:

[0005] Receive database operation instructions for a target data table, generate multiple execution plans for the database operation instructions, wherein each execution plan includes a sequence of operation operators, and the sequence of operation operators includes at least one database operation operator;

[0006] Obtain multiple sets of selection strategies for selecting an execution plan, and at least one sequence of operation operators matching each set of selection strategies, each set of selection strategies including at least one selection strategy, each selection strategy being a plan determination strategy or an execution cost adjustment strategy;

[0007] From the plurality of selection strategy sets, a target strategy set that matches at least one of the plurality of execution plans is determined; based on the selection strategy in the target strategy set, a target execution plan is determined from the plurality of execution plans;

[0008] Based on the target execution plan, the database operation instructions are executed on the target data table.

[0009] As an optional embodiment of this disclosure, the step of determining a target strategy set that matches at least one execution plan among the plurality of execution plans from the plurality of selection strategy sets; and determining a target execution plan from the plurality of execution plans according to the selection strategies in the target strategy set, includes:

[0010] Perform the following comparison operation on the multiple execution plans until all multiple execution plans have participated in the comparison operation, and determine the execution plan retained in the last comparison operation as the target execution plan;

[0011] Identify two execution plans from the plurality of execution plans that are participating in the current comparison operation, wherein at least one of the two execution plans has not participated in the comparison operation before;

[0012] From the plurality of selection strategy sets, a target strategy set that matches at least one of the two execution plans is determined. Based on the selection strategy in the target strategy set, the execution plan to be retained is determined from the two execution plans. The currently retained execution plan and any execution plan that has not participated in the comparison operation are selected as the two execution plans to participate in the next comparison operation.

[0013] As an optional embodiment of this disclosure, if the selection strategy set includes a plan determination strategy, then the selection strategy set is matched with at least two operation operator sequences, and the determination strategy includes a selection method for determining a target operator sequence from the at least two operation operator sequences;

[0014] The step of determining the execution plan to be retained from the two execution plans based on the selection strategy in the target strategy set includes:

[0015] If the target strategy set includes a plan determination strategy, a target operator sequence is determined from at least two operation operator sequences that match the target strategy set, according to the selection method of the plan determination strategy. The execution plan that includes the target operator sequence in the two execution plans is selected as the execution plan to be retained.

[0016] If the target strategy set includes an execution cost adjustment strategy, determine the initial execution cost corresponding to each of the two execution plans. Adjust the initial execution cost of the execution plan that matches the target strategy set according to the adjustment method of the execution cost adjustment strategy. If both execution plans match the target strategy set, select the execution plan with the lower adjusted execution cost as the execution plan to be retained. If only one of the two execution plans matches the target strategy set, determine the execution plan with the lower execution cost between the adjusted execution cost of the matching plan and the initial execution cost of the other execution plan as the execution plan to be retained.

[0017] As an optional embodiment of this disclosure, the step of determining the execution plan to be retained from the two execution plans according to the selection strategy in the target strategy set includes:

[0018] Obtain the policy execution trigger condition corresponding to each selected policy in the target policy set;

[0019] For each selection strategy in the target strategy set, if the two execution plans meet the strategy execution triggering condition of the selection strategy, the execution plan to be retained is determined from the two execution plans according to the selection strategy;

[0020] The method further includes:

[0021] If there is no selection strategy in the target strategy set that satisfies the strategy execution triggering conditions for the two execution plans, then based on the initial costs of the two execution plans, the execution plan with the lower execution cost is determined as the retained execution plan.

[0022] As an optional embodiment of this disclosure, receiving database operation instructions for a target data table and generating multiple execution plans for the database operation instructions includes:

[0023] The database operation instruction is parsed to obtain the operation step sequence corresponding to the database operation instruction, and the operation operator corresponding to each step in the operation step sequence;

[0024] Based on the sequence of operation steps, multiple generation operations are performed, wherein the multiple execution plans of the database operation instructions include the execution plan generated by the last generation operation;

[0025] The initial generation operation includes:

[0026] Select at least one of the earlier steps in the sequence of operation steps, and generate at least one execution plan for the first generation operation based on the operation operator corresponding to the at least one step.

[0027] Non-first generation operations include:

[0028] Based on at least one execution plan generated by the previous generation operation and the operation operator corresponding to at least one subsequent operation step of each operation step that has participated in the generation operation, generate at least one execution plan for the current generation operation.

[0029] As an optional embodiment of this disclosure, for non-first generation operations, generating at least one execution plan for the current generation operation includes:

[0030] If multiple execution plans were generated in the previous generation operation, one execution plan is selected from the multiple execution plans generated in the previous generation operation;

[0031] Based on the selected execution plan and the operation operator corresponding to at least one operation step after each operation step that has participated in the generation operation, at least one execution plan is generated for the current generation operation.

[0032] As an optional embodiment of this disclosure, when there are multiple execution plans generated in the previous generation operation, selecting one execution plan from the multiple execution plans generated in the previous generation operation includes:

[0033] For the multiple execution plans generated in the previous generation operation, a set of selection strategies that matches at least one of the multiple execution plans is determined from the multiple selection strategy sets;

[0034] Based on the selection strategy in the determined selection strategy set, determine one of the execution plans on which the current sub-generation operation is based from the multiple execution plans.

[0035] As an optional embodiment of this disclosure, the initial execution cost of each execution plan is determined in the following manner:

[0036] Obtain the data distribution information of the target data table, and determine the statistical information of the data to be processed corresponding to each operation operator in the execution plan based on the data distribution information;

[0037] For each operation operator, the execution cost of the operation operator is determined based on the statistical information of the data to be processed by the operation operator.

[0038] The initial execution cost of the execution plan is determined based on the execution costs of all operators in the execution plan.

[0039] As an optional embodiment of this disclosure, determining the target strategy set that matches at least one of the two execution plans from the plurality of selection strategy sets includes:

[0040] For each selection strategy set, if there is only one sequence of operation operators that matches the selection strategy set, and if the sequence of operation operators corresponding to either of the two execution plans includes a sequence of operation operators that matches the selection strategy set, then the selection strategy set is taken as the target strategy set.

[0041] For each selection strategy set, if there are multiple operation operator sequences that match the selection strategy set, and if the operation operator sequences corresponding to the two execution plans include operation operator sequences that match the selection strategy set, then the selection strategy set is taken as the target strategy set.

[0042] According to another aspect of the present disclosure, a data processing apparatus is provided, the apparatus comprising:

[0043] The operation instruction receiving module is used to receive database operation instructions for a target data table and generate multiple execution plans for the database operation instructions, wherein each execution plan includes a sequence of operation operators, and the sequence of operation operators includes at least one database operation operator.

[0044] The strategy acquisition module is used to acquire multiple sets of selection strategies for selecting an execution plan, and at least one sequence of operation operators matching each set of selection strategies. Each set of selection strategies includes at least one selection strategy, and each selection strategy is a plan determination strategy or a plan execution cost adjustment strategy.

[0045] The strategy determination module is used to determine a target strategy set that matches at least one execution plan among the plurality of execution plans from the plurality of selection strategy sets; and to determine a target execution plan from the plurality of execution plans based on the selection strategies in the target strategy set.

[0046] The execution operation instruction module is used to execute the database operation instructions on the target data table based on the target execution plan.

[0047] According to another aspect of the present disclosure, an electronic device is provided, the electronic device including a memory, a processor and a computer program stored in the memory, the processor executing the computer program to implement the data processing method described above.

[0048] According to another aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the data processing method described above.

[0049] According to another aspect of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the data processing method described above.

[0050] The beneficial effects of the technical solutions provided in this disclosure are:

[0051] The method of this disclosure, during the execution of a database operation instruction, generates multiple execution plans for the instruction and determines a target strategy set from a set of multiple selection strategies used to select the execution plans, which matches at least one of the execution plans. Each selection strategy set includes a plan determination strategy or an execution cost adjustment strategy. Based on the matching mechanism between the selection strategy set and the execution plans, the optimal execution plan is determined from the multiple execution plans based on the selection strategies in the target strategy set, and the database operation instruction is executed. This method is an automated way to determine the optimal execution plan, requiring low technical skills from the user and having a low barrier to entry. Furthermore, the execution effect of database operation instructions based on the target execution plan determined by this disclosure is good. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments of this disclosure will be briefly introduced below.

[0053] Figure 1 This is a schematic diagram of the system architecture for implementing the data processing method provided in the embodiments of this disclosure;

[0054] Figure 2 A flowchart illustrating a data processing method provided in an embodiment of this disclosure;

[0055] Figure 3 A grammar diagram of a domain-specific language provided for embodiments of this disclosure;

[0056] Figure 4 A flowchart illustrating the process of determining a target execution plan is provided for an embodiment of this disclosure;

[0057] Figure 5 A framework diagram for determining a target generation plan provided in an embodiment of this disclosure;

[0058] Figure 6 A content structure diagram of a database optimizer provided in this embodiment of the disclosure;

[0059] Figure 7 A schematic diagram of a selection strategy set provided in an embodiment of this disclosure;

[0060] Figure 8A schematic diagram illustrating another set of selection strategies provided in this embodiment of the disclosure;

[0061] Figure 9 A schematic diagram illustrating a data processing method provided in an embodiment of this disclosure;

[0062] Figure 10 A schematic diagram of a system architecture provided for an embodiment of this disclosure;

[0063] Figure 11 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of the present disclosure;

[0064] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0065] The embodiments of this disclosure are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this disclosure, and do not constitute a limitation on the technical solutions of the embodiments of this disclosure.

[0066] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this disclosure mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element are connected through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term, for example, “A and / or B” or “A, B” indicates implementation as “A,” or implementation as “B,” or implementation as “A and B.”

[0067] In this disclosure, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0068] To make the objectives, technical solutions, and advantages of this disclosure clearer, the embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.

[0069] First, the technical terms used in this disclosure will be introduced and explained:

[0070] The database optimizer, also known as the database tuner or query optimizer, generates one or more execution plans when a database executes an SQL statement. The optimizer then selects the plan with the lowest "cost" for actual execution. The optimizer can calculate the total cost of each execution plan by obtaining estimates such as the total number of rows in the table to be processed, the value distribution of each column, the cardinality of related rows, and the selectivity of join and filter conditions between tables. Based on these estimates and the cost models corresponding to different physical operations (such as full table scans or index scans, nested loop joins or hash joins), the optimizer calculates the total cost of each execution plan.

[0071] Physical operations are executed by corresponding operators. The cost model corresponding to the physical operation is used to determine the execution cost of the operator. The cost model is generally a theoretical model. In the process of determining the execution cost, the process of obtaining the estimate depends on a variety of assumptions, such as the distribution characteristics of the data and the assumption that the probabilities of the data satisfy independence. These assumptions are often difficult to fully satisfy in practical applications, resulting in the inaccuracy of the execution cost of the operator determined based on the cost model. Consequently, the execution plan automatically selected by the database optimizer does not meet expectations.

[0072] To address the aforementioned issues, existing technologies explicitly specify the operations the database optimizer should use by adding hints to SQL statements. For example, using "SELECT / *+NESTLOOP(T1 T2)* / FROM T1,T2 WHERET1.C1=T2.C1", the SQL statement explicitly specifies a nested loop join for tables t1 and t2 by adding a specific hint, thus preventing the database optimizer from automatically choosing other join methods such as hash join or merge-sort join. While the hint mechanism can intervene in execution plan selection to some extent, it relies on human experience, lacks adaptability to dynamic data changes, and may prevent the optimizer from automatically selecting the optimal execution path, leading to significant system performance fluctuations and making long-term maintenance and expansion difficult.

[0073] The data processing methods, apparatus, electronic devices, computer-readable storage media, and computer program products disclosed herein are intended to solve at least one of the above-mentioned technical problems of the prior art.

[0074] The following description of several exemplary embodiments illustrates the technical solutions of this disclosure and the technical effects produced by these solutions. It should be noted that the following embodiments can be referenced, learned from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0075] Figure 1 This is a schematic diagram of a system architecture for implementing a data processing method according to an embodiment of the present disclosure. The system architecture includes a terminal 10, a server 20, a database optimizer 30, and a rule tuner 40. Terminal 10 can be used to obtain database operation instructions (i.e., SQL statements in the figure) input by the user for the target data table, and send the database operation instructions to server 20. Server 20 can be a database processing server, which can interact with database optimizer 30. Database optimizer 30 generates multiple execution plans based on the database operation instructions. Database optimizer 30 interacts with rule tuner 40, which manages and parses selection strategy sets. Each selection strategy set includes at least one selection operation. Database optimizer 30 can match the generated multiple execution plans with the selection strategy sets in rule tuner 40 to determine the target strategy set that matches at least one execution plan among the multiple execution plans. Rule tuner 40 can determine the target execution plan from the multiple execution plans based on the selection strategies in the target strategy set. Rule tuner 40 can then transmit the determined target execution plan to server 20 via database optimizer 30. Server 20 can execute the database operation instructions based on the target execution plan, obtain the execution results, and return the execution results to terminal 10.

[0076] In this embodiment, the rule tuner can also be deployed within the database optimizer. That is, the database optimizer can not only generate multiple execution plans based on database operation instructions, but also determine a target execution plan from these plans using its internal rule tuner. Alternatively, the database optimizer can be deployed within server 20. After receiving a database operation instruction, server 20 can generate multiple execution plans based on its internal database optimizer, and further determine the target execution plan based on the rule tuner within the database optimizer. Then, the server executes the database operation instruction based on the target execution plan. The database optimizer can determine the execution cost of multiple execution plans and select the execution plan with the lowest execution cost as the target execution plan. The rule tuner can participate in the database optimizer's process of determining the execution cost of the execution plans, adjusting and correcting the execution plans determined by the database optimizer to determine a better target execution plan.

[0077] In some embodiments, terminal 10 may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, smart voice interaction device, smart home appliance, vehicle terminal, etc., but is not limited thereto. Terminal 10 is equipped with an application capable of data processing. Terminal 10 can perform database operations on data tables based on the application, or it can perform database operations using command lines within the terminal. This disclosure does not impose any limitations on this.

[0078] Those skilled in the art will understand that the number of terminals described above can be more or less. For example, there may be only one terminal, or there may be dozens or hundreds of terminals, or even more. This disclosure does not limit the number of terminals or the type of device.

[0079] In some embodiments, server 20 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Server 20 is used to provide background services for applications that support data processing. In some embodiments, server 20 undertakes the main computing work, and terminal 10 undertakes the secondary computing work; or, server 20 undertakes the secondary computing work, and terminal 10 undertakes the main computing work; or, server 20 and terminal 10 collaborate on computing using a distributed computing architecture.

[0080] For example, the data processing method in this embodiment can be performed by a server. The following description uses a server as the execution entity to illustrate the solution in this embodiment.

[0081] This disclosure provides a data processing method, such as... Figure 2 As shown, the method includes:

[0082] S201. Receive database operation instructions for the target data table and generate multiple execution plans for the database operation instructions.

[0083] Each of the execution plans includes a sequence of operation operators, and the sequence of operation operators includes at least one database operation operator.

[0084] In this embodiment, the database operation instruction can be an instruction to perform operations such as adding, deleting, querying, and modifying on a target data table. It should be understood that the database operation instruction includes a table identifier for the target data table, and the target data table can be determined based on the table identifier in the database operation instruction. As an optional embodiment, the database operation instruction can be a user-inputted SQL statement, or a data processing request described in natural language by the user. The database operation instruction is generated after the intent of the data processing request is recognized based on a large language model. By utilizing the text-to-SQL capability of the large language model, the user's learning curve can be lowered.

[0085] In this embodiment, the execution plan can be a sequence of operation operators, including at least one data operation operator. It should be noted that in a database system, the execution plan is divided into a logical execution plan and a physical execution plan. The logical execution plan reflects the query semantics, such as combinations of operations like "select + projection + join," without considering the underlying implementation. The physical execution plan specifically describes how each operation is executed, such as "using an index scan or a full table scan," and "using nested loop joins or hash joins," representing the actual steps the database will execute. The execution plan in this embodiment is a physical execution plan, a sequence of operation operators consisting of at least one operation operator. The operation operator directly determines the physical operation flow of the server performing database operations on the target data table.

[0086] In generating an execution plan, the corresponding operation operators can be determined based on the operation steps required to process the database operation instruction, and the execution plan can be constructed accordingly. It's important to understand that each operation step can correspond to different operation operators, and the choice of operation operator for each step determines the final execution effect of the generated execution plan. For the operation steps required by the database operation instruction, an execution plan consisting of the complete sequence of operation operators corresponding to that operation step can be generated all at once, or the sequence of operation operators corresponding to some operation steps can be determined step by step, ultimately resulting in an execution plan consisting of the complete sequence of operation operators. The second method of generating execution plans will be explained in detail below.

[0087] As an optional embodiment of this disclosure, receiving a database operation instruction for a target data table and generating multiple execution plans for the database operation instruction includes:

[0088] The database operation instruction execution steps are parsed to obtain the operation step sequence corresponding to the database operation instruction, and the operation operator corresponding to each step in the operation step sequence;

[0089] Based on this sequence of operation steps, multiple generation operations are performed, wherein the multiple execution plans of the database operation instruction include the execution plan generated by the last generation operation;

[0090] The initial generation operation includes:

[0091] Select at least one of the earlier steps in the sequence of operation steps, and generate at least one execution plan for the first generation operation based on the operation operator corresponding to the at least one step.

[0092] Non-first generation operations include:

[0093] Based on at least one execution plan generated by the previous generation operation and the operation operator corresponding to at least one subsequent operation step of each operation step that has participated in the generation operation, generate at least one execution plan for the current generation operation.

[0094] In this embodiment of the disclosure, after receiving a database operation instruction for a target data table, the system parses the database operation instruction and converts it into an ordered sequence of operation steps. This sequence of operation steps is the logical execution plan of the database operation instruction. For example, a database operation instruction may generate an operation step sequence of four steps: scanning, joining, filtering, and sorting, which are executed sequentially.

[0095] In this embodiment of the disclosure, after determining the sequence of operation steps corresponding to the database operation instruction, the operation operator corresponding to each operation step can also be obtained. For example, the operation operator corresponding to the scan step can be a full table scan operator or an index scan operator; the operation operator corresponding to the join step can be a nested loop join operator, a merge join operator, or a hash join operator; the operation operator corresponding to the filter step can be a predicate filter operator; and the operation operator corresponding to the sorting step can be a quicksort operator or an outer sort operator.

[0096] After determining the sequence of operation steps corresponding to the database operation instructions, multiple physical execution plans for the sub-sequences of operation steps can be exploratoryly constructed based on this sequence of operation steps using a multi-round execution plan generation approach. In this embodiment of the disclosure, during the initial generation operation, at least one of the earlier steps in the operation step sequence is selected, and a corresponding execution plan is generated based on the operation operator corresponding to that at least one step. For example, if the first operation step, the scanning operation step, is selected, an execution plan can be generated based on multiple operation operators corresponding to the scanning operation step. It should be understood that this execution plan is used to execute the scanning operation step in the operation step sequence. Optionally, the initial generation operation can also generate multiple complete execution plans corresponding to the operation step sequence, in which case subsequent generation operations are not required.

[0097] In non-initial generation operations, based on at least one execution plan generated in the previous round, at least one subsequent operation step that has not yet been executed in the sequence of operation steps can be determined, and the corresponding operation operator for the subsequent operation step can be determined. Based on this, at least one execution plan for the current round is generated, expanding and supplementing the execution path of the previous round, and gradually constructing a complete execution path. As an optional embodiment, multiple execution plans generated according to database operation instructions are the execution plans generated in the last generation operation.

[0098] As an optional embodiment of this disclosure, for a non-first generation operation, the execution plan for generating at least one of the current generation operations includes:

[0099] If multiple execution plans were generated in the previous generation operation, one execution plan is selected from the multiple execution plans generated in the previous generation operation;

[0100] Based on the selected execution plan and the operation operator corresponding to at least one operation step after each operation step that has participated in the generation operation, at least one execution plan is generated for the current generation operation.

[0101] In this embodiment of the disclosure, an execution plan can be selected from multiple execution plans generated in the previous generation operation by means of existing technology. For example, the initial execution cost of multiple execution plans generated in the previous generation operation can be calculated by a database optimizer, and the execution plan with the lowest initial execution cost can be selected as the execution plan.

[0102] After selecting an execution plan, the selected execution plan can be combined with the operation operator corresponding to at least one operation step in the operation step sequence that has not yet participated in the generation operation to generate the execution plan for the current operation. For example, if the operation step sequence is A→B→C→D, and the execution plan for A→B obtained from the previous generation operation is selected, the subsequent operation step can be determined, which can be C or a combination of C and D. Taking C as the selected subsequent step, the multiple operation operators corresponding to C are combined with the selected execution plan to obtain multiple execution plans corresponding to the current generation operation.

[0103] The multiple execution plans generated by the last generation operation are the multiple execution plans corresponding to the database operation instructions.

[0104] This embodiment of the disclosure generates execution plans for subsequences of different operation step sequences through multiple iterations. Based on the operation step sequence, it can dynamically generate multiple execution plans in an iterative manner, and optimize and adjust the execution path round by round during execution. Compared to generating a complete execution plan at once, this method offers greater flexibility and adaptability, enabling the generation of more efficient and reasonable execution plans based on the actual query structure and resource conditions, thereby improving the overall performance of the database system.

[0105] S202. Obtain multiple selection strategy sets for selecting an execution plan, and at least one sequence of operation operators that matches each selection strategy set.

[0106] Each set of selection strategies includes at least one selection strategy, and each selection strategy is a strategy for determining the plan or a strategy for adjusting the execution cost.

[0107] S203. From the multiple selection strategy sets, determine the target strategy set that matches at least one of the multiple execution plans; based on the selection strategy in the target strategy set, determine the target execution plan from the multiple execution plans.

[0108] In this embodiment, the selection strategy set and its matching sequence of operation operators can be generated by the database administrator using a Domain Specific Language (DSL). The database administrator is responsible for database management and optimization, including performance tuning, backup and recovery, and user management. Furthermore, the selection strategy set can also be written and generated by the user.

[0109] Domain-specific languages ​​(DSLs) are computer languages ​​specifically designed for a particular application domain. They are used to express operational logic, rule configurations, or data structures more efficiently and intuitively within that domain. Unlike general-purpose programming languages ​​(such as Java, C++, and Python), DSLs do not pursue broad applicability but emphasize high expressiveness, low redundancy, and strong business relevance within a specific domain. DSLs have independent syntax structures and parsing rules. By using DSLs, the barrier to entry for non-specialized developers can be lowered, system configuration flexibility can be improved, system maintainability and scalability can be enhanced, and it is also easier to solidify domain knowledge into reusable language components.

[0110] For example, Structured Query Language (SQL) is a specialized language for querying and manipulating data in relational databases, which can express complex join query logic with concise syntax; Regular Expressions (Regex) is a DSL for string pattern matching, which can efficiently perform text processing tasks such as validation, extraction, and replacement.

[0111] In this embodiment, the selection strategy set can also be called heuristic rules. Database administrators can pre-define the syntax for writing heuristic rules. Both database administrators and users can write heuristic rules according to this syntax based on actual needs. Each heuristic rule can include a sequence of operation operators from the execution plan it is used to match. When determining the target execution plan based on the cost of multiple execution plans, the rule tuner can match the heuristic rules with the execution plans. The heuristic rules that match the execution plans can assist the database optimizer in selecting the target execution plan, depending on the specific way they are written.

[0112] like Figure 3 As shown, Figure 3 This is a syntax diagram of a domain-specific language provided in an embodiment of this disclosure. As shown in the figure, the selection strategy set includes the name corresponding to the selection strategy set (rulename in the figure), the matching operation operator sequence (src_pattern) and (tar_pattern), where src_pattern is called the source pattern and tar_pattern is called the target pattern. Specifically, the source pattern in the syntax rules of the selection strategy set is optional, that is, the syntax rules must include an operation operator sequence, which is the source pattern operation operator sequence. In actual writing, if the database administrator wants to write a heuristic rule (candidate strategy set) about a certain operation operator sequence, he / she writes the operation operator sequence in the source pattern src_pattern. If the database administrator wants to write a heuristic rule for more than two operation operator sequences, he / she can write the two operation operator sequences in the source pattern src_pattern and the target pattern tar_pattern respectively.

[0113] In practical applications, database administrators can name heuristic rules based on the sequence of operation operators or the selection mechanism of a specific selection strategy. For example, if a heuristic rule is used to adjust the execution cost of operator A in an operation operator sequence, it can be called the execution cost adjustment rule for operator A. If a heuristic rule is used to determine operation operator sequence B from operation operator sequences B and C, it can be called the determination rule for operation operator sequence B. Generally, when comparing heuristic rules for two operation operator sequences, database administrators can, based on historical experience, place operation operator sequence D, which is considered to have a lower execution cost under triggering condition 1, in the source schema, and the other operation operator sequence E in the target schema. Furthermore, if the database administrator also believes that operation operator sequence E is superior to operation operator sequence D under triggering condition 2, they can write a heuristic rule to place operation operator sequence E in the source schema and operation operator sequence D in the target schema; that is, two operation operator sequences can correspond to multiple heuristic rules.

[0114] This syntax also includes parameters corresponding to the selection strategy set. These parameters are used to set trigger conditions, typically by comparing the attribute information of the operator with the parameter value. The syntax also defines the order of operator traversal, such as preorder traversal. The selection strategies and corresponding trigger conditions in the selection strategy set can be written as conditional statements. When the conditions in the conditional statements are met, the corresponding selection strategy is executed. The selection strategy can be either a plan determination strategy or an execution cost adjustment strategy, determined by the specific statement corresponding to the selection strategy. Parameters are optional in the selection strategy set. When parameters are included in the selection strategy set, they can be set by the administrator or obtained by training a machine learning model using historical data.

[0115] Specifically, when training a machine model using historical data, multiple database operation instruction samples can be obtained. For each database instruction sample, the data processing method provided in this embodiment is used. Different parameter values ​​are set in the candidate strategy set to obtain different target execution costs. The loss function is calculated based on the execution cost when the database operation instruction is actually executed according to the target execution plan. The parameter values ​​are continuously adjusted, and the parameter value that minimizes the loss function is taken as the parameter value in actual use.

[0116] In this embodiment of the disclosure, each selection strategy set is matched with at least one sequence of operation operators, or in other words, each selection strategy set corresponds to at least one sequence of operation operators. If the execution plan includes the sequence of operation operators, then the selection strategy set is considered to match the execution plan. Therefore, for an execution path with a specific structure or a specific operation type, the corresponding selection strategy set can be found based on the sequence of operation operators contained in the path, so as to achieve more targeted execution plan evaluation and optimization.

[0117] As an optional embodiment, each selection strategy set and its matching operation operator sequence can be stored in a mapping table. The operation operator sequence corresponding to each selection strategy set can be determined according to the mapping table. When the execution plan includes the operation operator sequence, the execution plan is considered to match the selection strategy set.

[0118] As an optional embodiment, it is only necessary to match the sequence of operation operators corresponding to the selection strategy set with the last few operation operators executed in the execution plan; if the sequence of operation operators is successfully matched with at least one of the last operation operators in the execution plan, it can be determined that the selection strategy set matches the execution plan, thereby determining the selection strategy set as the target selection strategy set of the execution plan.

[0119] When database administrators write heuristic rules, they can create operation operator sequence identifiers for matching according to a preset traversal method. Then, they can traverse the execution plan according to this traversal method to obtain the operation operator sequence identifiers for the execution plan under that traversal method. Taking preorder traversal as an example, after determining the execution plan, a preorder traversal can be performed on the operation operator structure in the execution plan to generate corresponding operation operator sequence identifiers. In the sequence generated by this preorder traversal, the operation operator executed first is located on the right side of the sequence, and the operation operator executed last is located on the leftmost side. At this point, the operation operator sequence identifiers in the heuristic rule are compared from left to right with the operation operator sequence identifiers corresponding to the execution plan. If they match, the selection strategy set is considered to match the execution plan.

[0120] As an optional embodiment, the identifier of the sequence of operation operators matching the selection strategy set may include a wildcard operator for matching with any operation operator. Furthermore, the first operation operator in the sequence of operation operators cannot be a wildcard operator to ensure that the matching process is deterministic and the starting operation is identifiable.

[0121] In this embodiment of the disclosure, each selection strategy set includes at least one selection strategy, which can be a plan determination strategy or a plan execution cost adjustment strategy. The plan determination strategy is used to directly select the optimal execution path from multiple execution plans; while the plan execution cost adjustment strategy is used to dynamically adjust the execution cost of the execution plans, enabling the database optimizer to determine the target execution plan based on the execution cost of the execution plans.

[0122] In this embodiment, after generating multiple execution plans, multiple selection strategy sets are used to match the execution plans. Each selection strategy set predefines strategy content that matches a specific type of operation operator sequence, guiding the selection and determination of the optimal plan among multiple candidate execution plans. By introducing selection strategy sets and their matching mechanism with operation operator sequences, personalized optimization strategies based on query structure characteristics can be applied, improving the accuracy and efficiency of execution plan selection, and providing more intelligent and adaptive optimization methods for database operations.

[0123] like Figure 4 As shown, Figure 4This is a flowchart illustrating a process for determining a target execution plan, as provided in an embodiment of this disclosure. As shown, the database tuner determines the execution plan through the following steps: First, the tuner collects statistical information about tables and columns, including the number of rows, data distribution, and index usage. Then, based on this statistical information, the tuner estimates the number of rows returned by the query conditions (cardinality estimation). Next, the tuner uses a cost model to evaluate the cost of different execution methods, such as whether an index is used, whether sorting or table joins are required, etc. Finally, the tuner selects the execution plan with the lowest cost.

[0124] As an optional embodiment of this disclosure, when multiple execution plans were generated in the previous generation operation, selecting one execution plan from the multiple execution plans generated in the previous generation operation includes:

[0125] For the multiple execution plans generated in the previous generation operation, a set of selection strategies that matches at least one of the multiple execution plans is determined from the set of selection strategies.

[0126] Based on the selection strategy in the determined selection strategy set, determine the execution plan on which the current sub-generation operation is based from the multiple execution plans.

[0127] In this embodiment of the disclosure, for each generation operation with multiple execution plans, a target strategy set matching at least one execution plan among the multiple execution plans can be determined from multiple selection strategy sets. Based on the selection strategy in the target strategy set, the target execution plan corresponding to each generation operation is determined from the multiple execution plans. Each generation operation filters according to the selection strategy in the target strategy set, selecting the execution plan that best meets the strategy requirements from the multiple execution plans as the target execution plan for the current operation step.

[0128] Based on this target execution plan, the database operation instructions are executed on the target data table. During execution, the target execution plan provides clear operation steps and execution order, ensuring that the database operations are executed according to the predetermined path and strategy.

[0129] In this embodiment of the disclosure, when selecting the execution plan of the previous generation operation in a non-first generation operation, the execution plan is selected from multiple execution plans generated in the previous generation operation based on the candidate strategy set, so that the optimal execution plan is selected each time.

[0130] As an optional embodiment of this disclosure, determining a target strategy set that matches at least one execution plan among the plurality of execution plans from the plurality of selection strategy sets; and determining a target execution plan from the plurality of execution plans based on the selection strategies in the target strategy set, includes:

[0131] Perform the following comparison operation on the multiple execution plans until all multiple execution plans have participated in the comparison operation, and determine the execution plan retained in the last comparison operation as the target execution plan;

[0132] Identify the two execution plans that are participating in the current comparison operation among the multiple execution plans, wherein at least one of the two execution plans has not participated in the comparison operation before;

[0133] From the multiple selection strategy sets, determine the target strategy set that matches at least one of the two execution plans. Based on the selection strategy in the target strategy set, determine the execution plan to be retained from the two execution plans. The currently retained execution plan and any execution plan that has not participated in the comparison operation are selected as the two execution plans to participate in the next comparison operation.

[0134] In this embodiment of the disclosure, a target strategy set that matches at least one execution plan among multiple selection strategy sets is determined. During the matching process, a target strategy set that matches the operation operator sequence corresponding to the execution plan is searched, so that the subsequent optimal operation of the execution plan can be guided based on the matched target strategy set.

[0135] Based on the selection strategy in the target strategy set, a target execution plan is determined from multiple execution plans. This determination process includes performing a series of comparison operations until all execution plans have participated in at least one comparison operation. During this process, the execution plan retained in the last comparison operation is determined as the final target execution plan.

[0136] Specifically, in each round of comparison, two execution plans are identified for comparison in the current round, at least one of which is an execution plan that has not been compared before. Subsequently, a set of target strategies that matches at least one of the two execution plans is determined from multiple selection strategy sets, and based on the selection strategy in the set of strategies, one execution plan to be retained is selected from the two execution plans.

[0137] The retained execution plan will be compared with another execution plan that has not yet participated in the comparison in the next round. This process continues iterating until all execution plans have participated in the comparison process, and the final selected target execution plan is the optimal solution after each round of strategy comparison.

[0138] Through the above round-by-round comparison mechanism, combined with the strategy determination strategy or execution cost adjustment strategy in the strategy set, the target execution plan is determined, which improves the efficiency and rationality of the selection of the target execution plan, thereby achieving a better physical execution path selection for database operations.

[0139] As an optional embodiment of this disclosure, if the selection strategy set includes a plan determination strategy, then the selection strategy set is matched with at least two operation operator sequences, and the determination strategy includes a selection method for determining a target operator sequence from the at least two operation operator sequences;

[0140] The step of determining the execution plan to be retained from the two execution plans based on the selection strategy in the target strategy set includes:

[0141] If the target strategy set includes a plan determination strategy, a target operator sequence is determined from at least two operation operator sequences that match the target strategy set, according to the selection method of the plan determination strategy. The execution plan that includes the target operator sequence in the two execution plans is selected as the execution plan to be retained.

[0142] If the target strategy set includes an execution cost adjustment strategy, determine the initial execution cost corresponding to each of the two execution plans. Adjust the initial execution cost of the execution plan that matches the target strategy set according to the adjustment method of the execution cost adjustment strategy. If both execution plans match the target strategy set, select the execution plan with the lower adjusted execution cost as the execution plan to be retained. If only one of the two execution plans matches the target strategy set, determine the execution plan with the lower execution cost between the adjusted execution cost of the matching plan and the initial execution cost of the other execution plan as the execution plan to be retained.

[0143] like Figure 5 As shown, Figure 5 This is a framework diagram for determining a target generation plan provided in an embodiment of this disclosure. As shown in the figure, the logical execution plan corresponding to the SQL statement is from A to C. According to this plan, the database optimizer can first determine the operators with the lowest execution costs for steps A and C, namely operators A1 and B1. When determining the operators for step C, statistical information of the dataset can be obtained. Based on the statistical information and the pre-set independence assumption, the execution costs of operators C1 and C2 are determined. Since the execution costs of operators C1 and C2 may also be related to operators A and B, the cost model of operator A1, the code model of operator B1, the cost model of operator C1, and the cost model of operator C2 are needed when estimating the cost of the execution plan.

[0144] In this embodiment of the disclosure, the cost module of each operation operator can determine a formula for calculating the I / O cost, CPU cost, memory cost or network cost of the operation operator based on the logic of the operation operator processing data, and use the formula as the cost model of the operation operator.

[0145] In this embodiment of the disclosure, when the target strategy set includes a plan determination strategy, an execution plan to be retained can be determined from two candidate execution plans according to the selection method specified by the plan determination strategy. For example, the selection method can be based on fixed priority, rule priority matching degree, or preset decision logic to optimize the two execution plans and determine one of them as the retained plan for use in subsequent stages.

[0146] Furthermore, when the target strategy set includes an execution cost adjustment strategy, the initial execution cost corresponding to each of the two execution plans is first determined. Then, according to the adjustment method of the execution cost adjustment strategy, the initial execution cost of the execution plan that matches the target strategy set is adjusted. For example, this adjustment method could be that the database administrator adjusts the execution cost of the operation operator based on experience, either upwards or downwards. It should be understood that after the execution cost of the operation operator is adjusted, the execution cost of the corresponding execution plan will change.

[0147] If both execution plans match the target strategy set, the execution plan with the lower adjusted execution cost is selected for retention. This approach further optimizes overall execution efficiency while ensuring strategy matching.

[0148] If only one of the two execution plans matches the target strategy set, the adjusted execution cost of the matching plan is compared with the initial execution cost of the unmatched plan, and the plan with the lower cost is selected as the final execution plan to be retained. This balances strategy matching and actual execution efficiency, and improves the intelligence and adaptability of query plan selection.

[0149] As an optional embodiment of this disclosure, the initial execution cost of each execution plan is determined in the following manner:

[0150] Obtain the data distribution information of the target data table, and based on the data distribution information, determine the statistical information of the data to be processed corresponding to each operation operator in the execution plan;

[0151] For each operator, the execution cost of the operator is determined based on the statistical information of the data to be processed by that operator.

[0152] Based on the execution costs of all operators in the execution plan, the initial execution cost of the execution plan is determined.

[0153] like Figure 6 As shown, Figure 6 This is a content structure diagram of a database optimizer provided in an embodiment of this disclosure. The database optimizer is a complex system that uses multiple modules working together to determine the optimal execution plan. Among them, the query rewriting module optimizes SQL statements, particularly improving query efficiency through subquery boosting. The Execution Plan Management (SPM) module manages the SQL execution plan, ensuring that queries use the optimal plan. The SQL Outline tool allows users to provide hints to guide the optimizer in selecting a specific execution plan. The Adaptive Plan cache improves performance by caching execution plans and dynamically adjusting them based on actual conditions. The SQL Patch module is used to fix problems in the SQL execution plan.

[0154] The cost system is the core of the database optimizer. It optimizes cost estimation through cost adjustment (selectivity) and selects the optimal plan based on cost in a distributed environment. Furthermore, the cost system builds a candidate list by matching heuristic rules to select the execution path with the lowest cost. The heuristic rule tuning system includes a rule management module, a pre-parsing rule set (index / Join / predicate), a rule parsing module, and a rule application module. It improves the query plan by applying a series of optimization rules.

[0155] The statistics module provides fundamental data support for the database optimizer. Statistics management is responsible for collecting and maintaining statistical information about tables, columns, and indexes, which is crucial for the optimizer to accurately estimate query costs. Through the collaborative work of these modules, combining statistics, cost models, and heuristic rules, the entire optimizer ultimately determines the optimal execution plan to improve the performance and efficiency of database queries.

[0156] The entire optimizer works in concert through these modules, utilizing statistical information and cost models, combined with heuristic rules and user hints, to ultimately determine the optimal execution plan.

[0157] In this embodiment of the disclosure, for each execution plan, the initial execution cost of the execution plan is determined based on the execution costs of each operation operator of the execution plan. After determining the target data table corresponding to the database operation instruction, the data distribution information of the target data table can be obtained. The data distribution information includes the value distribution of each column in the table, index status, data volume, and other relevant statistical information.

[0158] Based on the data distribution information, obtain the statistical information of the data to be processed related to each operator in the execution plan. Each operator processes specific input data, and the statistical information includes the data size, distribution characteristics, presence of an index, and whether the data is sorted. For each operator, determine the execution cost based on the statistical information of its data to be processed. The execution cost may include CPU time, memory usage, I / O overhead, etc., and estimate the resources and time required for the operator to execute using the statistical information.

[0159] In this embodiment of the disclosure, the initial execution cost of the execution plan is determined based on the process flow of each operation operator in processing the data table. The initial execution cost of the execution plan can be determined based on the resource consumption of each operation operator in processing the data table. Specifically, the execution costs of each operation operator can be summed to obtain the overall initial execution cost of the execution plan.

[0160] For operators that execute in a loop, their execution cost depends not only on the cost of a single execution but also on the number of times they are executed in a loop. Therefore, when calculating the initial execution cost, the execution cost of this type of operator can be multiplied by the estimated number of executions, and then combined with the costs of other operators to more accurately reflect the resource consumption of the entire execution plan during actual execution.

[0161] S204. Based on the target execution plan, execute the database operation instructions on the target data table.

[0162] After determining the target execution plan, the database operation instructions are executed on the target data table based on the target execution plan. Specifically, the corresponding database operations are performed on the target data table sequentially according to the operation steps and operator sequences contained in the target execution plan, following a predetermined execution order. This execution process may include operations such as data table scanning, filtering, joining, sorting, and aggregation, all of which are based on the configuration of each step and operator in the target execution plan.

[0163] The target execution plan is the specific implementation of the physical execution path, ensuring that database operation instructions can be executed in the optimal way, thereby improving execution efficiency, reducing resource consumption, and ensuring the accuracy and completeness of query results.

[0164] During this process, each execution step involved in the target execution plan will be triggered one by one in the database system, optimized according to the set strategies and costs, and finally complete all operations on the target data table to ensure the smooth execution of database instructions.

[0165] The method of this disclosure, during the execution of a database operation instruction, generates multiple execution plans for the instruction and determines a target strategy set from a set of multiple selection strategies used to select the execution plans, which matches at least one of the execution plans. Each selection strategy set includes a plan determination strategy or an execution cost adjustment strategy. Based on the matching mechanism between the selection strategy set and the execution plans, the optimal execution plan is determined from the multiple execution plans based on the selection strategies in the target strategy set, and the database operation instruction is executed. This method is an automated way to determine the optimal execution plan, requiring low technical skills from the user and having a low barrier to entry. Furthermore, the execution effect of database operation instructions based on the target execution plan determined by this disclosure is good.

[0166] As an optional embodiment of this disclosure, determining the execution plan to be retained from the two execution plans according to the selection strategy in the target strategy set includes:

[0167] Obtain the execution trigger conditions for each selected strategy in the target strategy set;

[0168] For each selection strategy in the target strategy set, if the two execution plans meet the strategy execution triggering conditions of the selection strategy, the execution plan to be retained is determined from the two execution plans according to the selection strategy;

[0169] The method also includes:

[0170] If there is no selection strategy in the target strategy set that satisfies the strategy execution triggering conditions for the two execution plans, then based on the initial costs of the two execution plans, the execution plan with the lower execution cost is determined as the retained execution plan.

[0171] In this embodiment of the disclosure, the execution triggering conditions corresponding to each selection strategy in the target strategy set are obtained. Each selection strategy defines specific triggering conditions in the strategy set. These triggering conditions may include specific structures of the execution plan, estimated costs, combinations of operation operators, etc., to ensure that an appropriate execution plan is selected under appropriate conditions.

[0172] For each selection strategy in the target strategy set, if two execution plans meet the strategy's execution triggering conditions, the execution plan to be retained is determined from the two execution plans according to the selection strategy. Each selection strategy provides specific rules or criteria, which enable the determination of whether the current execution plan meets the selection criteria based on its characteristics, and select the optimal plan from the two candidate plans according to the instructions of the selection strategy.

[0173] If no strategy in the target strategy set can satisfy the strategy execution triggering conditions for both execution plans, then the execution plan with the lower execution cost is determined and retained by comparing the initial execution costs of the two plans. This step, through cost evaluation, ensures that even without triggering strategy conditions, the more suitable execution plan can still be selected based on the principle of cost minimization.

[0174] As an optional embodiment of this disclosure, the triggering condition can be set according to the attributes of the operation operators in the sequence of operation operators that match the selection strategy. For each operation operator, the operation operator includes a type attribute, the corresponding table attribute, an estimated row count attribute, and an estimated cost, as shown in Table 1. Table 1 provides an explanation of the various attributes of the operation operators provided in this embodiment of the disclosure.

[0175] Type The type corresponding to this operator Relids The set of tables corresponding to this operator Rows The estimated number of rows corresponding to this operator Cost The estimated cost corresponding to this operator

[0176] The type of the operator can be its identifier in the heuristic rules. For example, if the identifier of the Hash join operation is HJ, then the type of the Hash join operation is HJ. The set of tables corresponding to the operator indicates which tables need to be processed when the operator is executed. It should be understood that there can be multiple target data tables for a database operation instruction, and each operation operator may only be used to process one or more of these target data tables. The target data tables processed by the operation operator are the set of tables corresponding to that operation operator. The estimated cost corresponding to the operator is the execution cost of the operation operator obtained by the database optimizer based on the cost model of the operation operator. The estimated number of rows corresponding to the operator is the number of rows in the target data table related to the operation operator estimated by the database optimizer when calculating the execution cost of the operation operator; it is also called the cardinality of the operation operator.

[0177] In the selection strategy, you can set the corresponding selection strategy to be executed when the properties of the operation operator meet the preset conditions.

[0178] The embodiments of this disclosure can determine the execution plan from the perspective of operation operator attributes. Compared with the prior art of formulating operation operators, the method for determining the execution plan provided by the embodiments of this disclosure has a smaller control granularity and is a fine-grained scheme for screening execution plans.

[0179] As an optional embodiment of this disclosure, determining the target strategy set that matches at least one of the two execution plans from the plurality of selection strategy sets includes:

[0180] For each selection strategy set, if there is only one sequence of operation operators that matches the selection strategy set, and if the sequence of operation operators corresponding to either of the two execution plans includes a sequence of operation operators that matches the selection strategy set, then the selection strategy set is taken as the target strategy set.

[0181] For each selection strategy set, if there are multiple operation operator sequences that match the selection strategy set, and the operation operator sequences corresponding to the two execution plans include operation operator sequences that match the selection strategy set, then the selection strategy set is taken as the target strategy set.

[0182] In this embodiment of the disclosure, when a database administrator or user generates a selection strategy set, the issue of inaccurate cost estimation by the database optimizer when comparing the initial execution costs of two execution plans is considered. It should be understood that the database optimizer's inaccurate estimation of the initial execution cost of an execution plan may be caused by inaccurate estimation of the execution cost of one or more operators. Therefore, when creating a selection strategy set, a sequence of operators that the database optimizer is prone to misestimating in execution cost can be identified first. This sequence of operators is then used as the matching sequence of operators for the selection strategy set. When this sequence of operators is a subsequence of an execution plan, the database optimizer may misestimate the initial execution cost of that execution plan. Therefore, the initial execution cost can be adjusted based on the selection rules in the selection strategy set.

[0183] like Figure 7 As shown, Figure 7This diagram illustrates a selection strategy set provided in an embodiment of the present disclosure. As can be seen from the diagram, the selection strategy set contains only one matching operation operator sequence and includes a selection strategy, which is an execution cost adjustment strategy. When the selection strategy set contains only one matching operation operator sequence, it indicates that the selection strategy set can be used to adjust the initial execution cost of all execution plans that use that operation operator sequence as a subsequence. Specifically, the source pattern of this selection strategy set is NL(OP, OP), where NL is the nestloop join operator and OP is the wildcard operator, which is the sequence identifier of the preorder traversal operator. NL is the parent node of the two wildcard operators. During execution, the two OP operators are executed first, followed by the NL operator. The triggering condition for the selection strategy is: if the type of S1 (the first operator from left to right of the operation selection sequence identifier, i.e., the NL operator) is NL, and the set of tables corresponding to the S2 operator (similarly, the OP on the left in the parentheses) is table t1, and the set of tables corresponding to the S3 operator (similarly, the OP on the right in the parentheses) is table t2, then the execution cost of the matching execution plan is adjusted. The specific adjustment method is the content after "=>" in the figure, that is, the execution cost of S1 (i.e., NL) is increased by X (X is a preset parameter). By adjusting the execution cost of the operation operators, the execution cost of the matching execution plan is adjusted. Alternatively, when writing heuristic rules, database administrators can classify target data tables into tables such as t1, t2, etc., according to the order in which the identifiers of the target data tables appear in database operation instructions.

[0184] Furthermore, selection strategy sets can be written based on multiple operation operator sequences. Database administrators or users can write multiple operation operator sequences that match the selection strategy set based on their own experience. When each of the two execution plans being compared corresponds to an operation operator sequence as a subsequence, the selection strategy set matches both execution plans. Based on the selection strategy in the selection strategy set, the execution plan with lower cost can be determined from the two execution plans, or the execution cost of at least one of the two execution plans can be adjusted. For example... Figure 8 As shown, Figure 8 This diagram illustrates another selection strategy set provided by an embodiment of the present disclosure. The selection strategy set has two matching operation operator sequences and three selection strategies, including a plan determination strategy and two cost adjustment strategies. If two execution plans each include these two operation operator sequences, the execution plan to be retained is determined according to the three selection strategies in this selection strategy set.

[0185] The following is combined with Figure 8This section provides a detailed explanation of the heuristic rule's meaning. The rule name is TO_HASHJOIN, and it has three parameters: K, T, and M, each with its own data type. SRC_PATTERN: Source pattern; the current operator's source pattern is Nestloop. TAR_PATTERN: Target pattern; the target pattern compared to the current pattern is a different Plan, HashJoin (NestLoop), so this rule can be applied. PARAM: The parameter has a range; during tuning, an optimal value needs to be selected within this range based on feedback or AI. RULE: The specific content of the rule.

[0186] "#S + number" represents the operator number used for preorder traversal of the source pattern, such as #S2 representing NL(NL(OP,OP),OP), and "#T + number" represents the operator in the target pattern; "$ + parameter" represents the parameter value.

[0187] if(#S2.rows>$K)&&(#S5.cost<$T))=>(#S1.type>>hashjoin): If the estimated number of rows of the NL (the second NL from the left) in the source pattern is greater than K and the operator cost of the OP (the last OP in the pattern from the left) is less than T, then hashjoin is better than nestloop.

[0188] The following is a complete embodiment of the data processing method provided in this disclosure, such as... Figure 9 As shown, Figure 9 A schematic diagram of a data processing method provided in this disclosure embodiment includes:

[0189] S301, Receive database operation instructions for the target data table;

[0190] S302. Parse the execution steps of the database operation instruction to generate the sequence of operation steps corresponding to the database operation instruction, and the operation operator corresponding to each step in the sequence;

[0191] S303. Based on the sequence of operation steps, perform multiple generation operations to obtain multiple execution plans corresponding to each generation operation;

[0192] S304. Obtain multiple selection strategy sets for selecting an execution plan, and at least one sequence of operation operators that matches each selection strategy set;

[0193] S305. From multiple selection strategy sets, determine the target strategy set that matches at least one execution plan among multiple execution plans corresponding to the last generation operation;

[0194] S306. According to the selection strategy in the target strategy set, perform the following comparison operation on multiple execution plans corresponding to the last generation operation until all multiple execution plans have participated in the comparison operation, and determine the execution plan retained in the last comparison operation as the target execution plan;

[0195] S307. Based on the target execution plan, execute database operation instructions on the target data table;

[0196] S303 includes:

[0197] S401. For the first generation operation, select at least one of the earlier steps in the operation step sequence, and generate at least one execution plan for the first generation operation based on the operation operator corresponding to the at least one step.

[0198] S402. For non-first generation operations, if there are multiple execution plans generated in the previous generation operation, a selection strategy set that matches at least one of the multiple execution plans is determined from the multiple selection strategy sets.

[0199] S403. Based on the selection strategy in the determined selection strategy set, determine one execution plan from the multiple execution plans on which the current generation operation is based;

[0200] S404. Based on the execution plan obtained in S403 and the operation operator corresponding to at least one operation step after each operation step that has participated in the generation operation, generate at least one execution plan for the current generation operation.

[0201] S306 includes:

[0202] S501. Determine the two execution plans that participate in the current comparison operation from among the plurality of execution plans;

[0203] S502. From the plurality of selection strategy sets, determine a target strategy set that matches at least one of the two execution plans;

[0204] S503. Based on the selection strategy in the target strategy set, determine the execution plan to be retained from the two execution plans;

[0205] S504. Select the currently retained execution plan and any execution plan that has not participated in the comparison operation as the two execution plans to participate in the next comparison operation.

[0206] like Figure 10 As shown, Figure 10 This is a schematic diagram of a system architecture provided for an embodiment of the present disclosure. The system architecture includes a user terminal and an administrator terminal. The administrator terminal is used to generate and maintain a selection policy set, i.e. Figure 10 The heuristic rules in this embodiment allow user terminals to write their own heuristic rules based on actual needs. These rules can be stored in a database. When the database server receives the SQL statement initiated by the user terminal, it can determine the target execution plan by calling the database optimizer and rule tuner, and then generate the user-input SQL statement based on the target execution plan. The heuristic rules in this embodiment can be written according to actual needs, and new or deleted heuristic rules can be added or deleted at any time, exhibiting pluggable characteristics and flexible management.

[0207] This disclosure provides a data processing apparatus, such as... Figure 11 As shown, the data processing device may include: a receiving operation instruction module 501, a strategy acquisition module 502, a strategy determination module 503, and an execution operation instruction module 504, wherein...

[0208] The operation instruction receiving module 501 is used to receive database operation instructions for a target data table and generate multiple execution plans for the database operation instructions, wherein each execution plan includes a sequence of operation operators, and the sequence of operation operators includes at least one database operation operator.

[0209] The strategy acquisition module 502 is used to acquire multiple selection strategy sets for selecting an execution plan, and at least one sequence of operation operators matching each selection strategy set. Each selection strategy set includes at least one selection strategy, and each selection strategy is a plan determination strategy or a plan execution cost adjustment strategy.

[0210] The strategy determination module 503 is used to determine, from the plurality of selection strategy sets, a target strategy set that matches at least one execution plan among the plurality of execution plans; and to determine the target execution plan from the plurality of execution plans based on the selection strategies in the target strategy set.

[0211] The execution operation instruction module 504 is used to execute the database operation instruction on the target data table based on the target execution plan.

[0212] As an optional embodiment of this disclosure, the strategy determination module model determines a target strategy set that matches at least one execution plan among the plurality of execution plans from the plurality of selection strategy sets; and determines a target execution plan from the plurality of execution plans based on the selection strategies in the target strategy set, specifically for:

[0213] Perform the following comparison operation on the multiple execution plans until all execution plans have participated in the comparison operation, and determine the execution plan retained in the last comparison operation as the target execution plan:

[0214] Identify the two execution plans that are participating in the current comparison operation among the multiple execution plans, wherein at least one of the two execution plans has not participated in the comparison operation before;

[0215] From the multiple selection strategy sets, determine the target strategy set that matches at least one of the two execution plans. Based on the selection strategy in the target strategy set, determine the execution plan to be retained from the two execution plans. The currently retained execution plan and any execution plan that has not participated in the comparison operation are selected as the two execution plans to participate in the next comparison operation.

[0216] As an optional embodiment, if the selection strategy set includes a plan determination strategy, then the selection strategy set is matched with at least two operation operator sequences, and the determination strategy includes a selection method for determining a target operator sequence from the at least two operation operator sequences;

[0217] When the strategy determination module determines which execution plan to retain from the two execution plans based on the selection strategy in the target strategy set, it is specifically used for:

[0218] If the target strategy set includes a plan determination strategy, a target operator sequence is determined from at least two operation operator sequences that match the target strategy set, based on the selection method of the plan determination strategy. The execution plan that includes the target operator sequence in the two execution plans is taken as the execution plan to be retained.

[0219] If the target strategy set includes an execution cost adjustment strategy, determine the initial execution cost corresponding to each of the two execution plans. Based on the adjustment method of the execution cost adjustment strategy, adjust the initial execution cost of the execution plan that matches the target strategy set. If both execution plans match the target strategy set, select the execution plan with the lower adjusted execution cost as the execution plan to be retained. If only one of the two execution plans matches the target strategy set, select the execution plan with the lower execution cost between the adjusted execution cost of the matching plan and the initial execution cost of the other execution plan as the execution plan to be retained.

[0220] As an optional implementation, when determining the execution plan to be retained from the two execution plans based on the selection strategy in the target strategy set, the strategy model is specifically used for:

[0221] Obtain the execution trigger conditions for each selected strategy in the target strategy set;

[0222] For each selection strategy in the target strategy set, if the two execution plans meet the strategy execution triggering conditions of the selection strategy, the execution plan to be retained is determined from the two execution plans according to the selection strategy;

[0223] The strategy determination module is also used for:

[0224] If there is no selection strategy in the target strategy set that satisfies the strategy execution triggering conditions for the two execution plans, then based on the initial costs of the two execution plans, the execution plan with the lower execution cost is determined as the retained execution plan.

[0225] As an optional embodiment, when the operation instruction receiving module receives a database operation instruction for a target data table and generates multiple execution plans for that database operation instruction, it is specifically used for:

[0226] The database operation instruction execution steps are parsed to obtain the operation step sequence corresponding to the database operation instruction, and the operation operator corresponding to each step in the operation step sequence;

[0227] Based on this sequence of operation steps, multiple generation operations are performed, wherein the multiple execution plans of the database operation instruction include the execution plan generated by the last generation operation;

[0228] The initial generation operation includes:

[0229] Select at least one of the earlier steps in the sequence of operation steps, and generate at least one execution plan for the first generation operation based on the operation operator corresponding to the at least one step.

[0230] Non-first generation operations include:

[0231] Based on at least one execution plan generated by the previous generation operation and the operation operator corresponding to at least one subsequent operation step of each operation step that has participated in the generation operation, generate at least one execution plan for the current generation operation.

[0232] As an optional embodiment, for a non-first generation operation, the execution plan for generating at least one of the current generation operations includes:

[0233] If multiple execution plans were generated in the previous generation operation, one execution plan is selected from the multiple execution plans generated in the previous generation operation;

[0234] Based on the selected execution plan and the operation operator corresponding to at least one operation step after each operation step that has participated in the generation operation, at least one execution plan is generated for the current generation operation.

[0235] As an optional embodiment, when there are multiple execution plans generated in the previous generation operation, the module receiving the operation instruction selects one execution plan from the multiple execution plans generated in the previous generation operation, specifically for:

[0236] For the multiple execution plans generated in the previous generation operation, a set of selection strategies that matches at least one of the multiple execution plans is determined from the set of selection strategies.

[0237] Based on the selection strategy in the determined selection strategy set, determine the execution plan on which the current sub-generation operation is based from the multiple execution plans.

[0238] As an optional implementation, the initial execution cost of each execution plan is determined in the following manner:

[0239] Obtain the data distribution information of the target data table, and based on the data distribution information, determine the statistical information of the data to be processed corresponding to each operation operator in the execution plan;

[0240] For each operator, the execution cost of the operator is determined based on the statistical information of the data to be processed by that operator.

[0241] Based on the execution costs of all operators in the execution plan, the initial execution cost of the execution plan is determined.

[0242] As an optional embodiment, when the strategy determination module determines the target strategy set that matches at least one of the two execution plans from the plurality of selected strategy sets, it is specifically used for:

[0243] For each selection strategy set, if there is only one sequence of operation operators that matches the selection strategy set, and if the sequence of operation operators corresponding to either of the two execution plans includes a sequence of operation operators that matches the selection strategy set, then the selection strategy set is taken as the target strategy set.

[0244] For each selection strategy set, if there are multiple operation operator sequences that match the selection strategy set, and the operation operator sequences corresponding to the two execution plans include operation operator sequences that match the selection strategy set, then the selection strategy set is taken as the target strategy set.

[0245] The apparatus of this disclosure embodiment can execute the method provided in this disclosure embodiment, and its implementation principle is similar, and it has corresponding technical effects. The actions performed by each module in the apparatus of each embodiment of this disclosure correspond to the steps in the method of each embodiment of this disclosure. For a detailed functional description of each module of the apparatus, please refer to the description in the corresponding method shown above, and it will not be repeated here.

[0246] This disclosure provides an electronic device including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the method provided in any optional embodiment of this disclosure. Compared with the prior art, the method of this disclosure generates multiple execution plans for a database operation instruction during execution, and determines a target strategy set that matches at least one execution plan from a set of multiple selection strategies used to select the execution plan. Each selection strategy set includes a plan determination strategy or an execution cost adjustment strategy. Based on the matching mechanism between the selection strategy set and the execution plan, the optimal execution plan is determined from the multiple execution plans based on the selection strategy in the target strategy set, and the database operation instruction is executed. This method is an automated way to determine the optimal execution plan, with low technical requirements and a low barrier to entry for users. Furthermore, the execution effect of database operation instructions based on the target execution plan determined in this disclosure is good.

[0247] This disclosure provides an electronic device including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a data processing method. Compared with related technologies, the method of this disclosure generates multiple execution plans for a database operation instruction during execution, and determines a target strategy set that matches at least one execution plan from a set of multiple selection strategies used to select the execution plan. Each selection strategy set includes a plan determination strategy or an execution cost adjustment strategy. Based on the matching mechanism between the selection strategy set and the execution plan, the optimal execution plan is determined from the multiple execution plans based on the selection strategy in the target strategy set, and the database operation instruction is executed. This method is an automated way to determine the optimal execution plan, with low technical requirements and a low barrier to entry for users. Furthermore, the execution effect of database operation instructions based on the target execution plan determined by this disclosure is good.

[0248] In one alternative embodiment, an electronic device is provided, such as Figure 12 As shown, Figure 12 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this disclosure.

[0249] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0250] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0251] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.

[0252] The memory 4003 is used to store computer programs that execute embodiments of the present disclosure, and is controlled by the processor 4001 to execute them. The processor 4001 is used to execute the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0253] Among them, electronic devices may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 12 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.

[0254] This disclosure provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program can implement the steps and corresponding content of the aforementioned method embodiments. Compared with the prior art, the method of this disclosure generates multiple execution plans for a database operation instruction during execution, and determines a target strategy set that matches at least one execution plan from a set of multiple selection strategies used to select the execution plan. Each selection strategy set includes a plan determination strategy or an execution cost adjustment strategy. Based on the matching mechanism between the selection strategy set and the execution plan, the optimal execution plan is determined from the multiple execution plans based on the selection strategy in the target strategy set, and the database operation instruction is executed. This method is an automated way to determine the optimal execution plan, with low technical requirements and a low barrier to entry for users. Furthermore, the execution effect of database operation instructions based on the target execution plan determined by this disclosure is good.

[0255] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium, a computer-readable medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0256] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments. Compared with the prior art, it can achieve the following: after generating multiple execution plans, multiple selection strategy sets for selecting execution plans are obtained, each selection strategy set including at least one matching operation operator sequence, so that the operation operator sequence matching each selection strategy set can be matched with multiple execution plans to determine a target strategy set that matches at least one execution plan among the multiple execution plans; by determining the target strategy set, at least one selection strategy in the target strategy set is determined. In this disclosure embodiment, each selection strategy is a plan determination strategy for determining the execution plan, or an adjustment strategy for adjusting the execution cost of the execution plan, wherein the plan determination strategy can indicate a low-cost execution plan to the database optimizer, and the execution cost adjustment strategy can correct or adjust the database optimizer's evaluation of the execution cost of multiple execution plans. By determining the target execution plan from multiple execution plans through the selection strategy in the target set, it is beneficial to improve the intelligence and robustness of the database optimizer in the execution plan selection process and reduce the risk of performance loss caused by incorrect selection. This embodiment of the disclosure optimizes the selection of execution plans by selecting strategies, without relying on manual prompts from users. This reduces manual intervention and the risk of human error, enabling the database system to dynamically determine the optimal execution path without manual intervention. Furthermore, it allows for the addition or deletion of selection strategy sets as needed, making it a pluggable solution with strong scalability, suitable for more complex and dynamic database execution environments.

[0257] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.

[0258] It should be understood that although arrows indicate various operation steps in the flowcharts of the embodiments of this disclosure, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of the embodiments of this disclosure, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured as required, and the embodiments of this disclosure do not limit this.

[0259] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of this disclosure.

Claims

1. A data processing method, characterized in that, include: Receive database operation instructions for a target data table, generate multiple execution plans for the database operation instructions, wherein each execution plan includes a sequence of operation operators, and the sequence of operation operators includes at least one database operation operator; Obtain multiple sets of selection strategies for selecting an execution plan, and at least one sequence of operation operators matching each set of selection strategies, each set of selection strategies including at least one selection strategy, each selection strategy being a plan determination strategy or an execution cost adjustment strategy; From the plurality of selection strategy sets, a target strategy set that matches at least one of the plurality of execution plans is determined; based on the selection strategy in the target strategy set, a target execution plan is determined from the plurality of execution plans; Based on the target execution plan, the database operation instructions are executed on the target data table.

2. The method according to claim 1, characterized in that, The step involves determining a target strategy set that matches at least one of the plurality of execution plans from the plurality of selection strategy sets. Based on the selection strategy in the target strategy set, a target execution plan is determined from the plurality of execution plans, including: Perform the following comparison operation on the multiple execution plans until all execution plans have participated in the comparison operation, and determine the execution plan retained in the last comparison operation as the target execution plan: Identify two execution plans from the plurality of execution plans that are participating in the current comparison operation, wherein at least one of the two execution plans has not participated in the comparison operation before; From the plurality of selection strategy sets, a target strategy set that matches at least one of the two execution plans is determined. Based on the selection strategy in the target strategy set, the execution plan to be retained is determined from the two execution plans. The currently retained execution plan and any execution plan that has not participated in the comparison operation are selected as the two execution plans to participate in the next comparison operation.

3. The method according to claim 2, characterized in that, If the selection strategy set includes a planning determination strategy, then the selection strategy set is matched with at least two operation operator sequences, and the determination strategy includes a selection method for determining a target operator sequence from the at least two operation operator sequences; The step of determining the execution plan to be retained from the two execution plans based on the selection strategy in the target strategy set includes: If the target strategy set includes a plan determination strategy, a target operator sequence is determined from at least two operation operator sequences that match the target strategy set, according to the selection method of the plan determination strategy. The execution plan that includes the target operator sequence in the two execution plans is selected as the execution plan to be retained. If the target strategy set includes an execution cost adjustment strategy, determine the initial execution cost corresponding to each of the two execution plans. Adjust the initial execution cost of the execution plan that matches the target strategy set according to the adjustment method of the execution cost adjustment strategy. If both execution plans match the target strategy set, select the execution plan with the lower adjusted execution cost as the execution plan to be retained. If only one of the two execution plans matches the target strategy set, determine the execution plan with the lower execution cost between the adjusted execution cost of the matching plan and the initial execution cost of the other execution plan as the execution plan to be retained.

4. The method according to claim 2 or 3, characterized in that, The step of determining the execution plan to be retained from the two execution plans based on the selection strategy in the target strategy set includes: Obtain the policy execution trigger condition corresponding to each selected policy in the target policy set; For each selection strategy in the target strategy set, if the two execution plans meet the strategy execution triggering condition of the selection strategy, the execution plan to be retained is determined from the two execution plans according to the selection strategy; The method further includes: If there is no selection strategy in the target strategy set that satisfies the strategy execution triggering conditions for the two execution plans, then based on the initial costs of the two execution plans, the execution plan with the lower execution cost is determined as the retained execution plan.

5. The method according to any one of claims 1-4, characterized in that, The step of receiving database operation instructions for a target data table and generating multiple execution plans for the database operation instructions includes: The database operation instruction is parsed to obtain the operation step sequence corresponding to the database operation instruction, and the operation operator corresponding to each step in the operation step sequence; Based on the sequence of operation steps, multiple generation operations are performed, wherein the multiple execution plans of the database operation instructions include the execution plan generated by the last generation operation; The initial generation operation includes: Select at least one of the earlier steps in the sequence of operation steps, and generate at least one execution plan for the first generation operation based on the operation operator corresponding to the at least one step. Non-first generation operations include: Based on at least one execution plan generated by the previous generation operation and the operation operator corresponding to at least one subsequent operation step of each operation step that has participated in the generation operation, generate at least one execution plan for the current generation operation.

6. The method according to claim 5, characterized in that, For non-first generation operations, the generation of at least one execution plan for the current generation operation includes: If multiple execution plans were generated in the previous generation operation, one execution plan is selected from the multiple execution plans generated in the previous generation operation; Based on the selected execution plan and the operation operator corresponding to at least one operation step after each operation step that has participated in the generation operation, at least one execution plan is generated for the current generation operation.

7. The method according to claim 6, characterized in that, When multiple execution plans were generated in the previous generation operation, selecting one execution plan from these multiple execution plans includes: For the multiple execution plans generated in the previous generation operation, a set of selection strategies that matches at least one of the multiple execution plans is determined from the multiple selection strategy sets; Based on the selection strategy in the determined selection strategy set, determine one of the execution plans on which the current sub-generation operation is based from the multiple execution plans.

8. The method according to claim 3 or 4, characterized in that, For each execution plan, the initial execution cost of the execution plan is determined in the following way: Obtain the data distribution information of the target data table, and determine the statistical information of the data to be processed corresponding to each operation operator in the execution plan based on the data distribution information; For each operation operator, the execution cost of the operation operator is determined based on the statistical information of the data to be processed by the operation operator. The initial execution cost of the execution plan is determined based on the execution costs of all operators in the execution plan.

9. The method according to any one of claims 2-4, characterized in that, The step of determining the target strategy set that matches at least one of the two execution plans from the plurality of selection strategy sets includes: For each selection strategy set, if there is only one sequence of operation operators that matches the selection strategy set, and if the sequence of operation operators corresponding to either of the two execution plans includes a sequence of operation operators that matches the selection strategy set, then the selection strategy set is taken as the target strategy set. For each selection strategy set, if there are multiple operation operator sequences that match the selection strategy set, and if the operation operator sequences corresponding to the two execution plans include operation operator sequences that match the selection strategy set, then the selection strategy set is taken as the target strategy set.

10. A data processing apparatus, characterized in that, include: The operation instruction receiving module is used to receive database operation instructions for a target data table and generate multiple execution plans for the database operation instructions, wherein each execution plan includes a sequence of operation operators, and the sequence of operation operators includes at least one database operation operator. The strategy acquisition module is used to acquire multiple sets of selection strategies for selecting an execution plan, and at least one sequence of operation operators matching each set of selection strategies. Each set of selection strategies includes at least one selection strategy, and each selection strategy is a plan determination strategy or an execution cost adjustment strategy. The strategy determination module is used to determine a target strategy set that matches at least one execution plan among the plurality of execution plans from the plurality of selection strategy sets; and to determine a target execution plan from the plurality of execution plans based on the selection strategies in the target strategy set. The execution operation instruction module is used to execute the database operation instructions on the target data table based on the target execution plan.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method according to any one of claims 1-9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-9.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-9.