Plan generation method and device

By replacing constant objects in a query tree with parameter objects in a distributed database and generating a parameterized query tree, the resource consumption problem caused by repeated query optimization is solved and the query execution efficiency is improved.

CN115577143BActive Publication Date: 2025-09-26ALIBABA CLOUD COMPUTING CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211171105.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2025-09-26
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

In distributed databases, repeated execution of query optimization processes leads to excessive consumption of computing resources, affecting overall performance. Existing technologies lack effective solutions.

Method used

Create a query tree by obtaining the query statement, replace constant objects with parameter objects and update their values ​​to generate a parameterized query tree. The tree is stored as the target query plan for reuse, avoiding repeated query optimization.

Benefits of technology

It improves the efficiency of query execution, reduces resource overhead, and optimizes the query processing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115577143B_ABST
    Figure CN115577143B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a plan generation method and apparatus, wherein the plan generation method includes: obtaining a query statement and creating a query tree corresponding to the query statement; when the query statement is a constant query statement, replacing the constant object in the query tree with a parameter object, and performing numerical update processing on the parameter object to obtain a target parameter object; recording the target parameter object in a parameter linked list, and creating a parameterized query tree based on the parameter linked list; generating a target query plan based on the parameterized query tree, and storing the plan in a target storage location.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of database technology, and in particular to a plan generation method and device. Background Art

[0002] With the development of internet technology, distributed databases have been applied as an important storage technology in various scenarios. Query optimization plays a connecting role in distributed databases. It is responsible for performing logical equivalence transformations on the query tree generated by syntax analysis and screening physical execution paths. It calculates the cost of each path based on statistical information, data distribution, and other information, thereby selecting the execution path with the lowest cost. In other words, query optimization is responsible for converting the query tree into a distributed query execution plan. This process is more complex and computationally intensive than that of a stand-alone database. If a SQL statement is executed repeatedly, the query optimization process will also be repeated multiple times, which not only consumes more computing resources but also affects the overall performance of the distributed database. Therefore, an effective solution is urgently needed to address this problem. Summary of the Invention

[0003] In view of this, embodiments of this specification provide a plan generation method. One or more embodiments of this specification also relate to a plan generation apparatus, a computing device, a computer-readable storage medium, and a computer program to address technical deficiencies in the prior art.

[0004] According to a first aspect of an embodiment of this specification, a plan generation method is provided, comprising:

[0005] Obtain a query statement and create a query tree corresponding to the query statement;

[0006] In the case where the query statement is a constant query statement, the constant object in the query tree is replaced with a parameter object, and the parameter object is numerically updated to obtain a target parameter object;

[0007] Record the target parameter object into a parameter linked list, and create a parameterized query tree according to the parameter linked list;

[0008] A target query plan is generated based on the parameterized query tree and stored in a target storage location.

[0009] According to a second aspect of the embodiments of this specification, there is provided a plan generating apparatus, comprising:

[0010] An acquisition module is configured to acquire a query statement and create a query tree corresponding to the query statement;

[0011] an updating module configured to, when the query statement is a constant query statement, replace the constant object in the query tree with a parameter object, and perform a numerical update process on the parameter object to obtain a target parameter object;

[0012] A creation module is configured to record the target parameter object into a parameter linked list and create a parameterized query tree according to the parameter linked list;

[0013] The generating module is configured to generate a target query plan based on the parameterized query tree and store the generated plan in a target storage location.

[0014] According to a third aspect of an embodiment of this specification, a computing device is provided, including:

[0015] memory and processor;

[0016] The memory is used to store computer-executable instructions, and the processor is used to implement any step of the above-mentioned plan generation method when executing the computer-executable instructions.

[0017] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned plan generation method are implemented.

[0018] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned plan generation method.

[0019] The plan generation method provided in this specification can create a reusable target query plan. After obtaining the query statement, a query tree corresponding to the query statement can be created. Then, if the query statement is a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the replaced parameter object can be numerically updated to obtain the target parameter object, thereby realizing parameterized transformation. After that, the target parameter object is recorded in a parameter linked list, and a parameterized query tree is created in combination with the parameter linked list of the written content. Then, the target query plan can be created according to the parameterized query tree and stored in the target storage location. The parameterized query plan is transformed and cached. This facilitates the reuse of the target query plan when the database is accessed again with a query statement of the same mode and containing constants, thereby avoiding the overhead of repeated query optimization for query statements containing constants and improving execution efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is a schematic diagram of a plan generation method provided by an embodiment of this specification;

[0021] Figure 2This is a flow chart of a plan generation method provided by one embodiment of this specification;

[0022] Figure 3 This is a process flow chart of a plan generation method provided by one embodiment of this specification;

[0023] Figure 4 This is a schematic diagram of the structure of a plan generation device provided by one embodiment of this specification;

[0024] Figure 5 This is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION

[0025] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0026] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0027] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0028] In this specification, a plan generation method is provided. This specification also relates to a plan generation device, a computing device, a computer-readable storage medium, and a computer program, which are described in detail one by one in the following embodiments.

[0029] In databases, query optimization is a crucial module that connects the preceding and subsequent parts. It is responsible for performing logical equivalence transformations on the query tree generated by syntax analysis, screening physical execution paths, calculating the cost of each path based on statistical information, and selecting the optimal execution path. In other words, query optimization converts the query tree into a query execution plan, a computationally intensive process. If a SQL statement is executed repeatedly, the query optimization process is also repeated multiple times, resulting in unnecessary performance loss. Caching the generated query execution plan can reduce query optimization overhead, but if the cached plan cannot be reused, not only will it fail to reduce query optimization overhead, but it will also lead to excessive memory consumption and overall performance degradation. Therefore, an effective solution is urgently needed to address this issue.

[0030] See also Figure 1 As shown in the schematic diagram, the plan generation method provided in this specification can create a reusable target query plan. After obtaining the query statement, a query tree corresponding to the query statement can be created. Then, when the query statement is a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the replaced parameter object can be numerically updated to obtain the target parameter object, thereby realizing parameterized transformation. After that, the target parameter object is recorded in the parameter linked list, and a parameterized query tree is created in combination with the parameter linked list of the written content. It is then possible to create a target query plan based on the parameterized query tree and store it in the target storage location. The parameterized query plan is transformed and cached. This facilitates the reuse of the target query plan when the database is accessed again by a query statement in the same mode and containing constants, thereby avoiding the overhead of repeated query optimization for query statements containing constants and improving execution efficiency.

[0031] Figure 2 A flow chart of a plan generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0032] Step S202: Obtain a query statement and create a query tree corresponding to the query statement.

[0033] The plan generation method provided in this embodiment is applied to the query optimization processing process of any type of database. In order to efficiently solve the performance loss caused by repeated query optimization processes, a processing method is adopted to extract and parameterize constants in the query tree, and a parameterized query tree is obtained as input for query optimization, which is used to generate a parameterized query execution plan, namely, a target query plan. The extracted constant values ​​are passed into the execution plan as parameters during execution to achieve the purpose of reusing the query execution plan, thereby saving resource overhead.

[0034] Based on this, before performing the transformation, it is necessary to first obtain the query statements used in the actual application scenario and create a query tree corresponding to the query statement, so that it can be parameterized and then the target query plan can be constructed. However, before this, considering that not all query statements can be used as transformation targets, there may be query statements that do not contain constants. Creating a query optimization execution plan for these query statements also needs to be implemented according to the standard processing method. In this embodiment, the specific implementation method is as follows:

[0035] The query tree is parameterized, and it is determined whether the query tree contains parameters based on the parameterization result; if not, a standard optimizer is called to create a standard query plan, and the standard query plan is stored in the target storage location; if so, if the query statement is a constant query statement, constant objects in the query tree are replaced with parameter objects, and the parameter objects are numerically updated to obtain a target parameter object.

[0036] Specifically, the standard optimizer is an optimizer that can create a query plan for any query statement. It is used to build query plans for non-parameterized queries. Correspondingly, a standard query plan is a query plan created for queries that do not contain parameters.

[0037] Based on this, after obtaining a query statement and creating its corresponding query tree, the query tree can be parameterized for processing. Based on the parameterization processing result, it is determined whether the query tree corresponding to the current query statement contains parameters. That is, it is detected whether the query tree contains constants. If so, the constants can be converted into parameters. If so, it indicates that the current query tree can be converted for subsequent parameterization to create a target query plan for reuse. At this time, step S204 is executed. That is, if the query statement is a constant query statement, the constant object in the query tree is replaced with a parameter object, and the parameter object is numerically updated to obtain the target parameter object.

[0038] If not included, it means that the current query tree cannot be modified. In order to create a query set with a unique correspondence, the standard optimizer can be called to create a standard query plan and store the standard query plan in the target storage location to achieve reuse of query statements with a unique correspondence.

[0039] For example, when creating a query plan for a SQL statement that does not contain constants and is not parameterized, after generating and parameterizing the query tree, it is possible to determine whether the query tree contains parameters. If not, the standard optimizer can be directly called to generate a standard execution plan for the SQL statement and record it in the plan cache. The parameterization process is responsible for determining whether the incoming query tree contains parameters. If not, the query tree does not need to be modified. Furthermore, if the SQL statement already contains parameters, it can be directly called to generate a parameterized query plan and record it in the plan cache without parameterization.

[0040] In summary, by determining the query statement type before processing, it is convenient to select an appropriate method to transform it, thereby creating a reusable query plan, improving query efficiency in the application stage, and saving query overhead.

[0041] Step S204 , when the query statement is a constant query statement, the constant object in the query tree is replaced with a parameter object, and the parameter object is numerically updated to obtain a target parameter object.

[0042] Specifically, after obtaining the query statement and creating its corresponding query tree, in order to create a highly reusable query plan, if the query statement is determined to be a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the parameter object can be numerically updated to obtain the target parameter object, thereby implementing parameterization processing at this stage and preparing for the subsequent creation of a query plan.

[0043] A constant query statement specifically refers to a query statement containing a constant value. Parameterizing such a query statement can generate a highly reusable query plan for use during query optimization. A constant object specifically refers to the const object in the query tree; a parameter object specifically refers to the param object. Value update processing specifically refers to the operation of assigning a value to a replaced parameter object; and a target parameter object specifically refers to the result obtained after the assignment.

[0044] Furthermore, when performing the redemption replacement, considering that the query tree contains a large number of constant objects, and each constant object needs to be replaced before it can be parameterized, it is necessary to replace them in sequence. In this embodiment, the specific implementation is as follows:

[0045] The query tree is traversed, and constant objects contained in the query tree are determined according to the traversal result; and the constant objects are replaced with parameter objects in sequence according to the execution order of the constant objects in the query tree.

[0046] Given this, and considering that queries must be executed sequentially, object replacement also needs to be done sequentially to avoid disrupting the order and preventing a reusable query plan. Therefore, by traversing the query tree, the constant objects contained in the query tree can be determined based on the traversal results. The execution order of the constant objects in the query tree can also be determined. All constant objects can then be replaced with parameter objects in that order. It should be noted that replacement must be performed according to the type of the constant object, meaning that the constant object and parameter object must have the same logical relationship before and after the replacement.

[0047] In summary, by replacing constant objects in the order of execution, it is possible to ensure that the replaced parameter objects are also sorted in order, thereby avoiding the inability to obtain a reusable query plan after the order is disrupted, thereby ensuring high reusability of the query.

[0048] Furthermore, after replacing the parameter object with the parameter object, it is necessary to assign a value to the parameter object to obtain the target parameter object. When assigning values, it is also necessary to implement it in order. In this embodiment, the specific implementation is as follows:

[0049] The parameter objects are marked in the execution order, and the constant values ​​associated with the constant objects are removed from the parameter objects in sequence according to the marking results; and the parameter objects with the constant values ​​removed are parameterized in sequence according to the marking results to obtain target parameter objects.

[0050] Specifically, the constant value of a constant object specifically refers to the value in the parameter object that has not been replaced. Based on this, the parameter objects are first marked in the execution order to assign an identifier to each parameter object according to the marking result. The identifier has a unique correspondence with the parameter object, and the marking is completed in sequence according to the execution order. Therefore, the constant value of the associated constant object can be removed from the parameter object in sequence according to the marking result. In other words, when replacing the parameter object, only the parameter is replaced, but the value is not changed. This stage is to support subsequent parameterization processing, so it is necessary to remove the constant value of the associated constant object in the parameter object, and then parameterize the parameter object with the constant value removed in sequence according to the execution order to obtain the target parameter object, that is, the target parameter object is obtained after the assignment processing operation.

[0051] In summary, by performing parameterized processing operations based on the execution order, parameters can be replaced and assigned in sequence, and parameterized processing can be completed while ensuring the execution order, so as to facilitate the subsequent generation of highly reusable query plans and save resource overhead.

[0052] Furthermore, when assigning values ​​to parameter objects that exclude constant values, considering that different constant objects correspond to different constant values, the functions and structures that can be implemented are also different, therefore, when assigning values ​​to different types of parameter objects, targeted processing is required. In this embodiment, the specific implementation is as follows:

[0053] (1) When the constant object is the first constant object associated with the query statement, a reference parameter is assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object.

[0054] Specifically, the first constant object refers to an object for which default parameters can be set; correspondingly, the baseline parameter refers to a preset default parameter, meaning that baseline parameters can be set for any constant object of this type. Based on this, if the constant object is the first constant object in the associated query statement, it can be assigned a default value to implement the assignment operation. Therefore, based on the labeling result, the parameter object excluding the constant value can be assigned the baseline parameter to obtain the target parameter object.

[0055] (2) When the constant object is the second constant object associated with the calling function and the calling function is a repeatedly executed function, the function parameters are calculated according to the calling function, and the function parameters are assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object.

[0056] Specifically, the second constant object refers to the object for which function parameters need to be set; correspondingly, the function parameters refer to the parameters calculated based on the function. Based on this, when the constant object is the second constant object associated with the calling function, and the calling function is a repeatedly executed function, assigning parameters to this type of constant object requires calculation in conjunction with the function. That is, the function parameters can be calculated based on the calling function, and the function parameters can be assigned to the parameter object excluding the constant value based on the labeling result to obtain the target parameter object.

[0057] (3) When the constant object is the third constant object associated with the calling function and the calling function is a non-repeated execution function, determine the replacement parameter corresponding to the calling function, and assign the replacement parameter to the parameter object excluding the constant value according to the marking result to obtain the target parameter object.

[0058] Specifically, the third constant object specifically refers to an object for which replacement parameters need to be set; correspondingly, the replacement parameters specifically refer to parameters determined based on the calling function. Based on this, if the constant object is the third constant object associated with the calling function, and the calling function is a non-repeated function, it means that assigning parameters to this type of constant object needs to be determined in conjunction with the function. Therefore, the replacement parameters corresponding to the calling function can be determined, and based on the labeling result, the replacement parameters can be assigned to the parameter object without the constant value to obtain the target parameter object.

[0059] It should be noted that the query tree may contain multiple constant objects, and there will also be multiple parameter objects after replacement, and each type may be different. Therefore, when assigning values, different assignment methods can be used for different parameter objects, that is, the above assignment operation can be selected according to actual needs, and this embodiment does not impose any restrictions here.

[0060] For example, if a query statement contains constant values, the query tree generated after SQL statement parsing is traversed to identify any const objects contained in the query tree. These const objects are then replaced with param objects, with param->paramkind marked as PARAM_EXTERN. Each param object is assigned a paramid based on the replacement order. During the replacement process, for query conditions where a=1 is present, the corresponding column constant value can be directly specified. If all function parameters are constant values ​​and the function is re-executed, the function value can be calculated as a replacement. If the function is not re-executed, the constant values ​​corresponding to the parameters are replaced, and the parameters are replaced in sequence.

[0061] In addition, when replacing, the const objects are replaced with param objects in sequence, and the param object describes the type and other information of the const, while the original const value is removed at the same time. The ParamExternData object, that is, the target parameter object, can be obtained according to the assignment result.

[0062] In summary, by assigning values ​​in different ways to different parameter objects to generate target parameter objects, it is possible to ensure parameterization processing without changing the original structure, so that the target query plan created subsequently has high reusability.

[0063] Step S206: Record the target parameter object into a parameter linked list, and create a parameterized query tree according to the parameter linked list.

[0064] Specifically, after obtaining the target parameter object as described above, the target parameter object can be further recorded in a parameter linked list. A parameterized query tree can then be created based on the parameter linked list, facilitating the subsequent creation and storage of a target query plan based on the parameterized query tree. The parameter linked list specifically refers to a linked list used to record the target parameter objects associated with the query statement. Accordingly, the parameterized query tree specifically refers to the query tree after parameterization.

[0065] Furthermore, considering that the query tree created directly based on the parameter linked list has relatively complex logic and structure, and requires high computing resources, if it is directly cached and reused, it may consume more computing resources. Therefore, in order to have the same function while simplifying the structure, the created query tree can be optimized. In this embodiment, the specific implementation is as follows:

[0066] An initial query tree is created according to the parameter linked list; query optimization processing is performed on the initial query tree, and the parameterized query tree is generated according to the optimization processing result.

[0067] Specifically, the initial query tree is created based on the parameter list. Query optimization involves performing logical and physical optimization on the initial query tree. Logical optimization replaces complex logic, while physical optimization optimizes the structure. Based on this, once the target parameter object is obtained, the initial query tree can be created based on the parameter list. Query optimization is then performed on the initial query tree, and the parameterized query tree is generated based on the optimization results.

[0068] Furthermore, when performing query optimization processing, the specific implementation method is as follows:

[0069] Performing logical optimization processing on the initial query tree to obtain an intermediate query tree, wherein the logical optimization processing is used to perform query logic conversion on the initial query tree; performing physical optimization processing on the intermediate query tree to generate the parameterized query tree based on the optimization processing result, wherein the physical optimization processing is used to update the query path of the intermediate query tree.

[0070] Specifically, query logic conversion refers to converting complex query logic into simple query logic. Correspondingly, query path update refers to replacing a query path with a complex structure with a query path with a simple structure, so as to save computing resources.

[0071] Based on this, during logical optimization, we can perform query logic replacement on the initial query tree to replace complex query logic with simple query logic, thereby generating an intermediate query tree. Physical optimization is then performed to update the complex query paths in the intermediate query tree to simple query paths, thereby generating a parameterized query tree.

[0072] For example, after recording the ParamExternData object in the paramList linked list, a parameterized query tree can be created based on the linked list after the recorded information. In order to ensure that the query plan generated subsequently is more concise, the parameterized query tree can be optimized through stanard_planner. The parameterized query tree can be logically transformed and the subquery can be promoted through the logical optimization strategy. The corresponding query path is generated for each table through the physical optimization strategy, and the connection path is generated according to the connection information. The cost is then calculated, and then the path with the minimum cost is obtained through dynamic programming or genetic algorithm, and an execution plan executable by the executor is generated.

[0073] In summary, by optimizing the query tree, we can effectively reduce the logical complexity and structural complexity, and realize the creation of subsequent target query plans through the simplified query tree, which can ensure that the created target query plans have lower costs and higher reuse rates.

[0074] Step S208: Generate a target query plan based on the parameterized query tree and store it in a target storage location.

[0075] Specifically, after obtaining the parameterized query tree as described above, a target query plan can be generated based on the target query tree and written to a target storage location, where the target storage location is the plan cache. This allows the query plan to be directly reused for query statements of the same pattern during the application phase, thereby reducing the resource overhead used for query optimization and improving query processing efficiency.

[0076] Furthermore, when storing the query plan, considering that it needs to be read during the application phase, a key-value pair can be created for caching. In this embodiment, the specific implementation is as follows:

[0077] An initial query plan is generated according to the parameterized query tree; the parameterized query tree is serialized, a query key is created according to the serialization result, and a query value is created according to the initial query plan; the target query plan is generated based on the query value and the query key, and is stored in the target storage location.

[0078] Specifically, the initial query plan refers to the query plan to be cached, and correspondingly, the serialization process refers to the processing operation of creating a key; correspondingly, the query key is the key required to use when reading the query plan, and correspondingly, the query value refers to the value required to use when storing the query plan.

[0079] Based on this, after obtaining the parameterized query tree, it means that the parameterization processing operation has been preliminarily completed, so the initial query plan can be generated according to the parameterized query tree; thereafter, the parameterized query tree is serialized to create a query key according to the serialization processing result, and the query value can be created according to the initial query plan; finally, the target query plan is generated based on the query value and query key, and stored in the target storage location.

[0080] Continuing with the previous example, after obtaining the parameterized query tree, the parameterized query tree can be serialized, and the query key of the query plan can be generated based on the processing result. The generated parameterized query plan is used as the value, and a PlanCacheEntry is generated and inserted into the plan cache. In the application phase, after determining the key, the corresponding value can be directly found to obtain the query plan for use.

[0081] In summary, by establishing key-value pairs to cache parameterized query plans, we can ensure their high reusability and avoid confusion caused by storing too many query plans. We can set key-value pairs separately for different types of query statements, facilitate the reading and use of query plans, and effectively improve query processing efficiency.

[0082] Furthermore, after receiving the user query statement, the query plan can be directly reused from the target storage location, and the parameters can be updated at the same time to read the target data at the data node. In this embodiment, the specific implementation method is as follows:

[0083] Receive a user query statement and determine a parameterized user query tree corresponding to the user query statement; read the target query plan at the target storage location according to the parameterized user query tree, and determine a user parameter linked list corresponding to the user query statement; and query data at a target data node based on the target query plan and the user parameter linked list.

[0084] Specifically, the user query statement refers to the query statement submitted by the user during the actual application phase; accordingly, the parameterized user query tree refers to the query tree constructed based on the user query statement. Accordingly, the target data node refers to the node that reads data in response to the user query statement.

[0085] Based on this, after receiving the user query statement, we can first determine the parameterized user query tree corresponding to the user query statement; read the target query plan at the target storage location according to the parameterized user query tree, and determine the user parameter linked list corresponding to the user query statement; then, based on the target query plan and the user parameter linked list, query the data at the target data node.

[0086] Furthermore, when querying data, it is actually necessary to plan the query based on the key-value pair and update based on the parameters. In this embodiment, the specific implementation is as follows:

[0087] A user query tree corresponding to the user query statement is created; the user query tree is parameterized to obtain the parameterized user query tree; the parameterized user query tree is serialized to create a user query key according to the serialization result; and the target query plan is read from the target storage location based on the user query key.

[0088] For example, after receiving a SQL statement submitted by a user, the SQL statement can be processed through parse analyze and rewrite to generate a query tree based on the processing results. The query tree is then parameterized to obtain a parameterized query tree and a parameter list corresponding to the query statement is extracted. The parameterized query tree is then serialized. The serialized value of the parameterized query tree can be used as a key to query the query plan in the cache based on the key to obtain a parameterized query plan. Finally, the parameter list and parameterized query plan are passed to the executor to perform data query processing.

[0089] In summary, by combining key-value pairs to perform query plans, it can be ensured that the query plan obtained corresponds to the query statement. Based on this, data reading can ensure that the read data is more accurate and meets user query needs.

[0090] The plan generation method provided in this specification can create a reusable target query plan. After obtaining the query statement, a query tree corresponding to the query statement can be created. Then, if the query statement is a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the replaced parameter object can be numerically updated to obtain the target parameter object, thereby realizing parameterized transformation. After that, the target parameter object is recorded in a parameter linked list, and a parameterized query tree is created in combination with the parameter linked list of the written content. Then, the target query plan can be created according to the parameterized query tree and stored in the target storage location. The parameterized query plan is transformed and cached. This facilitates the reuse of the target query plan when the database is accessed again with a query statement of the same mode and containing constants, thereby avoiding the overhead of repeated query optimization for query statements containing constants and improving execution efficiency.

[0091] The following combined Figure 3 , taking the application of the plan generation method provided in this specification in a database query scenario as an example, the plan generation method is further explained. Figure 3 A flowchart of a processing process of a plan generation method provided by an embodiment of this specification is shown, which specifically includes the following steps.

[0092] Step S302: Obtain a query statement and create a query tree corresponding to the query statement.

[0093] In a database, query optimization is a crucial module that connects the preceding and subsequent steps. It is responsible for performing logical equivalence transformations on the query tree generated by syntactic analysis, screening physical execution paths, calculating the cost of each path based on statistical information, and selecting the optimal execution path. In other words, query optimization converts the query tree into a query execution plan, a computationally intensive process. If a SQL statement is repeatedly executed, the query optimization process is also repeated multiple times, resulting in unnecessary performance loss. Caching the generated query execution plan can reduce query optimization overhead, but if the cached plan cannot be reused, not only does it fail to reduce query optimization overhead, it also leads to excessive memory consumption and overall performance degradation. Therefore, an effective solution is urgently needed to address this issue, specifically implemented in steps S302 to S332.

[0094] Step S304: if the query statement is a constant query statement, traverse the query tree and determine the constant objects included in the query tree according to the traversal result.

[0095] Step S306: replace the constant objects with parameter objects in sequence according to the execution order of the constant objects in the query tree.

[0096] Step S308 : Mark the parameter objects in the execution order, and remove the constant values ​​of the associated constant objects from the parameter objects in sequence according to the marking results.

[0097] Step S310 , parameterizing the parameter objects with constant values ​​removed in sequence according to the marking results to obtain target parameter objects.

[0098] Specifically, when the constant object is the first constant object associated with the query statement, the parameter object excluding the constant value is assigned a baseline parameter according to the marking result to obtain a target parameter object; when the constant object is the second constant object associated with the calling function, and the calling function is a repeatedly executed function, the function parameters are calculated according to the calling function, and the parameter object excluding the constant value is assigned a function parameter according to the marking result to obtain a target parameter object; when the constant object is the third constant object associated with the calling function, and the calling function is a non-repeatedly executed function, the replacement parameters corresponding to the calling function are determined, and the parameter object excluding the constant value is assigned a replacement parameter according to the marking result to obtain a target parameter object.

[0099] Step S312: record the target parameter object into the parameter linked list, and create an initial query tree according to the parameter linked list.

[0100] Step S314: perform logic optimization processing on the initial query tree to obtain an intermediate query tree, wherein the logic optimization processing is used to perform query logic conversion on the initial query tree.

[0101] Step S316 , performing physical optimization processing on the intermediate query tree, and generating a parameterized query tree according to the optimization processing result, wherein the physical optimization processing is used to update the query path of the intermediate query tree.

[0102] Step S318: Generate an initial query plan according to the parameterized query tree, and perform serialization processing on the parameterized query tree.

[0103] Step S320: Create a query key according to the serialization processing result, and create a query value according to the initial query plan.

[0104] Step S322: Generate a target query plan based on the query value and the query key, and store it in a target storage location.

[0105] Step S324: Receive a user query statement and create a user query tree corresponding to the user query statement.

[0106] Step S326: parameterize the user query tree to obtain a parameterized user query tree.

[0107] Step S328: Serialize the parameterized user query tree and create a user query key based on the serialization result.

[0108] Step S330 : reading a target query plan from a target storage location based on the user query key, and determining a user parameter linked list corresponding to the user query statement.

[0109] Step S332: query data at the target data node based on the target query plan and the user parameter linked list.

[0110] The plan generation method provided in this specification can create a reusable target query plan. After obtaining the query statement, a query tree corresponding to the query statement can be created. Then, if the query statement is a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the replaced parameter object can be numerically updated to obtain the target parameter object, thereby realizing parameterized transformation. After that, the target parameter object is recorded in a parameter linked list, and a parameterized query tree is created in combination with the parameter linked list of the written content. Then, the target query plan can be created according to the parameterized query tree and stored in the target storage location. The parameterized query plan is transformed and cached. This facilitates the reuse of the target query plan when the database is accessed again with a query statement of the same mode and containing constants, thereby avoiding the overhead of repeated query optimization for query statements containing constants and improving execution efficiency.

[0111] Corresponding to the above embodiment, this embodiment also provides another plan generation method, which includes:

[0112] Step S1, obtaining a query statement and creating a query tree corresponding to the query statement;

[0113] Step S2: if the query statement is a constant query statement, replace the constant object in the query tree with a parameter object, and perform a numerical update process on the parameter object to obtain a target parameter object;

[0114] Step S3, recording the target parameter object into a parameter linked list, and creating a parameterized query tree according to the parameter linked list;

[0115] Step S4, generating a target query plan based on the parameterized query tree and storing the plan in a target storage location;

[0116] Step S5: upon receiving a user query statement, reading a target query plan from a target storage location, and querying data according to the user query statement and the target storage location.

[0117] In one or more optional embodiments, replacing the constant object in the query tree with a parameter object includes:

[0118] The query tree is traversed, and constant objects contained in the query tree are determined according to the traversal result; and the constant objects are replaced with parameter objects in sequence according to the execution order of the constant objects in the query tree.

[0119] In one or more optional embodiments, performing a numerical update process on the parameter object to obtain a target parameter object includes:

[0120] The parameter objects are marked in the execution order, and the constant values ​​associated with the constant objects are removed from the parameter objects in sequence according to the marking results; and the parameter objects with the constant values ​​removed are parameterized in sequence according to the marking results to obtain target parameter objects.

[0121] In one or more optional embodiments, the step of performing parameterization processing on the parameter objects excluding constant values ​​according to the marking results to obtain the target parameter object includes:

[0122] In a case where the constant object is the first constant object associated with the query statement, the parameter object excluding the constant value is assigned a baseline parameter according to the marking result to obtain the target parameter object; in a case where the constant object is the second constant object associated with the calling function, and the calling function is a repeatedly executed function, function parameters are calculated according to the calling function, and the function parameters are assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object; in a case where the constant object is the third constant object associated with the calling function, and the calling function is a non-repeatedly executed function, replacement parameters corresponding to the calling function are determined, and the replacement parameters are assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object.

[0123] In one or more optional embodiments, creating a parameterized query tree according to the parameter linked list includes:

[0124] An initial query tree is created according to the parameter linked list; query optimization processing is performed on the initial query tree, and the parameterized query tree is generated according to the optimization processing result.

[0125] In one or more optional embodiments, performing query optimization processing on the initial query tree and generating the parameterized query tree according to the optimization processing result includes:

[0126] Performing logical optimization processing on the initial query tree to obtain an intermediate query tree, wherein the logical optimization processing is used to perform query logic conversion on the initial query tree; performing physical optimization processing on the intermediate query tree to generate the parameterized query tree based on the optimization processing result, wherein the physical optimization processing is used to update the query path of the intermediate query tree.

[0127] In one or more optional embodiments, generating a target query plan based on the parameterized query tree and storing the plan in a target storage location includes:

[0128] An initial query plan is generated according to the parameterized query tree; the parameterized query tree is serialized, a query key is created according to the serialization result, and a query value is created according to the initial query plan; the target query plan is generated based on the query value and the query key, and is stored in the target storage location.

[0129] In one or more optional embodiments, after the steps of obtaining a query statement and creating a query tree corresponding to the query statement are executed, the method further includes:

[0130] The query tree is parameterized, and it is determined whether the query tree contains parameters based on the parameterization result; if not, a standard optimizer is called to create a standard query plan, and the standard query plan is stored in the target storage location; if so, if the query statement is a constant query statement, constant objects in the query tree are replaced with parameter objects, and the parameter objects are numerically updated to obtain a target parameter object.

[0131] In one or more optional embodiments, after the step of generating a target query plan based on the parameterized query tree and storing the plan in a target storage location is executed, the method further includes:

[0132] Receive a user query statement and determine a parameterized user query tree corresponding to the user query statement; read the target query plan at the target storage location according to the parameterized user query tree, and determine a user parameter linked list corresponding to the user query statement; and query data at a target data node based on the target query plan and the user parameter linked list.

[0133] In one or more optional embodiments, determining the parameterized user query tree corresponding to the user query statement includes:

[0134] Creating a user query tree corresponding to the user query statement; parameterizing the user query tree to obtain the parameterized user query tree; correspondingly, reading the target query plan from the target storage location based on the parameterized user query tree, including: serializing the parameterized user query tree, creating a user query key based on the serialization result; and reading the target query plan from the target storage location based on the user query key.

[0135] It should be noted that another plan generation method provided in this embodiment corresponds to the plan generation method provided in the above embodiment. The same or corresponding description contents can be referred to the above embodiment, and this embodiment will not be elaborated in detail here.

[0136] This specification provides another plan generation method. In order to create a reusable target query plan, after obtaining the query statement, a query tree corresponding to the query statement can be created. Then, if the query statement is a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the replaced parameter object can be numerically updated to obtain the target parameter object, thereby realizing parameterized transformation. After that, the target parameter object is recorded in a parameter linked list, and a parameterized query tree is created in combination with the parameter linked list of the written content. This can realize the creation of a target query plan based on the parameterized query tree and store it in the target storage location. The parameterized query plan is transformed and cached. This facilitates the reuse of the target query plan when the database is accessed again with a query statement of the same mode and containing constants, thereby avoiding the overhead of repeated query optimization for query statements containing constants and improving execution efficiency.

[0137] Corresponding to the above method embodiment, this specification also provides a plan generation device embodiment, Figure 4 FIG. 1 shows a schematic diagram of a plan generating device provided by an embodiment of this specification. Figure 4 As shown, the device includes:

[0138] The acquisition module 402 is configured to acquire a query statement and create a query tree corresponding to the query statement;

[0139] An updating module 404 is configured to replace the constant object in the query tree with a parameter object when the query statement is a constant query statement, and perform a numerical update process on the parameter object to obtain a target parameter object;

[0140] A creation module 406 is configured to record the target parameter object into a parameter linked list and create a parameterized query tree according to the parameter linked list;

[0141] The generating module 408 is configured to generate a target query plan based on the parameterized query tree and store the target query plan in a target storage location.

[0142] In one or more optional embodiments, the updating module 404 is further configured to:

[0143] The query tree is traversed, and constant objects contained in the query tree are determined according to the traversal result; and the constant objects are replaced with parameter objects in sequence according to the execution order of the constant objects in the query tree.

[0144] In an optional embodiment, the updating module 404 is further configured to:

[0145] The parameter objects are marked in the execution order, and the constant values ​​associated with the constant objects are removed from the parameter objects in sequence according to the marking results; and the parameter objects with the constant values ​​removed are parameterized in sequence according to the marking results to obtain target parameter objects.

[0146] In one or more optional embodiments, the updating module 404 is further configured to:

[0147] In a case where the constant object is the first constant object associated with the query statement, the parameter object excluding the constant value is assigned a baseline parameter according to the marking result to obtain the target parameter object; in a case where the constant object is the second constant object associated with the calling function, and the calling function is a repeatedly executed function, function parameters are calculated according to the calling function, and the function parameters are assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object; in a case where the constant object is the third constant object associated with the calling function, and the calling function is a non-repeatedly executed function, replacement parameters corresponding to the calling function are determined, and the replacement parameters are assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object.

[0148] In one or more optional embodiments, the creation module 406 is further configured to:

[0149] An initial query tree is created according to the parameter linked list; query optimization processing is performed on the initial query tree, and the parameterized query tree is generated according to the optimization processing result.

[0150] In one or more optional embodiments, the creation module 406 is further configured to:

[0151] Performing logical optimization processing on the initial query tree to obtain an intermediate query tree, wherein the logical optimization processing is used to perform query logic conversion on the initial query tree; performing physical optimization processing on the intermediate query tree to generate the parameterized query tree based on the optimization processing result, wherein the physical optimization processing is used to update the query path of the intermediate query tree.

[0152] In one or more optional embodiments, the generating module 408 is further configured to:

[0153] An initial query plan is generated according to the parameterized query tree; the parameterized query tree is serialized, a query key is created according to the serialization result, and a query value is created according to the initial query plan; the target query plan is generated based on the query value and the query key, and is stored in the target storage location.

[0154] In one or more optional embodiments, the device further comprises:

[0155] The judgment module is configured to parameterize the query tree and determine whether the query tree contains parameters based on the parameterization result; if not, call the standard optimizer to create a standard query plan and store the standard query plan to the target storage location; if so, execute the update module 404.

[0156] In one or more optional embodiments, the device further comprises:

[0157] The query module is configured to receive a user query statement and determine a parameterized user query tree corresponding to the user query statement; read the target query plan at the target storage location according to the parameterized user query tree, and determine a user parameter linked list corresponding to the user query statement; and query data at a target data node based on the target query plan and the user parameter linked list.

[0158] In one or more optional embodiments, the query module is further configured to:

[0159] Creating a user query tree corresponding to the user query statement; parameterizing the user query tree to obtain the parameterized user query tree; correspondingly, reading the target query plan from the target storage location based on the parameterized user query tree, including: serializing the parameterized user query tree, creating a user query key based on the serialization result; and reading the target query plan from the target storage location based on the user query key.

[0160] The plan generation device provided in this specification can create a reusable target query plan. After obtaining the query statement, it can create a query tree corresponding to the query statement. Then, when the query statement is a constant query statement, the constant object in the query tree can be replaced with a parameter object, and the replaced parameter object can be numerically updated to obtain the target parameter object, thereby realizing parameterized transformation. After that, the target parameter object is recorded in the parameter linked list, and a parameterized query tree is created in combination with the parameter linked list of the written content. It is then possible to create a target query plan based on the parameterized query tree and store it in the target storage location. The parameterized query plan is transformed and cached. This facilitates the reuse of the target query plan when the database is accessed again with a query statement of the same mode and containing constants, thereby avoiding the overhead of repeated query optimization for query statements containing constants and improving execution efficiency.

[0161] The above is a schematic scheme of a plan generation device of this embodiment. It should be noted that the technical scheme of the plan generation device and the technical scheme of the plan generation method described above are of the same concept. For details not described in detail in the technical scheme of the plan generation device, please refer to the description of the technical scheme of the plan generation method described above.

[0162] Figure 5 The block diagram of a computing device 500 according to one embodiment of the present disclosure is shown. Components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and a database 550 is used to store data.

[0163] The computing device 500 also includes an access device 540 that enables the computing device 500 to communicate via one or more networks 560. Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of network interface (e.g., a network interface card (NIC)), whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0164] In one embodiment of the present specification, the above components of the computing device 500 and Figure 5 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 5 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.

[0165] Computing device 500 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. Computing device 500 can also be a mobile or stationary server.

[0166] The processor 520 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-mentioned plan generation method.

[0167] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned plan generation method are of the same concept. For details not described in detail in the technical scheme of the computing device, please refer to the description of the technical scheme of the above-mentioned plan generation method.

[0168] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned plan generation method.

[0169] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned plan generation method are based on the same concept. For details not described in detail in the technical scheme of the storage medium, please refer to the description of the technical scheme of the above-mentioned plan generation method.

[0170] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned plan generation method.

[0171] The above is a schematic scheme of a computer program of this embodiment. It should be noted that the technical scheme of the computer program and the technical scheme of the above-mentioned plan generation method are based on the same concept. For details not described in detail in the technical scheme of the computer program, please refer to the description of the technical scheme of the above-mentioned plan generation method.

[0172] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0173] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0174] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0175] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0176] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A plan generation method, comprising: Obtain a query statement and create a query tree corresponding to the query statement; In a case where the query statement is a constant query statement, the constant objects in the query tree are replaced with parameter objects in sequence according to the execution order, and the parameter objects are numerically updated to obtain a target parameter object, wherein the constant objects include a first constant object, a second constant object, and a third constant object, the parameter object after the first constant object is replaced is assigned a reference parameter, the parameter object after the second constant object is replaced is assigned a function parameter calculated according to a repeatedly executed function, and the parameter object after the third constant object is replaced is assigned a replacement parameter corresponding to a non-repeatedly executed function; Record the target parameter object into a parameter linked list, and create a parameterized query tree according to the parameter linked list; A target query plan is generated based on the parameterized query tree and stored in a target storage location.

2. The method according to claim 1, wherein replacing the constant object in the query tree with the parameter object comprises: Traversing the query tree, and determining constant objects contained in the query tree according to the traversal result; The constant objects are replaced with parameter objects in sequence according to the execution order of the constant objects in the query tree.

3. The method according to claim 2, wherein the step of performing numerical update processing on the parameter object to obtain the target parameter object comprises: Marking the parameter objects according to the execution order, and removing the constant values ​​associated with the constant objects from the parameter objects in sequence according to the marking results; According to the marking results, parameter objects with constant values ​​removed are parameterized in sequence to obtain target parameter objects.

4. The method according to claim 3, wherein the parameter objects with constant values ​​removed are parameterized in sequence according to the marking results to obtain the target parameter objects, comprising: In a case where the constant object is the first constant object associated with the query statement, assigning a reference parameter to the parameter object excluding the constant value according to the marking result to obtain the target parameter object; If the constant object is a second constant object associated with a calling function and the calling function is a repeatedly executed function, calculate function parameters according to the calling function, and assign the function parameters to the parameter object excluding the constant value according to the marking result to obtain the target parameter object; When the constant object is the third constant object associated with the calling function and the calling function is a non-repeatedly executed function, a replacement parameter corresponding to the calling function is determined, and the replacement parameter is assigned to the parameter object excluding the constant value according to the marking result to obtain the target parameter object.

5. The method according to claim 1, wherein creating a parameterized query tree according to the parameter linked list comprises: Creating an initial query tree according to the parameter linked list; Perform query optimization processing on the initial query tree, and generate the parameterized query tree according to the optimization processing result.

6. The method according to claim 5, wherein the performing query optimization processing on the initial query tree and generating the parameterized query tree according to the optimization processing result comprises: Performing logic optimization processing on the initial query tree to obtain an intermediate query tree, wherein the logic optimization processing is used to perform query logic conversion on the initial query tree; Performing physical optimization processing on the intermediate query tree, and generating the parameterized query tree according to the optimization processing result, wherein the physical optimization processing is used to update the query path of the intermediate query tree.

7. The method according to claim 1, wherein generating a target query plan based on the parameterized query tree and storing the plan in a target storage location comprises: generating an initial query plan according to the parameterized query tree; Serializing the parameterized query tree, creating a query key according to the serialization result, and creating a query value according to the initial query plan; The target query plan is generated based on the query value and the query key, and stored in the target storage location.

8. The method according to claim 1, after the steps of obtaining a query statement and creating a query tree corresponding to the query statement are performed, further comprising: Performing parameterization processing on the query tree, and determining whether the query tree contains parameters according to the parameterization processing result; If not, calling a standard optimizer to create a standard query plan, and storing the standard query plan in the target storage location; If so, executing the step of replacing the constant object in the query tree with a parameter object and performing a numerical update process on the parameter object to obtain a target parameter object when the query statement is a constant query statement.

9. The method according to claim 1, further comprising: after the step of generating a target query plan based on the parameterized query tree and storing the plan in a target storage location is executed: Receive a user query statement and determine a parameterized user query tree corresponding to the user query statement; Reading the target query plan at the target storage location according to the parameterized user query tree, and determining a user parameter linked list corresponding to the user query statement; Based on the target query plan and the user parameter linked list, data is queried at the target data node.

10. The method according to claim 9, wherein determining the parameterized user query tree corresponding to the user query statement comprises: Creating a user query tree corresponding to the user query statement; Performing parameterization processing on the user query tree to obtain the parameterized user query tree; Accordingly, reading the target query plan at the target storage location according to the parameterized user query tree includes: Serializing the parameterized user query tree and creating a user query key according to the serialization result; The target query plan is read in the target storage location based on the user query key.

11. A plan generating device comprising: An acquisition module is configured to acquire a query statement and create a query tree corresponding to the query statement; an updating module configured to, when the query statement is a constant query statement, sequentially replace constant objects in the query tree with parameter objects in an execution order, and perform numerical update processing on the parameter objects to obtain a target parameter object, wherein the constant objects include a first constant object, a second constant object, and a third constant object, the parameter object after the first constant object is replaced is assigned a baseline parameter, the parameter object after the second constant object is replaced is assigned a function parameter calculated according to a repeatedly executed function, and the parameter object after the third constant object is replaced is assigned a replacement parameter corresponding to a non-repeatedly executed function; A creation module is configured to record the target parameter object into a parameter linked list and create a parameterized query tree according to the parameter linked list; The generating module is configured to generate a target query plan based on the parameterized query tree and store the generated plan in a target storage location.

12. A computing device comprising: memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • A streaming transaction processing method and system

    CN109918391A

  • Query processing method and device, database system, electronic equipment and storage medium

    CN113076330A