Method, device and storage medium for analyzing function dependency set of an analysis operator

By analyzing the execution plan of the query statement, merging and replacement rules were used to process functional dependencies and clean up unrelated attributes. This solved the problem of high complexity in the functional dependency graph, reduced the complexity of the functional dependency set and graph, and improved query optimization efficiency.

CN116595041BActive Publication Date: 2026-01-02PINGCAP XINGCHEN (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310436444.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-21
Publication Date
2026-01-02
Estimated Expiration
2043-04-21

AI Technical Summary

Technical Problem

Existing technologies have high complexity when constructing function dependency graphs, and there is a lack of effective solutions to reduce this complexity.

Method used

By analyzing the execution plan of the query statement, the target operator is identified and its functional dependency set is updated. Functional dependencies are processed using merge and replacement rules, unrelated attributes are cleaned up, and a functional dependency graph is constructed.

Benefits of technology

It effectively reduces the complexity of the functional dependency set and functional dependency graph, reduces the number of functional dependencies and redundant attributes, and improves query optimization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116595041B_ABST
    Figure CN116595041B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a method, device and storage medium for analyzing function dependency set of an analysis operator, and relate to the technical field of databases. The method comprises: determining a first function dependency generated when a relation expression executed by a target operator from an execution plan of a query statement, determining a target processing rule according to a dependency type of the function dependency, and updating the first function dependency to an initial set of the target operator according to the target processing rule to obtain an intermediate set; cleaning attributes irrelevant to the expression executed by the target operator in the intermediate set to obtain a function dependency set of the target operator. The scheme shown in the embodiments of the present application uses improvement means such as merging, replacing and cleaning, so that the complexity of the finally obtained function dependency set is effectively reduced, and accordingly, the complexity of a function dependency graph constructed based on the function dependency set is also effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, in particular, the present application relates to a method, device and equipment for analyzing function dependency set of an operator and a storage medium. BACKGROUND

[0002] Traditional databases are too implicit in the description and implementation of function dependencies. As for open-source database MySQL, due to the disordered code of related function dependencies and the deep coupling with function code, it cannot be used as a separate module for the optimizer to do other things.

[0003] To solve the above problems, a technical solution recorded in a paper entitled "Exploiting Functional Dependence in Query Optimization" (hereinafter referred to as "EGDQO") is based on the definition of extended function function dependency, and the description and implementation process of function dependency is clear. Among them, the new extended concept can completely express the key defined by ANSI SQL, as well as the changes of function dependencies introduced by query predicates and outer joins. In this scheme, the constraints of each SQL algebraic operator are formalized and proved, and the reasoning formula of extended function dependency / equality constraint / NULL constraint is proposed. In addition, the scheme also defines a model, and the function dependency graph constructed according to each function dependency.

[0004] However, since the model stipulates that the vertices of each edge in the function dependency graph are single attribute vertices, when the type and number of function dependencies are complex, the complexity of the constructed function dependency graph will be deepened.

[0005] At present, there is a lack of a scheme to reduce the complexity of the function dependency graph. SUMMARY

[0006] The embodiments of the present application provide a method, device and equipment for analyzing function dependency set of an operator and a storage medium from the following aspects, which can solve one of the above technical problems.

[0007] In one aspect, the embodiments of the present application provide a method for analyzing function dependency set of an operator, which comprises:

[0008] The semantic analysis is performed on the query statement to obtain an execution plan, the execution plan comprising at least two operators, each operator executing a relational expression in the query statement. Any one of the at least two operators is taken as a target operator, and if the relational expression executed by the target operator is nested with the relational expressions executed by other operators in the at least two operators, a union set of function dependency sets of the other operators is taken as an initial set of the target operator. Any function dependency generated in the execution process is taken as a first function dependency by executing the corresponding relational expression by the target operator, and a dependency type of the first function dependency is determined, the function dependency comprising a first attribute set storing decision attributes in the function dependency and a second attribute set storing dependent attributes in the function dependency. For each first function dependency, a processing rule associated with the dependency type of the first function dependency is determined as a target processing rule, the first function dependency is updated to the initial set according to the target processing rule, and an intermediate set of the target operator is obtained. Attributes irrelevant to the relational expression executed by the target operator in the intermediate set of the target operator are cleaned up, and the cleaned-up intermediate set is taken as a function dependency set of the target operator, and a function dependency graph of the target operator is constructed according to the function dependency set of the target operator.

[0009] Optionally, the processing rule associated with the dependency type of the first function dependency comprises a merging rule; the merging rule comprises: determining a second function dependency matching the first function dependency in the initial set, and merging the first function dependency into the second function dependency.

[0010] The processing rule associated with the dependency type of the first function dependency is determined as the target processing rule, the first function dependency is updated to the initial set according to the target processing rule, and the intermediate set of the target operator is obtained, comprising: the target processing rule is determined as the merging rule. The initial set obtained after the merging rule is executed is taken as the intermediate set.

[0011] Optionally, the processing rule associated with the dependency type of the first function dependency comprises a replacement rule; the replacement rule comprises: determining a third function dependency matching the first function dependency in the initial set, and replacing the third function dependency with the first function dependency.

[0012] The processing rule associated with the dependency type of the first function dependency is determined as the target processing rule, the first function dependency is updated to the initial set according to the target processing rule, and the intermediate set of the target operator is obtained, comprising: the target processing rule is determined as the replacement rule. The initial set obtained after the replacement rule is executed is taken as the intermediate set.

[0013] Optionally, the processing rule associated with the dependency type of the first function dependency comprises the replacement rule and the merging rule.

[0014] The processing rule associated with the dependency type of the first function dependency is determined as a target processing rule, and the first function dependency is updated to the initial set according to the target processing rule, so that an intermediate set of the target operator is obtained, including: determining the target processing rule as a merge rule and a replacement rule; and sequentially executing the merge rule and the replacement rule, and taking the initial set obtained after executing the replacement rule as the intermediate set.

[0015] Optionally, the dependency type includes a constant function dependency, the first attribute set of the constant function dependency is empty, and the second attribute set of the constant function dependency is non-empty; and the processing rule associated with the constant function dependency only includes the merge rule.

[0016] If the dependency type of the first function dependency is a constant function dependency, the second function dependency matched with the first function dependency satisfies the following conditions: the dependency type of the second function dependency is consistent with the dependency type of the first function dependency.

[0017] Optionally, the dependency type includes an equality dependency, and the processing rule associated with the equality dependency includes the merge rule.

[0018] If the dependency type of the first function dependency is an equality dependency, the second function dependency matched with the first function dependency satisfies the following conditions: the dependency type of the second function dependency is consistent with the dependency type of the first function dependency; the first attribute set of the second function dependency is equal to the second attribute set of the first function dependency, and the second attribute set of the second function dependency is equal to the first attribute set of the first function dependency.

[0019] Optionally, after the first function dependency is merged into the second function dependency, the method further includes:

[0020] A fourth function dependency matched with the second function dependency is obtained from the initial set, and the fourth function dependency is merged into the second function dependency; wherein the dependency type of the fourth function dependency is an equality dependency; the two attribute sets of the fourth function dependency are equal, and the intersection of the first attribute set of the fourth function dependency and the first attribute set of the second function dependency is non-empty.

[0021] Optionally, the dependency type includes a weak function dependency or a weak equality dependency, and the processing rule associated with the weak function dependency or the weak equality dependency includes the replacement rule.

[0022] If the dependency type of the first function dependency is any one of a weak function dependency or a weak equality dependency, the third function dependency matched with the first function dependency satisfies the following conditions: the dependency type of the third function dependency is consistent with the dependency type of the first function dependency; the second attribute set of the third function dependency and the second attribute set of the first function dependency are equal; there is a first inclusion relationship between the first attribute set of the third function dependency and the first attribute set of the first function dependency, and the function dependency associated with the true subset in the first inclusion relationship is the first function dependency.

[0023] Optionally, the dependency type further includes a strong functional dependency, and the processing rule associated with the strong functional dependency includes a replacement rule.

[0024] If the dependency type of the first functional dependency is a strong functional dependency, the third functional dependency matched with the first functional dependency satisfies the following conditions:

[0025] The dependency type of the third functional dependency is consistent with the dependency type of the first functional dependency, the second attribute set of the third functional dependency is equal to the second attribute set of the first functional dependency, and there is a second inclusion relationship between the first attribute set of the third functional dependency and the first attribute set of the first functional dependency, and the functional dependency associated with the true subset in the second inclusion relationship is the first functional dependency.

[0026] Or,

[0027] The dependency type of the third functional dependency is consistent with the dependency type of the first functional dependency, the first attribute set of the third functional dependency is equal to the first attribute set of the first functional dependency, there is a third inclusion relationship between the second attribute set of the third functional dependency and the second attribute set of the first functional dependency, and the functional dependency associated with the true subset in the third inclusion relationship is the second functional dependency.

[0028] Optionally, the dependency type includes a strong equality dependency, a weak equality dependency, a strong functional dependency, or a weak functional dependency, the processing rule associated with the strong equality dependency, the weak equality dependency, the strong functional dependency, or the weak functional dependency includes a replacement rule, and each dependency type has a level; the dependency types in order from high to low are: the strong equality dependency, the weak equality dependency, the strong functional dependency, and the weak functional dependency.

[0029] If the dependency type of the first functional dependency is any one of a strong equality dependency, a weak equality dependency, and a strong functional dependency, the third functional dependency matched with the first functional dependency satisfies the following conditions: compared with the level of the dependency type of the first functional dependency, the level of the dependency type of the third functional dependency is lower; the first attribute set of the third functional dependency is equal to the first attribute set of the first functional dependency, and the second attribute set of the third functional dependency is equal to the second attribute set of the first functional dependency.

[0030] Optionally, the attributes in the intermediate set of the cleaning target operator that are irrelevant to the relationship expression executed by the target operator are cleaned, including:

[0031] Determine the attribute universal set of the relationship expression in the target operator; derive other functional dependencies implied by the intermediate set based on the attribute universal set, and add the other functional dependencies to the intermediate set; clean the attributes in the intermediate set that are not in the attribute universal set; wherein, for each functional dependency in the intermediate set, if at least one attribute set of the functional dependency is empty, the functional dependency is cleaned from the intermediate set.

[0032] Optionally, the derivation of the other functional dependencies implied by the intermediate set based on the attribute universal set includes:

[0033] For each function dependency in the intermediate set, if the intersection of at least one set of the function dependency and the attribute set is non-empty, a fifth function dependency is obtained according to the function dependency. The level of the dependency type of the fifth function dependency is lower than that of the function dependency, and the first attribute set and the second attribute set of the fifth function dependency are equal to those of the function dependency. Other function dependencies contained in the intermediate set are derived according to the preset axiom and the fifth function dependency, and the fifth function dependency is taken as the other function dependencies contained in the intermediate set.

[0034] In another aspect, the embodiment of the present application further provides a device for analyzing function dependency sets of operators, which comprises:

[0035] A statement analysis module is configured to perform semantic analysis on the query statement to obtain an execution plan, and the execution plan comprises at least two operators, each of which executes a relational expression in the query statement.

[0036] A first determination module is configured to take any one of the at least two operators as a target operator, and if the relational expression executed by the target operator is nested with the relational expressions executed by other operators in the at least two operators, then the union of the function dependency sets of the other operators is taken as the initial set of the target operator.

[0037] A second determination module is configured to take any function dependency generated in the execution process as a first function dependency by executing the corresponding relational expression by the target operator, and determine the dependency type of the first function dependency. The function dependency is associated with a first attribute set storing the determining attribute in the function dependency and a second attribute set storing the dependent attribute in the function dependency.

[0038] An updating module is configured to, for each first function dependency, determine the processing rule associated with the dependency type of the first function dependency as a target processing rule, and update the first function dependency to the initial set according to the target rule to obtain the intermediate set of the target operator.

[0039] A cleaning module is configured to clean the attributes in the intermediate set of the target operator that are irrelevant to the relational expression executed by the target operator, and take the cleaned intermediate set as the function dependency set of the target operator.

[0040] The embodiment of the present application further provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method for analyzing the function dependency sets of operators provided by the embodiment of the present application.

[0041] The embodiment of the application further provides a computer readable storage medium, which stores a computer program, and the computer program is characterized in that when the computer program is executed by a processor, the steps of the method for analyzing a function dependency set of an operator are implemented.

[0042] The technical scheme provided by the embodiment of the application has the beneficial effects that:

[0043] After the semantic analysis of the query statement is performed to obtain the execution plan, any operator in the execution plan can be taken as a target operator, and if it is determined that the target operator executes a relational expression nested with other operators, the function dependency set of the other operators is taken as an initial set of the target operator, and then the target operator executes the corresponding relational expression. If a new function dependency is generated in the execution process, the new function dependency is taken as a first function dependency, the target processing rule of how to update the first function dependency to the initial set is determined based on the dependency type of the first function dependency, and the first function dependency is updated to the initial set based on the target processing rule to obtain an intermediate set. Further, the attributes in the intermediate set that are irrelevant to the relational expression of the target operator are cleaned up to obtain the function dependency set of the target operator, and the function dependency graph of the target operator is constructed through the function dependency set.

[0044] On the one hand, the related art directly uses a dependent attribute to associate only one decision attribute to represent a function dependency when defining a newly added function dependency, which leads to the fact that the function dependency set of each operator is very complex due to the existence of many function dependencies. For this problem, the scheme shown in the application proposes a new definition method for the newly added function dependency: one function dependency is associated with a first attribute set storing decision attributes and a second attribute set storing dependent attributes, so that one function dependency can contain multiple function dependencies, thereby effectively reducing the number of function dependencies that need to be maintained by the function dependency set, and further reducing the complexity.

[0045] On the other hand, since the target processing rule includes at least one of the merging rule and the replacement rule, when the first function dependency is updated to the initial set, the first function dependency can be added by the way of "merging" or "replacing", instead of the way of directly adding a function dependency to the set to realize the adding operation in the related art. This way can also compress the number of function dependencies in the initial set, that is, further reduce the complexity.

[0046] Finally, since the deletion of the irrelevant attributes in the functional dependency in the related art, the irrelevant attributes are only taken as virtual attributes, and all the attributes of the original functional dependency are still maintained, which leads to that the functional dependency set still maintains a lot of "redundant" attributes and functional dependencies. In the scheme shown in the present application, the attributes irrelevant to the relationship expression executed by the target operator in the set are cleaned up, and the "redundant" attributes and functional dependencies can be further cleaned up, and the complexity is also reduced, and the effect is most obvious.

[0047] The scheme shown in the embodiments of the present application improves the related art from the above three aspects, so that the complexity of the finally obtained functional dependency set is effectively reduced. Further, the functional dependency graph is created by obtaining the functional dependency set, and the complexity is effectively reduced. BRIEF DESCRIPTION OF DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced.

[0049] Figure 1 A functional dependency graph for a related art functional dependency set of an analysis operator;

[0050] Figure 2 A flowchart of a method for analyzing a functional dependency set of an analysis operator provided by the embodiments of the present application;

[0051] Figure 3 A flowchart of an execution plan of a query statement provided by the embodiments of the present application;

[0052] Figure 4a A functional dependency graph of a functional dependency set obtained by the method for analyzing a functional dependency set of an analysis operator provided by the embodiments of the present application;

[0053] Figure 4b A functional dependency graph of a Datasource operator in an execution plan of a query statement provided by the embodiments of the present application;

[0054] Figure 4c A functional dependency graph of a Projection1 operator in an execution plan of a query statement provided by the embodiments of the present application;

[0055] Figure 4d A functional dependency graph of an Aggregation operator in an execution plan of a query statement provided by the embodiments of the present application;

[0056] Figure 4e A functional dependency graph of a Projection2 operator in an execution plan of a query statement provided by the embodiments of the present application;

[0057] Figure 5Another structure diagram of an execution plan example provided by an embodiment of the present application is shown in FIG. 2.

[0058] Figure 6 A structure diagram of a device for analyzing a function dependency set of an operator provided by an embodiment of the present application is shown in FIG. 3.

[0059] Figure 7 A structure diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 4. DETAILED DESCRIPTION

[0060] Embodiments of the present application will be described below in conjunction with the accompanying drawings. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions of the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0061] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms "a", "an" and "the" used herein can also include the plural forms. It should be further understood that the terms "comprise" and "include" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the present technology. It should be understood that when we say that an element is "connected" or "coupled" to another element, the element can be directly connected or coupled to the other element, or can mean that the element and the other element are connected through an intermediate element. In addition, "connected" or "coupled" used herein can include wireless connection or wireless coupling. The term "and / or" used herein means that at least one of the items defined by the term, for example, "A and / or B" means that "A" is implemented, or "A" is implemented, or "A and B" are implemented.

[0062] In order to make the purposes, technical solutions and advantages of the present application clearer, the embodiments of the present application will be described in further detail below in conjunction with the accompanying drawings.

[0063] First, several terms related to the present application are introduced and explained:

[0064] Execution plan: after semantic analysis of a query statement, an executable flow obtained. The analysis process of a query statement mainly includes 8 steps:

[0065] 1) SQL lexical analysis and syntax analysis;

[0066] 2) Abstract Syntax Tree (AST) formation;

[0067] 3) verification check;

[0068] 4) AST to relational algebra expression;

[0069] 5) Generating a logical plan from the relational algebra expression;

[0070] 6) Optimizer processing the logical plan and generating an optimal plan;

[0071] 7) Generating a physical plan from the optimal plan;

[0072] 8) Finally, the execution engine executes the physical plan and returns the result.

[0073] Functional dependency (FD): A constraint between two sets of column attributes in a relation in a database. Given a relation R, a set of attributes X on R functionally determines a set of attributes Y on R (denoted as X→Y) if and only if each X value on R is associated with exactly one Y value on R; thus, R is said to satisfy the functional dependency X→Y. In addition, the functional dependency analysis in the ANSI SQL relational model is complicated by the presence of null values, operators that contain null values, outer joins, and duplicate rows.

[0074] Functional dependency graph: A graph constructed from a set of functional dependencies. Each functional dependency in the set corresponds to an "edge" in the functional dependency graph, and the two vertices of the edge correspond to the dependent and determining attributes of the functional dependency, respectively. For example, the start vertex of the edge corresponds to the determining attribute, and the end vertex of the edge corresponds to the dependent attribute.

[0075] Currently, the paper "Exploiting Functional Dependence in Query Optimization" extends the definition of functional dependencies to include concepts such as strict / lax functional dependencies (i.e., strong functional dependencies / weak functional dependencies), strict / lax equality dependencies (i.e., strong equality dependencies / weak equality dependencies), and null dependencies. These concepts can fully express the changes in functional dependencies introduced by ANSI SQL-defined keys, query predicates, and outer joins. The paper formalizes and proves the constraints of each SQL algebraic operator and proposes inference formulas for these extended functional dependencies / equality constraints / null constraints. Based on this, the paper also defines an extended functional dependency graph model to represent the above constraints, presents, and proves a polynomial algorithm for maintaining the FD graph for each algebraic operator.

[0076] In the paper, the solution is mainly improved for the abstract syntax tree obtained after the third step of the above eight steps, which includes building a function dependency graph based on the abstract syntax tree.

[0077] Figure 1 A function dependency graph of a set of function dependencies built according to the solution in the paper is shown.

[0078] The set of function dependencies is: A->BCD, D->E, BCE->F and CE->H. Taking A->BCD as an example, the function dependency graph records the function dependency through 3 "edges" (A->B, A->C, A->D respectively), and A is the determinant attribute, and B, C and D are dependent attributes respectively.

[0079] In order to continue the background art, an example of a query statement in a MySQL database is used to illustrate how the prior art analyzes function dependencies. In this example, the table t includes attributes e and f, denoted as t.e and t.f respectively. The query statement example is shown as follows:

[0080] select d.a, d.b from (select t.e*2 as a, t.e as b from t) d group by d.b;

[0081] This example provides a traditional function dependency analysis method, which uses a logical query block as a unit and uses a chained group_check structure for tracking. First, some basic FDs are constructed from the basic elements of the outermost query block and placed into a new group_check (group_by, key, where and join, etc.). In this example, d.b->d.b is determined first, and then the analysis of the outer query block is completed. Second, a new group_check structure is constructed for the subquery, and the FDs in the previous analysis can also be inherited; in this example, in the group_check structure of the subquery, d.b and t.b are renamed t.e, so there is an equality dependency t.b==d.b==t.e. In addition, t.a is a renamed column of t.e*2, t.e->t.a, and d.a is a renamed column of t.a, so the function dependency t.a==d.a can be generated.

[0082] When the group_check of the recursive subquery is constructed, the function dependencies of the query as a whole are obtained as follows: d.b->t.a, t.a==d.a, and finally d.b->d.a.

[0083] This example also provides a function dependency graph of the example built by the method shown in the related art, which includes the following function dependency relationships.

[0084] d.b----strict_equiv_FD---->t.b; / / strict_equiv_FD, strong equivalent dependency

[0085] t.a----strict_FD---->t.b; / / strict_FD, strong functional dependency

[0086] t.a----strict_equiv_FD---->d.a

[0087] In addition, lax_equiv_FD identifies weak equivalent dependency; lax_FD identifies weak functional dependency; constant_FD identifies constant functional dependency; and null_FD identifies null dependency.

[0088] In addition, the example also provides a set of functional dependency sets, and constructs a functional dependency graph by the method shown in the related art.

[0089] Application of the functional dependency analysis result, at an external user level, is mainly to make the design mode of the schema decomposition table mode maintain a reasonable normal form, to avoid redundancy of stored information and complication of relational structure. At an internal database optimization level, by analyzing the operators in the execution plan of the base table, join, where, group, etc. constituting a query, only-full-group-by checking, selection degree estimation, result and intermediate set size estimation, order elimination and cost estimation, etc. can be performed in the execution stage of the execution plan by using the functional dependency.

[0090] Therefore, obtaining a functional dependency graph with higher "quality" can solve many problems, whether from an external user level or an internal database optimization level.

[0091] To achieve the purpose, the embodiment of the present application proposes a method for analyzing functional dependency sets of operators. In the method, in the fifth step of analyzing a query statement, a preliminary execution plan is obtained, and analysis is performed for each operator in the execution plan, and finally the functional dependency sets of each operator are obtained, and a functional dependency graph is obtained through the functional dependency sets.

[0092] The technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application will be described through the description of several exemplary embodiments. It should be noted that the following embodiments can be mutually referenced, borrowed or combined. For the same terms, similar features and similar implementation steps in different embodiments, they will not be described repeatedly.

[0093] Figure 2An optional embodiment of a method for analyzing a function dependency set of an operator is shown. The method includes steps S210-S250.

[0094] S210, semantic analysis of the query statement to obtain an execution plan, the execution plan including at least two operators, each operator executing a relational expression in the query statement.

[0095] Specifically, after receiving the query statement, semantic analysis of the query statement can sequentially obtain an abstract syntax tree, a relational algebra expression converted from the abstract syntax tree, a logical execution plan generated from the relational algebra expression, and a physical execution plan. The execution plan referred to in the embodiments of the present application is the logical execution plan generated in the fifth step of the analysis steps.

[0096] In one example, Figure 3 An execution plan for the above SQL statement example is shown. In this example, the execution plan includes four operators, wherein the subquery (e.g., select t.e*2as a, t.eas b from t) is converted into a DataSource (DataSource is an identifier of an operator and is used to represent the operator, the following descriptions are the same), and a Projection1; the recursive query (i.e., … group by…) is converted into an Aggregation; and the outer query (i.e., select d.a, d.b from…) is converted into a Projection2.

[0097] S220, taking any one of the at least two operators as a target operator, if the relational expression executed by the target operator is nested with the relational expression executed by other operators in the at least two operators, then the union set of the function dependency sets of the other operators is taken as the initial set of the target operator.

[0098] Optionally, the target operator can be any operator in the execution plan; the target operator can be an operator determined by a user through a click operation; and the number of target operators can be one or more.

[0099] In the example shown, the target operator is determined to be the Projection2, and then the function dependency set of the Aggregation can be taken as the initial set. Figure 3

[0100] S230, executing the corresponding relational expression through the target operator, taking any function dependency generated in the execution process as a first function dependency, and determining the dependency type of the first function dependency, the function dependency being associated with a first attribute set storing the determining attribute in the function dependency and a second attribute set storing the dependent attribute in the function dependency.

[0101] ​In describing a functional dependency, either end of the functional dependency can be a set of attributes according to the present application, and based on the set of attributes, the operations of merging and replacing are implemented on the functional dependency.

[0102] In one example, a functional dependency can be defined in the following manner:

[0103]

[0104] For a strong equality dependency FD1: A == BC, if the strong equality dependency is maintained by using the structure, the following relationship can be obtained.

[0105] FD1 = {set1 = [A]; set2 = [C]; FD_type = "strict_equiv_FD";}

[0106] In addition, FD1 can also be described in the following simplified manner: {A} == {B, C}.

[0107] In one example, there is a set of functional dependencies X, and the following functional dependencies exist in the set of functional dependencies: A -> BCD, D -> E, BCE -> F, and CE -> H.

[0108] In this example, if a functional dependency graph is constructed for X based on the functional dependencies defined in the paper, the functional dependency graph is as shown in Figure 1 That is, when maintaining X, 11 functional dependencies need to be maintained, specifically: {A -> B, A -> C, A -> D, D -> E, BCE -> F, BCE -> B, BCE -> C, BCE -> E, CE -> H, CE -> C, CE -> E}.

[0109] In this example, if a functional dependency graph is constructed for X based on the functional dependencies defined in the present application, the functional dependency graph is as shown in Figure 4a In addition, when maintaining X, only 4 functional dependencies need to be maintained, specifically: {A -> BCD, D -> E, BCE -> F, CE -> H}.

[0110] Therefore, by using the manner provided in the embodiments of the present application to define functional dependencies, the number of functional dependencies that need to be maintained can be greatly reduced.

[0111] S240, for each first functional dependency, determining a processing rule associated with the dependency type of the first functional dependency as a target processing rule, and updating the first functional dependency to the initial set according to the target processing rule to obtain an intermediate set of the target operator.

[0112] S250, clean the attributes in the intermediate set of the target operator which are irrelevant to the relational expression executed by the target operator, and take the cleaned intermediate set as the function dependency set of the target operator, and construct the function dependency graph of the target operator according to the function dependency set of the target operator.

[0113] The scheme shown in the embodiments of the present application improves the related art from three aspects, so that the complexity of the finally obtained function dependency set is effectively reduced. Further, the function dependency graph is created by the function dependency set, and the complexity of the function dependency graph is also reduced.

[0114] Next, the embodiments of the present application will specifically describe how the scheme shown in the embodiments of the present application optimizes the function dependency set from the three aspects of "merging rule", "replacement rule" and "cleaning".

[0115] The embodiments of the present application also provide an optional embodiment, which mainly further extends the step S240 of "updating the first function dependency to the initial set according to the target processing rule to obtain the intermediate set of the target operator". The extension can be any one of steps Sa1-Sa3.

[0116] Sa1, determining that the target processing rule is the merging rule; executing the merging rule, and taking the initial set obtained after executing the merging rule as the intermediate set.

[0117] The processing rule associated with the dependency type of the first function dependency includes the merging rule; the merging rule includes: determining the second function dependency matched with the first function dependency in the initial set, and merging the first function dependency into the second function dependency.

[0118] Sa2, determining that the target processing rule is the replacement rule; executing the replacement rule, and taking the initial set obtained after executing the replacement rule as the intermediate set.

[0119] The processing rule associated with the dependency type of the first function dependency includes the replacement rule; the replacement rule includes: determining the third function dependency matched with the first function dependency in the initial set, and replacing the third function dependency with the first function dependency.

[0120] Sa3, determining that the target processing rule is the merging rule and the replacement rule; executing the merging rule and the replacement rule in sequence, and taking the initial set obtained after executing the replacement rule as the intermediate set.

[0121] The processing rule associated with the dependency type of the first function dependency includes the replacement rule and the merging rule.

[0122] In an implementation manner of the embodiment, the dependency type includes the constant function dependency, and the processing rule associated with the constant function dependency only includes the merging rule.

[0123] The first attribute set of the constant function dependency is empty, and the second attribute set is non-empty. Specifically, the embodiment of the application expands a new function dependency, i.e., a constant function dependency, on the basis of the related art. The constant function dependency is a function dependency without a decision attribute set. When the first function dependency with the dependency type of constant function dependency is updated to the initial set, it can be directly merged into the second function dependency with the dependency type of constant function dependency. That is, the constant function dependency maintained in the initial set always has only one item.

[0124] Optionally, the first function dependency is merged into the second function dependency, and specifically includes:

[0125] The dependency attributes in the second attribute set of the first function dependency are all merged into the second attribute set of the second function dependency, and the second function dependency after the merging contains the first function dependency, and the first function dependency can be derived from the second function dependency according to the Armstrong axiom. It should be pointed out that the Armstrong axiom is a commonly used means in the related art, and is not described herein for the sake of simplicity.

[0126] In one example, there is an FD2 meeting the condition in the initial set, and the first function dependency is set as FD3. The constant_FD is an identifier of the constant function dependency.

[0127] FD2={set1=[]; set2=[A]; FD_type="constant_FD";}

[0128] FD3={set1=[]; set2=[B]; FD_type="constant_FD";}

[0129] After FD3 is merged into FD1, the FD2 is updated.

[0130] FD2={set1=[]; set2=[A,B]; FD_type="constant_FD";}

[0131] In addition, the FD2 can also be described in the following simplified manner: {}->{A,B}.

[0132] In another implementation manner of the embodiment, the dependency type includes an equivalence dependency, and the processing rule associated with the equivalence dependency includes a merging rule.

[0133] If the dependency type of the first function dependency is the equivalence dependency, the second function dependency matched with the first function dependency meets the following conditions:

[0134] The dependency type of the second functional dependency is consistent with the dependency type of the first functional dependency; the first attribute set of the second functional dependency is equal to the second attribute set of the first functional dependency, and the second attribute set of the second functional dependency is equal to the first attribute set of the first functional dependency.

[0135] Optionally, the first functional dependency is merged into the second functional dependency, specifically including:

[0136] The first attribute sets of the first functional dependency and the second functional dependency are merged, and the merging result is taken as the first attribute set of the second functional dependency again; and the second attribute sets of the first functional dependency and the second functional dependency are merged, and the merging result is taken as the second attribute set of the second functional dependency again.

[0137] In one example, in one example, there is a FD4 in the initial set that meets the condition, and the first functional dependency is set as FD5. Wherein, constant_FD is the identification of the constant functional dependency.

[0138] FD4={set1=[ab]; set2=[cd]; FD_type="strict_equiv_FD";}

[0139] FD5={set1=[cd]; set2=[ab]; FD_type="strict_equiv_FD";}

[0140] FD5 is merged into FD4, and FD4 is as follows.

[0141] FD4={set1=[abcd]; set2=[abcd]; FD_type="strict_equiv_FD";}

[0142] Optionally, after the first functional dependency is merged into the second functional dependency, a fourth functional dependency that matches the second functional dependency can also be obtained from the initial set, and the fourth functional dependency is merged into the second functional dependency.

[0143] Wherein, the dependency type of the first functional dependency is an equivalence dependency; the two attribute sets of the fourth functional dependency are equal, and the intersection of the first attribute set of the fourth functional dependency and the first attribute set of the second functional dependency is non-empty.

[0144] Optionally, the fourth functional dependency is merged into the second functional dependency, including:

[0145] merge the first attribute set of the second functional dependency and the fourth functional dependency respectively, and take the merging result as the first attribute set of the second functional dependency again; and merge the second attribute set of the second functional dependency and the fourth functional dependency respectively, and take the merging result as the second attribute set of the second functional dependency again. Optionally, the fourth functional dependency is cleaned from the initial set.

[0146] In one example, the fourth functional dependency FD6 in the initial set satisfies the condition.

[0147] FD6={set1=[bcde]; set2=[bcde]; FD_type=“strict_equiv_FD”;}

[0148] Since the intersection of the first attribute set of FD6 and the first attribute set of FD4 is [bcd], FD6 can be merged into FD4. After the merging, FD4 is:

[0149] FD4={set1=[abcde]; set2=[abcde]; FD_type=“strict_equiv_FD”;}

[0150] The embodiments of the present application also define the strong and weak implication rules between functional dependencies, for example, for the same decision attribute, compared with the weak functional dependency, the strong functional dependency can derive more dependent attributes and does not lose the functional dependency in the initial set; for the same dependent attribute, compared with the weak functional dependency, the strong functional dependency can use fewer decision attributes for derivation and does not lose the original functional dependency. The replacement rule proposed in the embodiments of the present application is based on such strong and weak implication rules. Next, the application of the strong and weak implication rules in the replacement rule will be described through the following implementation manners.

[0151] In another implementation manner of the embodiment, the dependency type includes a weak functional dependency or a weak equivalent dependency, and the processing rule associated with the weak functional dependency or the weak equivalent dependency includes the replacement rule.

[0152] If the dependency type of the first functional dependency is any one of a weak functional dependency or a weak equivalent dependency, the third functional dependency matched with the first functional dependency satisfies the following conditions:

[0153] The dependency type of the third functional dependency is consistent with the dependency type of the first functional dependency; the second attribute set of the third functional dependency is equal to the second attribute set of the first functional dependency; there is a first containing relationship between the first attribute set of the third functional dependency and the first attribute set of the first functional dependency, and the functional dependency associated with the true subset in the first containing relationship is the first functional dependency.

[0154] Optionally, the third functional dependency is replaced by the first functional dependency, including:

[0155] The third functional dependency is cleaned up from the initial set, and the first functional dependency is added.

[0156] It can be understood that the first functional dependency derives the same second attribute set as the third functional dependency, and the first attribute set required is less. Therefore, the first functional dependency has a strong implication relation to the third functional dependency. Therefore, the third functional dependency can be replaced by the first functional dependency.

[0157] In an example, there is FD7 in the initial set, and the first dependency relation is FD8.

[0158] FD7={set1=[AB]; set2=[C]; FD_type=“lax_FD”;}

[0159] FD8={set1=[A]; set2=[C]; FD_type=“lax_FD”;}

[0160] Since the set2 of FD8 is equal to the set2 of FD7, and the set1 of FD8 is a proper subset of the set1 of FD7, it can be seen that FD8 has a strong implication relation to FD7, and the third functional dependency can be replaced by the first functional dependency.

[0161] In addition, FD8 can also be described in the following simplified manner: {A}=>{C}.

[0162] In another implementation manner of the embodiment, the dependency type further includes a strong functional dependency, and the processing rule associated with the strong functional dependency includes a replacement rule.

[0163] If the dependency type of the first functional dependency is a strong functional dependency, the third functional dependency matched with the first functional dependency satisfies the following condition 1 or condition 2.

[0164] Condition 1: The dependency type of the third functional dependency is consistent with the dependency type of the first functional dependency, and the second attribute set of the third functional dependency and the first functional dependency is equal; there is a second inclusion relation between the first attribute set of the third functional dependency and the first functional dependency, and the function dependency associated with the proper subset in the second inclusion relation is the first functional dependency.

[0165] It can be understood that the first functional dependency derives the same second attribute set as the third functional dependency, and the first attribute set required is less. Therefore, the first functional dependency has a strong implication relation to the third functional dependency. Therefore, the third functional dependency can be replaced by the first functional dependency.

[0166] In an example, there is FD9 in the initial set, and the first functional dependency is FD10.

[0167] FD9 = {set1 = [AB] ; set2 = [C] ; FD_type = "strict_FD" ;} ;

[0168] FD10 = {set1 = [A] ; set2 = [C] ; FD_type = "strict_FD" ;} ;

[0169] Since FD9 has the same set2 as FD10, and the set1 of FD10 is a true subset of the set1 of FD9, i.e. the same decision attributes, FD10 can derive more dependency attributes. Therefore, FD10 has a strong implication relationship with FD9, and FD9 can be replaced by FD10.

[0170] Condition 2: the dependency type of the third functional dependency is consistent with the dependency type of the first functional dependency, the first attribute set of the third functional dependency is equal to the first attribute set of the first functional dependency, and there is a third inclusion relationship between the second attribute sets of the third functional dependency and the first functional dependency, and the functional dependency associated with the true subset in the third inclusion relationship is the second functional dependency.

[0171] It can be understood that the first functional dependency and the third functional dependency have equal first attribute sets, and the second attribute set derived by the first functional dependency through the first attribute set has more attributes. Therefore, the first functional dependency has a strong implication relationship with the third functional dependency. Therefore, the third functional dependency can be replaced by the first functional dependency.

[0172] In an example, there is FD11 in the initial set, and the first functional dependency is FD12.

[0173] FD11 = {set1 = [A] ; set2 = [C] ; FD_type = "strict_FD" ;} ;

[0174] FD12 = {set1 = [A] ; set2 = [BC] ; FD_type = "strict_FD" ;} ;

[0175] Since FD11 has the same set1 as FD12, and the set2 of FD11 is a true subset of the set2 of FD12, i.e. the same decision attributes, FD12 can derive more dependency attributes. Therefore, FD12 has a strong implication relationship with FD11, and FD11 can be replaced by FD12.

[0176] Optionally, replacing the third functional dependency with the first functional dependency comprises:

[0177] cleaning the third functional dependency from the initial set, and adding the first functional dependency.

[0178] In addition, the replacement rule proposed in the embodiment of the present application also provides other strong and weak implication rules. For the same decision attribute and dependent attribute, if the dependent type is a strong equivalent dependency or a weak equivalent dependency, it is obvious that the constraint between the dependent attribute and the decision attribute in the strong equivalent dependency is stronger, and the function dependency with stronger constraint is retained to strengthen the constraint between the dependent attribute and the decision attribute. Next, the specific application of the strong and weak implication rules in the replacement rule will be described through the following implementation manners.

[0179] In a possible implementation manner of the embodiment, the dependent type includes a strong equivalent dependency, a weak equivalent dependency, a strong function dependency or a weak function dependency, the replacement rule is included in the processing rule associated with the strong equivalent dependency, the weak equivalent dependency, the strong function dependency or the weak function dependency, and each dependent type has a level. The dependent types in descending order of the level are: the strong equivalent dependency, the weak equivalent dependency, the strong function dependency and the weak function dependency.

[0180] If the dependent type of the first function dependency is any one of the strong equivalent dependency, the weak equivalent dependency and the strong function dependency, the third function dependency matched with the first function dependency satisfies the following conditions:

[0181] Compared with the level of the dependent type of the first function dependency, the level of the dependent type of the third function dependency is lower; the first attribute set and the second attribute set of the third function dependency and the first function dependency are equal respectively.

[0182] Since the dependency of the dependent attribute on the decision attribute in the strong equivalent dependency is stronger than the dependency of the corresponding relationship in the weak equivalent dependency, it is the best choice to retain the strong function dependency.

[0183] In an example, there is an FD13 in the dependent set, and the first function dependency is FD14.

[0184] FD13={set1=[A];set2=[B];FD_type=“strict_FD”;};

[0185] FD14={set1=[A];set2=[B];FD_type=“strict_equiv_FD”;};

[0186] Since the level of the dependent type of the strong function dependency FD13 is lower than that of the dependent type of FD14, the function dependency represented by FD14 is a strong function dependency than that of FD13. Therefore, FD13 can be replaced by FD14.

[0187] Through the merging rule and the replacement rule defined by the above implementation manners of the embodiment,

[0188] In OLAP scenarios, a query may involve many tables and many join operations, and the number of attributes obtained can be very large, and the number of extended functional dependencies generated by such a query can be very large, so maintaining the minimum number of functional dependency sets is the key to reducing the complexity of the graph. On the one hand, considering the compression and merging operations of constant function dependencies and equivalent dependencies when adding new dependencies can maintain the minimum functional dependency set; on the other hand, by replacing the implication relationship between various strong and weak function dependencies in the rule, only strong edges are retained when adding function dependencies, which is also an important means of maintaining the minimum functional dependency set.

[0189] In the FD graph of the EFDQO theory in the paper, vertex deletion only marks the related vertex as a virtual vertex, and the related vertex and edge set of the original related FD graph are unchanged, which will cause the system to need to retain many unnecessary edges (i.e. a function dependency). In order to solve this problem, the embodiment of the application further provides a vertex deletion mechanism, which expands the closure of the function dependencies in the set and then deletes the vertex, so as to achieve the purpose of simplifying the set without losing the function dependencies in the set.

[0190] In a possible implementation manner of this embodiment, if the second function dependency and / or the third function dependency does not exist in the initial set, the first function dependency is directly added to the initial set.

[0191] In a possible implementation manner of this embodiment, the step S250 includes the following implementation steps Sb1-Sb3.

[0192] Sb1, determine the attribute full set of the relational expression in the target operator.

[0193] Sb2, derive other function dependencies implied by the intermediate set based on the attribute full set, and add the other function dependencies to the intermediate set.

[0194] Optionally, for each function dependency in the intermediate set, if the intersection of at least one set of the function dependency and the attribute full set is non-empty, a fifth function dependency is obtained according to the function dependency; the level of the dependency type of the fifth function dependency is lower than the level of the dependency type of the function dependency, and the first attribute set and the second attribute set of the fifth function dependency are equal to the first attribute set and the second attribute set of the function dependency, respectively. Derive other function dependencies implied by the intermediate set according to the preset axiom and the fifth function dependency, and take the fifth function dependency as the other function dependencies implied by the intermediate set

[0195] Sb3, clean up the attributes in the intermediate set that do not belong to the attribute full set.

[0196] Among them, for each function dependency in the intermediate set, if at least one attribute set of the function dependency is empty, the function dependency is cleaned up from the intermediate set.

[0197] Compared to the merging and replacement rules applied to newly added functional dependencies, the cleanup rules for attributes are a more important part of reducing the complexity of functional dependency sets. By using cleanup rules, many redundant functional dependencies can be removed.

[0198] Based on the above embodiments, it can be determined that the method for analyzing the functional dependency set of operators shown in the embodiments of this application has the following advantages:

[0199] 1. By implementing merge and replacement rules in the execution plan, the number of functional dependencies can be reduced from the stage of collecting functional dependencies.

[0200] 2. Functional dependencies are collected from the bottom up, on a per-operator basis in the execution plan, without needing to consider semantic isolation caused by subquery hierarchy.

[0201] 3. Building upon related technologies, the storage method for functional dependencies has been expanded, such as storing dependency attributes and determinant attributes separately using sets. When adding a functional dependency to the set, the dependency is added according to merging and replacement rules, resulting in effective compression and simplification of the final functional dependency set. For example, in most OLAP scenarios, the functional dependency set can reduce maintenance of functional dependencies by 80%, and reduce the number of edges in the functional dependency graph by 80%; in OLTP scenarios, the functional dependency set can reduce maintenance of functional dependencies by 50%, and reduce the number of edges in the functional dependency graph by 50%. In other words, the final functional dependency graph is effectively simplified.

[0202] Following the query example described in the above embodiment, since the query result only includes columns da and db from table d (a and b are two attributes of table d), while the related attributes of table t are additional functional dependencies introduced by the underlying subquery, it is necessary to clean up unnecessary related columns when analyzing the upper-level operators.

[0203] To better understand the technical effects of the solutions shown in the embodiments of this application, the embodiments of this application will continue to be combined with Figure 3 The execution plan shown illustrates the process of analyzing functional dependencies, which proceeds sequentially from the bottom-level operators to the top-level operators.

[0204] The Datasource scans table t and creates a basic functional dependency: {row_id}->{te,tf}. Based on this functional dependency, the Datasource's functional dependency set is created as follows:

[0205] {row_id}->{te,tf}. Its functional dependency graph is as follows: Figure 4b As shown.

[0206] Projection1 gets the function dependency set from Datasource as the initial set; the new function dependencies created when Projection1 executes the relational expression include: {t.e}->{t.a} (derived from t.a=t.e*2), {t.e}=={t.b}; the irrelevant attributes "row_id" and "t.f" are deleted, so the function dependency set of Projection1 includes the following function dependencies:

[0207] {t.e}=={t.b}, {t.e}->{t.a}. The function dependency graph is shown in Figure 4c .

[0208] Aggregation gets the function dependency set from Projection1 as the initial set; when Aggregation executes the relational expression, it not only generates new attributes, such as d.a and d.b, but also creates function dependencies for the new attributes, such as {t.e}->{d.a} (derived from t.e*2 as a) and {t.e}=={d.b} (derived from t.e as b); after the intermediate set is obtained from the initial set, d.b->d.a can be derived from d.b->t.e->d.a. So the function dependency set of Aggregation includes the following function dependencies:

[0209] d.b->{t.e,d.a}, {t.e}->{d.a}, {t.e}=={d.b}; the function dependency graph is shown in Figure 4d .

[0210] Projection2 gets the function dependency set from Aggregation as the initial set. The operator does not create new attributes or new function dependencies when it executes the relational expression; the irrelevant attributes "t.e" and "t.b" in the initial set are deleted, as well as the related dependencies, so the following function dependency can be obtained:

[0211] {d.b}->{d.a}. The function dependency graph is shown in Figure 4e .

[0212] In addition, the query statement generated in a real production environment can be more complex than that shown in Figure 3 , so the execution plan is also relatively complex. The embodiment of the present application also provides an example of a relatively complex execution plan based on the example in Figure 3 . For details, refer to FIG.

[0213] In this example, the relational expression executed in the join operator is various "join" expressions, such as "inner join", "left join", etc.; the relational expression executed in the selection operator is "select…from…"; and the relational expression executed in the aggregation operator is "group by", etc.

[0214] To solve the third technical problem in the prior art based on the scheme shown in the paper, the embodiments of the present application further provide a technical scheme for creating an independent application module.

[0215] The application module can implement a method for analyzing the function dependency set of each type of operator in the execution plan shown in the paper. After obtaining the execution plan of each query statement, the function dependency set of each operator can be obtained. Figure 5

[0216] Since each operator receives the function dependency set of the lower layer operator as input, a new function dependency set is formed after the expression is executed and is output to the upper layer operator. Therefore, after obtaining the execution plan, there is no need to care about the semantic isolation introduced by each query block, and there is no need to manually process the merging operation of the function dependency on the data source caused by the join processing of multiple tables, and accordingly the function dependency collection operation similar to the volcano query model can be easily implemented from the root operator of the execution plan.

[0217] Figure 6 An apparatus 600 for analyzing the function dependency set of an operator is shown. The apparatus 600 includes the following modules.

[0218] The statement analysis module 610 is configured to perform semantic analysis on the query statement to obtain an execution plan, and the execution plan includes at least two operators, each of which executes a relational expression in the query statement.

[0219] The first determination module 620 is configured to take any one of the at least two operators as a target operator, and if the relational expression executed by the target operator is nested with the relational expression executed by other operators in the at least two operators, then the union set of the function dependency set of the other operators is taken as the initial set of the target operator.

[0220] The second determination module 630 is configured to execute the corresponding relational expression by the target operator, take any function dependency generated in the execution process as a first function dependency, and determine the dependency type of the first function dependency. The function dependency is associated with a first attribute set storing the decision attribute in the function dependency and a second attribute set storing the dependent attribute in the function dependency.

[0221] ​The updating module 640 is configured to determine, for each first functional dependency, a processing rule associated with the dependency type of the first functional dependency as a target processing rule, and update the first functional dependency to the initial set according to the target rule to obtain an intermediate set of target operators.

[0222] The cleaning module 650 is configured to clean attributes irrelevant to relational expressions executed by the target operators from the intermediate set of target operators, and take the cleaned intermediate set as the functional dependency set of the target operators.

[0223] The apparatus provided in the embodiments of the present application can execute the method provided in the embodiments of the present application, and the implementation principles are similar. The actions performed by each module in the apparatus of the embodiments of the present application are corresponding to the steps in the method of the embodiments of the present application. The detailed function description of each module of the apparatus can be referred to the description of the corresponding method in the foregoing description, and will not be repeated here.

[0224] In the embodiments of the present application, an electronic device is provided, which includes 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 for analyzing the functional dependency set of an operator. Compared with the prior art, the method can achieve the following advantages:

[0225] Referring to Figure 7 , the embodiments of the present application further provide an electronic device, and a specific example of the electronic device is shown in Figure 7 The electronic device 7000 shown in the figure includes a processor 7001 and a memory 7003. The processor 7001 and the memory 7003 are connected, for example, through a bus 7002. Optionally, the electronic device 7000 can also include a transceiver 7004, which can be used for data interaction between the electronic device and other electronic devices, such as data sending and / or data receiving. It should be noted that in actual application, the transceiver 7004 is not limited to one, and the structure of the electronic device 7000 does not constitute a limitation on the embodiments of the present application.

[0226] The processor 7001 can 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 device, transistor logic device, hardware component, or any combination thereof. It can implement or execute various exemplary logical blocks, modules and circuits described in connection with the disclosure. The processor 7001 can also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0227] The bus 7002 can include a path for transmitting information between the above-mentioned components. The bus 7002 can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 7002 can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 7 Only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.

[0228] The memory 7003 can be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, an optical disk storage (including a compact disk, a laser disk, an optical disk, a digital versatile disk, a Blu-ray disk, etc.), a magnetic disk storage medium, other magnetic storage device, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation.

[0229] The memory 7003 is configured to store a computer program for implementing the embodiments of the present application, and the processor 7001 is configured to control the execution of the computer program stored in the memory 7003. The processor 7001 is configured to execute the computer program stored in the memory 7003 to implement the steps shown in the foregoing method embodiments.

[0230] The electronic device includes, but is not limited to, a computer.

[0231] The embodiments of the present application provide a computer readable storage medium, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the steps and corresponding contents of the foregoing method embodiments.

[0232] The embodiments of the present application also provide a computer program product, which includes a computer program. The computer program is executed by a processor to implement the steps and corresponding contents of the foregoing method embodiments.

[0233] It should be understood that, although the flowcharts of the embodiments of the present application indicate the respective operation steps by arrows, the implementation order of the steps is not limited to the order indicated by the arrows. Unless otherwise specified herein, in some implementation scenarios of the embodiments of the present application, the implementation steps in each flowchart can be executed in other orders as required. In addition, part or all of the steps in each flowchart can include multiple sub-steps or multiple stages based on the actual implementation scenario. Part or all of the sub-steps or stages can be executed at the same time, and each of the sub-steps or stages can also be executed at different times. In the scenario where the execution times are different, the execution order of the sub-steps or stages can be flexibly configured according to requirements, and the embodiments of the present application do not limit this.

[0234] The above is only an optional implementation manner of some implementation scenarios of the present application. It should be pointed out that, for those skilled in the art, other similar implementation manners based on the technical concept of the present application can also be adopted without departing from the technical concept of the present application, and these also belong to the protection scope of the embodiments of the present application.

Claims

1. A method of analyzing a function dependency set of an analytic operator, characterized by, The method comprises the following steps: performing semantic analysis on a query statement to obtain an execution plan, the execution plan being composed of at least two operators, each operator executing a relational expression in the query statement; taking any one of the at least two operators as a target operator, if a relational expression executed by the target operator is nested with a relational expression of another operator, taking a union set of function dependency sets of the other operators as an initial set of the target operator; the other operator being an operator other than the target operator among the at least two operators; during execution of the corresponding relational expression by the target operator, taking any function dependency generated in the execution process as a first function dependency, determining a dependency type of the first function dependency, the function dependency including a first attribute set storing decision attributes in the function dependency and a second attribute set storing dependent attributes in the function dependency; for each first function dependency, determining a processing rule associated with the dependency type of the first function dependency as a target processing rule, updating the first function dependency to the initial set according to the target processing rule to obtain an intermediate set of the target operator; cleaning up attributes in the intermediate set of the target operator that are irrelevant to the relational expression executed by the target operator, and taking the cleaned-up intermediate set as a function dependency set of the target operator.

2. The method of claim 1, wherein, The processing rule associated with the dependency type of the first function dependency includes a merging rule; the merging rule includes: determining a second function dependency matching the first function dependency in the initial set, and merging the first function dependency into the second function dependency. The processing rule associated with the dependency type of the first function dependency is determined as a target processing rule, and the first function dependency is updated to the initial set according to the target processing rule to obtain an intermediate set of the target operator, which includes: determining that the target processing rule is the merging rule; executing the merging rule, and taking the initial set obtained after executing the merging rule as the intermediate set.

3. The method of claim 1, wherein, The processing rule associated with the dependency type of the first function dependency includes a replacement rule; the replacement rule includes: determining a third function dependency matching the first function dependency in the initial set, and replacing the third function dependency with the first function dependency. The processing rule associated with the dependency type of the first function dependency is determined as a target processing rule, and the first function dependency is updated to the initial set according to the target processing rule to obtain an intermediate set of the target operator, which includes: determining that the target processing rule is the replacement rule; executing the replacement rule, and taking the initial set obtained after executing the replacement rule as the intermediate set.

4. The method of claim 1, wherein, The processing rule associated with the dependency type of the first function dependency includes a replacement rule and a merging rule. The processing rule associated with the dependency type of the first function dependency is determined as a target processing rule, and the first function dependency is updated to the initial set according to the target processing rule to obtain an intermediate set of the target operator, which includes: determining that the target processing rule is the merging rule and the replacement rule. The merging rule and the replacing rule are executed in sequence, and an initial set obtained after the replacing rule is executed is taken as the intermediate set.

5. The method of claim 2, wherein, The dependency type includes a constant function dependency, a first attribute set of the constant function dependency is empty, and a second attribute set of the constant function dependency is non-empty; and the merging rule is included in a processing rule associated with the constant function dependency. If the dependency type of the first function dependency is the constant function dependency, the second function dependency matched with the first function dependency satisfies the following conditions: The dependency type of the second function dependency is consistent with the dependency type of the first function dependency.

6. The method of claim 2, wherein, The dependency type includes an equality dependency, and the merging rule is included in a processing rule associated with the equality dependency. If the dependency type of the first function dependency is the equality dependency, the second function dependency matched with the first function dependency satisfies the following conditions: The dependency type of the second function dependency is consistent with the dependency type of the first function dependency. The first attribute set of the second function dependency is equal to the second attribute set of the first function dependency, and the second attribute set of the second function dependency is equal to the first attribute set of the first function dependency.

7. The method of claim 6, wherein, After the first function dependency is merged into the second function dependency, the method further includes: A fourth function dependency matched with the second function dependency is obtained from the initial set, and the fourth function dependency is merged into the second function dependency. The dependency type of the fourth function dependency is the equality dependency; two attribute sets of the fourth function dependency are equal, and an intersection of the first attribute set of the fourth function dependency and the first attribute set of the second function dependency is non-empty.

8. The method of claim 3, wherein, The dependency type includes a weak function dependency or a weak equality dependency, and the replacing rule is included in a processing rule associated with the weak function dependency or the weak equality dependency. If the dependency type of the first function dependency is any one of the weak function dependency or the weak equality dependency, a third function dependency matched with the first function dependency satisfies the following conditions: The dependency type of the third function dependency is consistent with the dependency type of the first function dependency. The second attribute sets of the third function dependency and the first function dependency are equal. A first containing relationship exists between the first attribute sets of the third function dependency and the first function dependency, and a function dependency associated with a true subset in the first containing relationship is the first function dependency.

9. The method of claim 3, wherein, The dependency type further includes a strong function dependency, and the replacing rule is included in a processing rule associated with the strong function dependency. If the dependency type of the first function dependency is the strong function dependency, the third function dependency matched with the first function dependency satisfies the following conditions: The dependency type of the third function dependency is consistent with the dependency type of the first function dependency, the second attribute sets of the third function dependency and the first function dependency are equal, a second containing relationship exists between the first attribute sets of the third function dependency and the first function dependency, and a function dependency associated with a true subset in the second containing relationship is the first function dependency. Or The dependency type of the third functional dependency is consistent with the dependency type of the first functional dependency, the first attribute set of the third functional dependency and the first functional dependency is equal, there is a third inclusion relationship between the second attribute set of the third functional dependency and the first functional dependency, and the functional dependency associated with the true subset in the third inclusion relationship is the second functional dependency.

10. The method of claim 3, wherein, The dependency type includes strong equality dependency, weak equality dependency, strong functional dependency or weak functional dependency, the processing rule associated with the strong equality dependency, the weak equality dependency, the strong functional dependency or the weak functional dependency includes the replacement rule, and each dependency type has a level; each dependency type is in turn from high to low: strong equality dependency, weak equality dependency, strong functional dependency and weak functional dependency; If the dependency type of the first functional dependency is any one of strong equality dependency, weak equality dependency and strong functional dependency, the third functional dependency matched with the first functional dependency satisfies the following conditions: Compared with the level of the dependency type of the first functional dependency, the level of the dependency type of the third functional dependency is lower; the first attribute set and the second attribute set of the third functional dependency and the first functional dependency are equal respectively.

11. The method of claim 1, wherein, The cleaning of the attributes in the intermediate set of the target operator that are not associated with the relational expression executed by the target operator includes: Determining the attribute universal set of the relational expression in the target operator; Deriving other functional dependencies implied by the intermediate set based on the attribute universal set, and adding the other functional dependencies to the intermediate set; Cleaning the attributes in the intermediate set that are not in the attribute universal set; If at least one attribute set of each functional dependency in the intermediate set is empty, the functional dependency is cleaned from the intermediate set.

12. The method of claim 11, wherein, The deriving of the other functional dependencies implied by the intermediate set based on the attribute universal set includes: If the intersection of at least one set of each functional dependency in the intermediate set and the attribute universal set is non-empty, a fifth functional dependency is obtained according to the functional dependency; compared with the level of the dependency type of the functional dependency, the level of the dependency type of the fifth functional dependency is lower, and the first attribute set and the second attribute set of the fifth functional dependency and the functional dependency are equal respectively; Deriving other functional dependencies implied by the intermediate set according to the fifth functional dependency and the fifth functional dependency as the other functional dependencies implied by the intermediate set.

13. An apparatus for analyzing the functional dependency set of an operator, characterized in that, It includes: A sentence analysis module is configured to perform semantic analysis on a query statement to obtain an execution plan, the execution plan including at least two operators, each operator executing a relational expression in the query statement; A first determination module is configured to take any one of the at least two operators as a target operator, and if the relational expression executed by the target operator is nested with the relational expression of another operator, the union set of the functional dependency set of the other operator is taken as the initial set of the target operator; The other operator is an operator other than the target operator in the at least two operators; a second determining module, configured to execute a corresponding relational expression by the target operator, take any function dependency generated in the execution process as a first function dependency, and determine a dependency type of the first function dependency, the function dependency being associated with a first attribute set storing decision attributes in the function dependency and a second attribute set storing dependency attributes in the function dependency; an updating module, configured to, for each first function dependency, determine a processing rule associated with the dependency type of the first function dependency as a target processing rule, and update the first function dependency to the initial set according to the target rule to obtain an intermediate set of the target operator; a cleaning module, configured to clean attributes irrelevant to the relational expression executed by the target operator in the intermediate set of the target operator, and take the cleaned intermediate set as the function dependency set of the target operator.

14. An electronic device comprising a memory, a processor, and a computer program stored on the memory, wherein the computer program, when executed by the processor, is arranged to perform the method of any one of claims 1 to 12. The processor executes the computer program to implement the steps of the method in any one of claims 1-12.

15. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1-12.

Citation Information

Patent Citations

  • Dependence package recommendation method and device, electronic equipment and readable storage medium

    CN112182199A

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

    CN112905323A