Data query method and apparatus

By generating a plan tree in the database engine and establishing grouping task dependencies, the management node processes the acquired grouping aggregation results, solving the problem of low efficiency of enhanced grouping function queries in the existing technology and achieving more efficient data queries.

WO2025200564A1PCT designated stage Publication Date: 2025-10-02HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/137243
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-25
Filing Date
2024-12-05
Publication Date
2025-10-02

AI Technical Summary

Technical Problem

When processing query statements containing enhanced grouping functions, existing database engines need to perform multiple grouping and aggregation calculations on all records in the data table, resulting in high time overhead and low query efficiency.

Method used

After receiving the query statement, the management node generates a plan tree, establishes the dependency relationship of the grouping tasks, and executes the grouping tasks according to the dependency relationship. By grouping and aggregating the obtained grouping aggregation results, it avoids grouping all the records in the data table.

Benefits of technology

It improves query efficiency, reduces time overhead, and reduces repeated grouping operations on data tables.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024137243_02102025_PF_FP_ABST
    Figure CN2024137243_02102025_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a data query method and apparatus. The method comprises: a management node receives a query statement, the query statement comprising an enhanced grouping function; the management node generates a plan tree on the basis of the query statement, wherein the plan tree comprises a plurality of tasks, the plurality of tasks comprise N grouping tasks generated on the basis of the enhanced grouping function, M second fields in at least one grouping task among the N grouping tasks comprise at least one third field, and the third field indicates that grouping is not required; the management node establishes a dependency relationship of the N grouping tasks on the basis of the quantity of the third field, wherein among grouping tasks with adjacent quantities of third fields, the grouping task with a large quantity of third fields is used as a child node, and the grouping task with a small quantity of third fields is used as a parent node; and when executing the N grouping tasks on the basis of the plan tree, the management node executes the N grouping tasks on the basis of the dependency relationship. According to the method, the query efficiency can be improved, and the time overhead can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Data query method and device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of the People's Republic of China on March 25, 2024, with application number 202410361350.4 and application name "A Data Query Method and Device", the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the field of big data technology, and in particular to a data query method and device. Background Art

[0004] When analyzing and counting data in a database, you can use query statements containing grouping functions to divide multiple rows in a table into multiple groups, analyze and count the records in each group, and finally output the query results. Grouping functions can include simple grouping functions and enhanced grouping functions. Simple grouping functions include the group by() function, while common enhanced grouping functions include grouping sets(), rollup(), and cube().

[0005] Currently, after obtaining a query statement containing an enhanced grouping function, the database engine needs to query the data table at least once, and each time it needs to group all the records in the data table, and then analyze and count the records in the divided groups. This will increase the time overhead. How to reduce the time overhead and improve query efficiency is a technical problem that urgently needs to be solved. Summary of the Invention

[0006] The present application provides a data query method and device for reducing the time overhead of querying data tables and improving query efficiency.

[0007] In a first aspect, an embodiment of the present application provides a data query method, which can be executed by a management node or a device including a management node (such as a chip, a chip system, etc.). Optionally, the method can also be executed by a logical node, a logical module, software, an acceleration library, a cloud service, or a hardware and software integrated device that can implement all or part of the management node functions. The description here takes the management node as the execution subject as an example. The method specifically includes the following steps: a management node receives a query statement, the query statement includes an enhanced grouping function, the enhanced grouping function is used to group data in a first data table according to M first fields, where M is a positive integer; the management node generates a plan tree according to the query statement, the plan tree includes multiple tasks, the multiple tasks include N grouping tasks generated according to the enhanced grouping function, and the M second fields in at least one of the N grouping tasks include at least one third field, and the third field indicates that grouping is not required; the management node establishes a dependency relationship among the N grouping tasks according to the number of third fields, wherein, among grouping tasks with adjacent numbers of third fields, the grouping task with a larger number of third fields serves as a child node, and the grouping task with a smaller number of third fields serves as a parent node, and the child node depends on the parent node; when the N grouping tasks are executed according to the plan tree, the management node executes the N grouping tasks according to the dependency relationship, wherein the grouping task with the smallest number of third fields is executed first, and the execution result of the parent node is used as input data for executing the child node, until the N grouping tasks are completed.

[0008] In the above method, for query statements containing enhanced grouping functions, the management node does not need to group and aggregate the records in the data table every time, but can group and aggregate the obtained grouping aggregation results. Since the records in the grouping aggregation results are much smaller than the records in the data table, the above method is conducive to improving query efficiency and reducing time overhead.

[0009] In a possible design, the enhanced grouping function includes any one of a grouping sets() function, a rollup() function, or a cube() function.

[0010] In one possible design, the dependency relationship includes a root node and N nodes located below the root node; the N nodes correspond to N grouping tasks; the dependency relationship includes L layers, L is an integer greater than or equal to 2, and the root node is located at the first layer in the dependency relationship; the second layer in the dependency relationship includes P1 nodes, the P1 nodes are child nodes of the root node, the number of third fields of the grouping tasks corresponding to the P1 nodes are the same, the number of third fields of the grouping tasks corresponding to the P1 nodes is the smallest among the numbers of third fields of the N grouping tasks, and P1 is an integer less than or equal to N.

[0011] In a possible design, the other layers in the dependency relationship except the first layer and the second layer include P2 nodes; the i-th layer in the dependency relationship includes P3 nodes, the number of third fields of the grouping tasks corresponding to the P3 nodes is the same, and the number of third fields of the grouping tasks corresponding to the p3-th node in the P3 nodes is greater than the number of third fields of the grouping tasks corresponding to each node in the i-1-th layer in the dependency relationship; when the m-th second field among the M second fields of the grouping task corresponding to the parent node of the p3-th node is the third field, the m-th second field among the M second fields of the grouping task corresponding to the p3-th node is the third field, P2 is an integer less than N, m is an integer that traverses [0, M], P3 is an integer less than or equal to P2, i is an integer that traverses [3, L], and p3 is an integer that traverses [1, P3].

[0012] In a possible design, the management node executes N grouping tasks according to the dependency relationship, including: the management node hierarchically traverses the dependency relationship and executes the N grouping tasks.

[0013] In a second aspect, an embodiment of the present application further provides a data query device, which includes a device for executing the method provided in the first aspect above.

[0014] In a third aspect, an embodiment of the present application further provides a data query device, which includes a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call the computer program and execute the method provided in the first aspect above.

[0015] In a fourth aspect, an embodiment of the present application further provides a computing device cluster comprising at least one computing device, each computing device comprising a processor and a memory, wherein the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method provided in the first aspect above.

[0016] In a fifth aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute the method provided in the first aspect above.

[0017] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method provided in the first aspect above.

[0018] In a seventh aspect, an embodiment of the present application further provides a chip comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute the method provided in the first aspect above.

[0019] In an eighth aspect, embodiments of the present application provide a chip system comprising instructions, which, when executed by a computing device cluster, causes the computing device cluster to execute the method provided in the first aspect above. The chip system may be composed of a chip alone, or may include a chip and other discrete devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] FIG1A is a schematic diagram of a system architecture provided in an embodiment of the present application;

[0021] FIG1B is a schematic diagram of the structure of a management node provided in an embodiment of the present application;

[0022] FIG2 is a flow chart of a data query method provided in an embodiment of the present application;

[0023] FIG3 is a flow chart of a method for determining N grouping tasks provided in an embodiment of the present application;

[0024] FIG4 is a flow chart of a method for determining N grouping tasks provided in an embodiment of the present application;

[0025] FIG5 is a flow chart of a method for determining N grouping tasks provided in an embodiment of the present application;

[0026] FIG6 is a flow chart of a method for determining a relationship tree according to an embodiment of the present application;

[0027] FIG7 is a flow chart of a method for establishing a dependency relationship according to an embodiment of the present application;

[0028] FIG8( a ) is a schematic diagram of a dependency relationship structure provided in an embodiment of the present application;

[0029] FIG8( b ) is a schematic diagram of a dependency structure provided in an embodiment of the present application;

[0030] FIG9 is a flow chart of a method for establishing a dependency relationship according to an embodiment of the present application;

[0031] FIG10 is a flow chart of a method for establishing a dependency relationship according to an embodiment of the present application;

[0032] FIG11 is a schematic diagram of a dependency structure provided in an embodiment of the present application;

[0033] FIG12 is a schematic diagram of a dependency relationship structure provided in an embodiment of the present application;

[0034] FIG13 is a schematic diagram of a flow chart of a method for determining group aggregation results provided in an embodiment of the present application;

[0035] FIG14 is a schematic diagram of a flow chart of a method for determining group aggregation results provided in an embodiment of the present application;

[0036] FIG15 is a flow chart of a method for determining group aggregation results according to an embodiment of the present application;

[0037] FIG16 is a flow chart of a method for determining group aggregation results according to an embodiment of the present application;

[0038] FIG17 is a schematic diagram of the structure of a data query device provided in an embodiment of the present application;

[0039] FIG18 is a schematic diagram of the structure of a data query device provided in an embodiment of the present application;

[0040] FIG19 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;

[0041] FIG20 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application;

[0042] FIG21 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solutions and advantages of this application more clear, the application will be further described in detail below with reference to the accompanying drawings. The specific operation methods and functional descriptions in the method embodiments can also be applied to the device embodiments or system embodiments.

[0044] Below, some terms used in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0045] Structured Query Language (SQL) is a special-purpose programming language, a database query and programming language used to access data and query, update, and manage relational database systems.

[0046] A plan tree is a tree structure that describes the query execution process and is generated by the database management system when executing an SQL query based on the logical structure of the query statement and the data distribution. It is also called the "SQL physical plan tree," "execution plan tree," or "query optimization tree." The plan tree consists of multiple nodes, each of which represents an operation or a result. Starting from the root node of the plan tree, it expands downward layer by layer until it reaches the leaf node of the plan tree. The root node of the plan tree represents the initial state of the query, and the leaf nodes of the plan tree represent the final result of the query. Each node in the plan tree corresponds to a task. For example, the root node of the plan tree represents the start of the query and contains information such as the query type and the name of the data table. The scan node in the plan tree can represent a scan operation on a table or view, including a range scan, a full table scan, etc. The index node in the plan tree can represent an operation that uses an index for a query, including an index range scan, an index full table scan, etc.

[0047] Query statements are used to query data in the database and do not modify the data in the database. Query statements can be divided into two categories: simple query statements and complex query statements.

[0048] The syntax format of a simple query statement is select expression1from tablename of a data table, where expression1 can be understood as a column name in a data table, or as an operation expression of at least one column name in a data table, and the table name of a data table can also be understood as the identifier of the data table.

[0049] For example, consider a simple query like "select age from table1," where "table1" is the table name and "age" is the column name in table1. Table1 also contains data corresponding to the age column. When you execute the query "select age from table1," the query results are all the data corresponding to the age column in table1.

[0050] A simple query statement is "select 2*age from table1," where "age" is the column name in table1 and "2*age" is the calculation expression. When this query statement is executed, the result is the product of each data point in the age column in table1 multiplied by 2.

[0051] A simple query statement is "select age / salary from table1." "age" and "salary" are column names in table1, which contains data corresponding to both the age and salary columns. "age / salary" is an expression. When you execute the query "select age / salary from table1," the result is the ratio of each value in the age column to the corresponding value in the salary column.

[0052] Complex query statements may include aggregate functions and / or grouping functions. Aggregation functions can appear alone in complex query statements. Grouping functions generally do not appear alone in complex query statements, but rather appear in combination with aggregate functions.

[0053] An aggregate function takes a set of inputs and returns a single value. Aggregate functions are used to perform calculations on data in a specific column of a table. Database management systems (DBMSs) provide specialized aggregate functions, such as count(), sum(), avg(), max(), and min().

[0054] The count() function is used to calculate the number of rows of data in the specified column of the data table.

[0055] The sum() function is used to calculate the sum of the data in the specified column of the data table.

[0056] The avg() function is used to calculate the average value of the data in the specified column of the data table.

[0057] The max() function is used to calculate the maximum value of the data in the specified column of the data table.

[0058] The min() function is used to calculate the minimum value of the data in the specified column of the data table.

[0059] Grouping functions include simple grouping functions and enhanced grouping functions. Simple grouping functions include the group by() function, and enhanced grouping functions include the grouping sets() function, rollup() function, and cube() function.

[0060] When a complex query statement includes an aggregate function, the corresponding syntax is "select aggregate function (expression 2) from table name", where expression 2 can be understood as a column name in the table. The query result of "select aggregate function (expression 2) from table name" is obtained by performing an aggregate calculation on the data in the table using "aggregate function (expression 2)".

[0061] For example, consider the complex query "select avg(age) from table1," where "table1" is the table name, "age" is the column name in table1, and includes data corresponding to the age column. "avg()" is an aggregate function that calculates the average value of the data corresponding to the age column in table1. When the query "select avg(age) from table1" is executed, the query result is the average value of the data corresponding to the age column in table1.

[0062] When a complex query statement includes both aggregate and group functions, the corresponding syntax is "select aggregate function (expression 2) from table name group function (expression 3)," where both expression 2 and expression 3 can be understood as column names in the table. The query result of "select aggregate function (expression 2) from table name group function (expression 3)" is obtained by grouping the data in the table using the group function (expression 3) and performing an aggregation calculation on the data in each group using the aggregate function (expression 2).

[0063] With respect to the four different grouping functions, the query results corresponding to the query statements when the complex query statements include different grouping functions are explained in detail below in conjunction with specific embodiments.

[0064] The contents of the data table table1 to be queried are shown in Table 1.

[0065] Table 1

[0066] Table 1 shows that table1 contains five columns and corresponding data: name, company, dept, salary, and age. Name describes the employee's name, company describes the employee's company, dept describes the employee's department, salary describes the employee's salary, and age describes the employee's age. Table1 contains eight records. For a detailed explanation of the first record, the following information might be provided: Employee A1 belongs to the Sales department of Company X, has a salary of 100, and is 36 years old.

[0067] In the first scenario, a query statement includes the group by() function. For example, in the query "select company, sum(salary), avg(age) from table1 group by company," group by company is used to group the data in table1 by company, resulting in two groups: the first group and the second group. The first group contains four records, all containing "company" (X). Table 2 shows the first group.

[0068] Table 2

[0069] The second group includes 4 records, and the company in all 4 records is Y. The second group is shown in Table 3.

[0070] Table 3

[0071] Aggregate calculations are performed on the first group shown in Table 2 and the second group shown in Table 3, respectively, as follows:

[0072] For the first group shown in Table 2, in the query statement "select company,sum(salary),avg(age)", company is used to select a data corresponding to the column name company from the first group, sum(salary) is used to calculate the sum of the data corresponding to the column name salary in the first group, and the calculated result is 830. avg(age) is used to calculate the average of the data corresponding to the column name age in the first group, and the calculated result is 34.

[0073] For the second group shown in Table 3, in the query statement "select company,sum(salary),avg(age)", company is used to select a data corresponding to the column name company from the second group, sum(salary) is used to calculate the sum of the data corresponding to the column name salary in the second group, and the calculated result is 1150. avg(age) is used to calculate the average of the data corresponding to the column name age in the second group, and the calculated result is 32.

[0074] After the above grouping and aggregation calculation process, the query results for the statement select company, sum(salary), avg(age) from table1 group by company are shown in Table 4. Based on the query results in Table 4, we can see that the total salary paid to all employees in Company X is 830, and the average age of all employees in Company X is 34. The total salary paid to all employees in Company Y is 1150, and the average age of all employees in Company Y is 32.

[0075] Table 4

[0076] It should be understood that when executing the query above, the processor does not follow the previously described execution process, where the processor first obtains and stores the first and second groups and then calculates the average of the data corresponding to the age column and the sum of the data corresponding to the salary column for each group. This execution process is described for ease of understanding. In practice, when calculating the average of the data corresponding to the age column and the sum of the data corresponding to the salary column, the processor directly determines the group to which each record in the data table belongs and performs an aggregation calculation for each group.

[0077] As can be seen from the above method, when a query statement includes a simple grouping function (group by()), the processor needs to query all records in the data table to obtain the query result corresponding to the query statement. In addition, when the query statement includes group by(), the processor only needs to query the data table once to obtain the query result corresponding to the query statement, without having to query the data table multiple times.

[0078] In the second scenario, when the query statement includes the grouping sets() function, for example, the query statement is select company,sum(salary),avg(age)from table1 group by grouping sets(company,dept), the query result is equivalent to the query result of the following query statement:

[0079] select company,sum(salary),avg(age)from table1 group by company union

[0080] select sum(salary),avg(age)from table1 group by dept

[0081] Based on the above embodiment, it can be seen that when executing the query statement select company,sum(salary),avg(age)from table1 group by grouping sets(company,dept), the processor needs to query all records in the data table1 twice.

[0082] When querying all records in table1 for the first time, the processor divides all records in table1 into two groups according to company. It then performs aggregation calculations on the records in each group based on the query "company, sum(salary), avg(age)" to obtain the query result corresponding to the query statement select company, sum(salary), avg(age) from table1 group by company.

[0083] When querying all records in table1 for the second time, the processor divides all records in table1 into three groups according to dept. It then performs aggregation calculations on the records in each group based on the query "sum(salary),avg(age)" to obtain the query result corresponding to the query statement select sum(salary),avg(age) from table1 group by dept.

[0084] Finally, output the query results corresponding to select company,sum(salary),avg(age)from table1 group by company and select sum(salary),avg(age)from table1 group by dept in turn to obtain the query result of select company,sum(salary),avg(age)from table1 group by grouping sets(company,dept).

[0085] Scenario 3: When the query statement includes the rollup() function, for example, the query statement is select company,sum(salary),avg(age)from table1 group by rollup(company,dept). The query result of this query statement is equivalent to the query result of the following query statement:

[0086] select company,sum(salary),avg(age)from table1 group by grouping sets((company,dept),(company),())

[0087] Alternatively, it can be equivalent to the query results of the following query statement:

[0088] select company,sum(salary),avg(age)from table1 group by(company,dept)union

[0089] select company,sum(salary),avg(age)from table1 group by company union

[0090] select sum(salary),avg(age)from table1 group by()

[0091] Based on the above embodiment, it can be seen that when executing the query statement select company,sum(salary),avg(age)from table1 group by rollup(company,dept), the processor needs to query all records in the data table table1 three times.

[0092] When querying all records in table1 for the first time, the processor divides all records in table1 into four groups according to company and dept. It then performs aggregation calculations on the records in each group based on the query "company, sum(salary), avg(age)" to obtain the query result corresponding to the query statement select company, sum(salary), avg(age) from table1 group by (company, dept).

[0093] When querying all records in table1 for the second time, the processor divides all records in table1 into two groups according to company, and then performs aggregation calculations on the records in each group based on the query statement "company, sum(salary), avg(age)". The query result corresponding to the query statement "select company, sum(salary), avg(age) from table1 group by company" is obtained.

[0094] When querying all records in table1 for the third time, the processor does not need to group the records in table1. Alternatively, the processor groups the records in table1 into the same group. The processor then performs an aggregation calculation on the records in table1 based on the query "sum(salary),avg(age)" to obtain the query result corresponding to the query statement select sum(salary),avg(age) from table1 group by().

[0095] Finally, output the query results corresponding to select company,sum(salary),avg(age)from table1 group by(company,dept), select company,sum(salary),avg(age)from table1 group by company, and select sum(salary),avg(age)from table1 group by() in turn to obtain the query result of the query statement select company,sum(salary),avg(age)from table1 group by rollup(company,dept).

[0096] Scenario 4: When the query statement includes the cube() function, for example, the query statement is select company,sum(salary),avg(age)from table1 group by cube(company,dept). The query result of this query statement is equivalent to the query result of the following query statement:

[0097] select company,sum(salary),avg(age)from table1 group by grouping sets((company,dept),(company),(dept),())

[0098] Alternatively, it can be equivalent to the query results of the following query statement:

[0099] select company,sum(salary),avg(age)from table1 group by(company,dept)union

[0100] select company,sum(salary),avg(age)from table1 group by company union

[0101] select sum(salary),avg(age)from table1 group by dept union

[0102] select sum(salary),avg(age)from table1 group by()

[0103] Based on the above embodiment, it can be seen that when executing the query statement select company,sum(salary),avg(age)from table1 group by cube(company,dept), the processor needs to query all records in the data table table1 four times.

[0104] When querying all records in table1 for the first time, the processor divides all records in table1 into four groups according to company and dept. It then performs aggregation calculations on the records in each group based on the query "company, sum(salary), avg(age)" to obtain the query result corresponding to the query statement select company, sum(salary), avg(age) from table1 group by (company, dept).

[0105] When querying all records in table1 for the second time, the processor divides all records in table1 into two groups according to company, and then performs aggregation calculations on the records in each group based on the query statement "company, sum(salary), avg(age)". The query result corresponding to the query statement "select company, sum(salary), avg(age) from table1 group by company" is obtained.

[0106] When querying all records in table1 for the third time, the processor divides all records in table1 into three groups based on dept. It then performs aggregation calculations on the records in each group based on the query "sum(salary),avg(age)" to obtain the query result corresponding to the query statement select sum(salary),avg(age) from table1 group by dept.

[0107] When querying all records in table1 for the fourth time, the processor does not need to group the records in table1. Alternatively, the processor groups the records in table1 into the same group. The processor then performs an aggregation calculation on the records in table1 based on the query "sum(salary),avg(age)" to obtain the query result corresponding to the query statement select sum(salary),avg(age) from table1 group by().

[0108] Finally, output the query results corresponding to select company,sum(salary),avg(age)from table1 group by(company,dept), select company,sum(salary),avg(age)from table1 group by company, select sum(salary),avg(age)from table1 group by dept, and select sum(salary),avg(age)from table1 group by() in turn to obtain the query result of the query statement select company,sum(salary),avg(age)from table1 group by cube(company,dept).

[0109] As can be seen from the above method, when the query statement includes enhanced grouping functions such as grouping sets(), rollup(), and cube(), the processor needs to query all records in the data table at least once. In addition, each time the processor queries the data table, it needs to group all records in the data table and then perform aggregation calculations on the records in the divided groups to obtain the query result corresponding to the query statement. The above query process requires a large amount of time and has low query efficiency. To solve this problem, the present application provides a query method and device.

[0110] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0111] Figure 1A shows a possible system architecture diagram applicable to the data query method provided in an embodiment of the present application. This implementation scenario is only an exemplary description, which only provides components related to an embodiment of the present invention, but Figure 1A is not a specific limitation on the application of the present invention. The system architecture includes a terminal device 101, a management node 102, and a computing node 103. The management node 102 and the computing node 103 can constitute a cloud data center. The terminal device 101 can log in to the management node 102 via the network. The management node 102 can communicate with the computing node 103 via the network. Among them, the network generally represents any telecommunications or computer network, including, for example, an intranet, a wide area network (WAN), a local area network (LAN), a personal area network (PAN), or the Internet.

[0112] The following describes the various components of the system architecture.

[0113] (1) Terminal device 101

[0114] The terminal device 101 can be a virtual machine or a physical machine, and the physical machine can be an ordinary computer, a tablet computer, a smart phone, etc. After the user logs in to the management node 102 using the terminal device (such as through a browser of an ordinary computer), he can submit query tasks on the management node 102.

[0115] Optionally, when submitting a query task to the management node 102 , the user may also configure the scale of computing resources used to execute the query task, such as the number of computing nodes, the number of processor cores, etc. The computing resources here will be provided by the computing node 103 .

[0116] (2) Management Node 102

[0117] The management node 102 can be a physical machine or a virtual machine. Physical machines include but are not limited to desktop computers, servers, laptops, and mobile devices.

[0118] After receiving the query task submitted by the terminal device, the management node 102 obtains the query statement corresponding to the query task and generates a corresponding plan tree based on the query statement, wherein the plan tree includes multiple tasks, and the multiple tasks include at least one grouping task. The management node 102 can also establish a dependency relationship of at least one grouping task. Afterwards, the management node 102 schedules the computing node 103 based on the plan tree and the dependency relationship of at least one grouping task, and the computing node 103 determines the query result corresponding to the query task.

[0119] Optionally, after receiving the query task submitted by the terminal device, the management node can determine the number of computing nodes that execute the query task, and be responsible for the life cycle management of the query task, such as task scheduling, task termination, etc.

[0120] In addition, the system usually includes at least two management nodes, which can back up each other. When one of the management nodes fails, the other can take over the business of the failed management node, thereby avoiding the unavailability of the entire computing node 103 due to hardware failure.

[0121] 1B is a schematic diagram of the structure of the management node 102 provided in an embodiment of the present application. At the hardware level, the management node 102 includes at least a processor 112, a memory 113, and a network card 114.

[0122] The processor 112 can be a central processing unit (CPU) that can be used to calculate or process data. For example, in this application, it can be used to process query tasks submitted by users. Figure 1B shows only one CPU 112. In actual applications, there are often multiple CPUs 112, wherein one CPU 112 has one or more CPU cores. This embodiment does not limit the number of CPUs and the number of CPU cores. In addition, when the CPU 112 is the main processor, the management node 102 may also include a coprocessor (not shown in Figure 2). The coprocessor can be used to process tasks dispatched by the CPU 112 to the coprocessor. The coprocessor includes but is not limited to: a graphics processing unit (GPU), a data processing unit (DPU), an application specific integrated circuit (ASIC), a system on chip (SOC), a field programmable gate array (FPGA), an embedded neural network processor (NPU), and the like.

[0123] Memory 113 refers to internal memory that directly exchanges data with CPU 112. It can read and write data at any time and at a high speed, and serves as temporary data storage for the operating system or other running programs. Memory 113 includes at least two types of memory. For example, memory 113 can be either random access memory (RAM) or read-only memory (ROM). For example, random access memory is dynamic random access memory (DRAM), storage class memory (SCM), static random access memory (SRAM), etc. As for read-only memory, for example, it can be programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), etc. In actual applications, the management node 102 can be configured with multiple memories 113, as well as different types of memories 113. This embodiment does not limit the number and type of memory 113. In addition, the memory 113 may also interact with the coprocessor, or the computing node 103 may include an internal memory that can directly exchange data with the coprocessor, which is not limited in the embodiments of the present application.

[0124] The network card 114 is used to communicate with components within the management node 102 or with external devices (such as the computing node 103). For example, the management node 102 schedules the computing node 103 through the network card according to the plan tree and the dependency relationship of at least one grouped task.

[0125] (3) Computing node 103

[0126] Computing node 103 can be a physical device (such as a server, desktop computer, etc.), a virtual machine, or a container. In the case where the system includes multiple computing nodes, each computing node can communicate with each other. Each computing node can be a node with the same configuration, such as a hardware structure (such as the hardware structure shown in Figure 1B) and hardware performance. Alternatively, each computing node includes components with the same hardware performance, such as each computing node includes a CPU with the same computing power.

[0127] The present application provides a data query method, which is described using the management node shown in FIG1A as an example. Referring to FIG2 , the method includes the following steps:

[0128] S201: A management node receives a query statement.

[0129] In an embodiment of the present application, the query statement may include an identifier of the first data table, Q1 projected fields, an enhanced grouping function, and M first fields associated with the enhanced grouping function, where M is a positive integer and Q1 is a positive integer. The enhanced grouping function is used to group the data in the first data table according to the M first fields.

[0130] The syntax format corresponding to the query statement may be as follows: select Q1 projection fields from the identifier-enhanced grouping function of the first data table (M first fields).

[0131] Projected fields can be of two forms: aggregate function fields and non-aggregate function fields. Aggregate function fields consist of an aggregate function and the column name in the first data table, while non-aggregate function fields are column names in the first data table and do not include an aggregate function.

[0132] For example, let's say the first data table is table1. Table 1 shows its contents, including five columns: name, company, dept, salary, and age. If the projected field is sum(salary), then sum(salary) is an aggregate function field, where salary is the name of a column in table1 and sum() is the aggregate function. If the projected field is avg(age), then avg(age) is also an aggregate function field, where age is the name of a column in table1 and avg() is the aggregate function.

[0133] If the projected field is company, then the projected field company is a non-aggregate function field, where company is the column name in the first data table table1. If the projected field is dept, then the projected field dept is a non-aggregate function field, where dept is the column name in the first data table table1.

[0134] The first field is composed of at least one column name in the first data table. For example, the query statement is select company,sum(salary),avg(age)from table1 group by grouping sets((company,dept),dept). In this query statement, grouping sets() is an enhanced grouping function, and the two first fields associated with this enhanced grouping function are (company,dept) and dept. The first first field (company,dept) is composed of two column names, and the second first field dept is composed of one column name. The above query statement also includes three projected fields, namely company, sum(salary), and avg(age). Among them, the projected field company is a non-aggregate function field, and the projected fields sum(salary) and avg(age) are both aggregate function fields.

[0135] For ease of understanding, the first field discussed subsequently consists of a column name in the first data table.

[0136] S202: The management node generates a plan tree according to the query statement.

[0137] In an embodiment of the present application, a plan tree includes multiple tasks, each of which is executed in the execution order specified in the plan tree. The multiple tasks may include tasks to be executed by a scan node in the plan tree, or tasks to be executed by an index node in the plan tree. The multiple tasks also include N grouping tasks generated according to the enhanced grouping function.

[0138] Specifically, each of the N grouping tasks corresponds to M second fields, and the M second fields corresponding to each grouping task are not exactly the same. In the M second fields corresponding to each grouping task, if the second field is the first field, it indicates that the second field needs to be grouped; if the second field is the third field, it indicates that the second field does not need to be grouped.

[0139] Specifically, among the N grouping tasks, there is at least one grouping task, and the M second fields in the at least one grouping task include at least one third field.

[0140] It should be understood that the third field can be a null field or other marked field, which is not limited here. The following description assumes that the third field is null.

[0141] In the embodiment of the present application, according to three different enhanced grouping functions, N grouping tasks corresponding to the three enhanced grouping functions can be determined respectively through the following three possible implementations.

[0142] In a first possible implementation, when the enhanced grouping function is a grouping sets() function, N grouping tasks can be determined by the following steps as shown in FIG3 .

[0143] S301: The management node determines a first setting mode according to a grouping sets() function.

[0144] In an embodiment of the present application, the first setting method corresponding to the grouping sets() function is to set any M-1 first fields among the M first fields in the query statement as the third field.

[0145] S302: The management node determines N grouping tasks according to the first setting method and the M first fields.

[0146] In an embodiment of the present application, the management node sets M first fields using a first setting method, and can obtain M-1 different grouping tasks.

[0147] For any grouping task among the M-1 grouping tasks, the grouping task includes M second fields, and the M second fields are composed of M-1 third fields and one first field.

[0148] For example, the query statement is select company,sum(salary),avg(age)from table1 group by grouping sets(company,dept), where grouping sets() is an enhanced grouping function and the two first fields associated with the enhanced grouping function are company and dept. Based on grouping sets() and the two first fields, two grouping tasks can be determined: the task of grouping by (company,null) and the task of grouping by (null,dept). The first grouping task includes two second fields: company and null, where company is the first field and null is the third field. The second grouping task includes two second fields: null and dept, where null is the third field and dept is the first field.

[0149] It should be understood that tasks grouped by (company, null) can also be abbreviated as tasks grouped by (company), and tasks grouped by (null, dept) can also be abbreviated as tasks grouped by (dept), and there is no limitation here.

[0150] In the above method, when the enhanced grouping function is a grouping sets() function, a method for determining N grouping tasks is provided.

[0151] In a second possible implementation, when the enhanced grouping function is a rollup() function, N grouping tasks may be determined through the following steps as shown in FIG4 .

[0152] S401: The management node determines a second setting mode according to the rollup() function.

[0153] In an embodiment of the present application, the second setting method corresponding to the rollup() function is to set the m first fields after the M first fields in the query statement as the third field in sequence, where m is an integer ranging from [0, M].

[0154] S402: The management node determines N grouping tasks according to the second setting mode and the M first fields.

[0155] In an embodiment of the present application, the management node uses the second setting method to set the M first fields, and can obtain M+1 different grouping tasks.

[0156] For any grouping task among the M+1 grouping tasks, the grouping task includes M second fields, and the M second fields are composed of at least one first field, or are composed of a third field.

[0157] For example, the query statement is select company,sum(salary),avg(age)from table1 group by rollup(company,dept), where rollup() is an enhanced grouping function and the two first fields associated with it are company and dept. Based on rollup() and the two first fields, three grouping tasks can be determined: grouping by (company,dept), grouping by (company,null), and grouping by (null,null). The first grouping task includes two second fields: company and dept, where both company and dept are first fields. The second grouping task includes two second fields: company and null, where company is the first field and null is the third field. The third grouping task includes two second fields: null and null, where both null and null are third fields.

[0158] It should be understood that tasks grouped according to (company, null) can also be abbreviated as tasks grouped according to (company), and tasks grouped according to (null, null) can also be abbreviated as tasks grouped according to (), and there is no limitation here.

[0159] In the above method, when the enhanced grouping function is a rollup() function, a method for determining N grouping tasks is provided.

[0160] In a third possible implementation, when the enhanced grouping function is a cube() function, N grouping tasks may be determined through the following steps as shown in FIG5 .

[0161] S501: The management node determines a third setting mode according to the cube() function.

[0162] In an embodiment of the present application, the third setting method corresponding to the cube() function is to set any m first fields of M first fields as the third field, where m is an integer ranging from [0, M].

[0163] S502: The management node determines N grouping tasks according to the third setting method and the M first fields.

[0164] In the embodiment of the present application, the management node sets the M first fields using the third setting method, and can obtain different grouping tasks, where C is the number of combinations in mathematical concepts, It indicates the total number of possible combinations that can be determined by selecting M-1 first fields from the M first fields without duplication to form a combination.

[0165] against Any grouping task among the grouping tasks, the grouping task includes M second fields, and the M second fields are composed of at least one first field, or are composed of a third field.

[0166] For example, the query statement is select company,sum(salary),avg(age) from table1 group by cube(company,dept), where cube() is an enhanced grouping function and the two first fields associated with it are company and dept. Based on cube() and the two first fields, four grouping tasks can be determined: group by (company,dept), group by (company,null), group by (null,dept), and group by (null,null). The first grouping task includes two second fields: company and dept, where both company and dept are first fields. The second grouping task includes two second fields: company and null, where company is the first field and null is the third field. The third grouping task includes two second fields: null and dept, where null is the third field and dept is the first field. The fourth grouping task includes two second fields: null and null, where both null and null are third fields.

[0167] It should be understood that tasks grouped according to (company, null) can also be abbreviated as tasks grouped according to (company), tasks grouped according to (null, dept) can also be abbreviated as tasks grouped according to (dept), and tasks grouped according to (null, null) can also be abbreviated as tasks grouped according to (), and there is no limitation here.

[0168] In the above method, when the enhanced grouping function is a cube() function, a method for determining N grouping tasks is provided.

[0169] S203, the management node establishes a dependency relationship among N grouping tasks according to the number of the third fields, wherein, among the grouping tasks with adjacent numbers of the third fields, the grouping tasks with a larger number of the third fields serve as child nodes, and the grouping tasks with a smaller number of the third fields serve as parent nodes, and the child nodes depend on the parent nodes.

[0170] In an embodiment of the present application, FIG6 shows a flow chart of a method for determining dependencies between N grouped tasks provided in an embodiment of the present application, which includes the following steps.

[0171] S601: The management node root determines the number of third fields corresponding to N grouping tasks.

[0172] For example, if the enhanced grouping function is grouping sets(), the query statement is select company, sum(salary), avg(age) from table1 group by grouping sets(company, dept). Grouping sets(company, dept) determines two grouping tasks: grouping by (company, null) and grouping by (null, dept). The first grouping task includes two second fields: company and null. One of these second fields is null. Therefore, the number of the third field in the first grouping task is 1. Similarly, the number of the third field in the second grouping task is also 1.

[0173] Therefore, the two grouping tasks corresponding to grouping sets (company, dept) and the number of the third field corresponding to each grouping task are as follows:

[0174] <Tasks grouped by (company, null), 1>

[0175] <Tasks grouped by (null, dept), 1>

[0176] For example, if the enhanced grouping function is rollup(), the query statement is select company,sum(salary),avg(age)from table1 group by rollup(company,dept). The three grouping tasks determined by rollup(company,dept) are grouped by (company,dept), (company,null), and (null,null). The first grouping task includes two second fields, company and dept, and neither is null. Therefore, the number of third fields in the first grouping task is 0. Similarly, the number of third fields in the second grouping task is determined to be 1, and the number of third fields in the third grouping task is determined to be 2.

[0177] Therefore, the three grouping tasks corresponding to rollup(company,dept) and the number of the third field corresponding to each grouping task are as follows:

[0178] <Tasks grouped by (company, dept), 0>

[0179] <Tasks grouped by (company, null), 1>

[0180] <Tasks grouped by (null,null), 2>

[0181] For example, if the enhanced grouping function is cube(), the query statement is select company,sum(salary),avg(age)from table1 group by cube(company,dept). The four grouping tasks determined by cube(company,dept) are grouping by (company,dept), grouping by (company,null), grouping by (null,dept), and grouping by (null,null). The first grouping task includes two second fields: company and null. Both second fields are not null, so the number of third fields in the first grouping task is 0. Similarly, the number of third fields in the second grouping task is 1, the third grouping task is 1, and the fourth grouping task is 2.

[0182] Therefore, the four grouping tasks corresponding to cube(company,dept) and the number of the third field corresponding to each grouping task are as follows:

[0183] <Tasks grouped by (company, dept), 0>

[0184] <Tasks grouped by (company, null), 1>

[0185] <Tasks grouped by (null, dept), 1>

[0186] <Tasks grouped by (null,null), 2>

[0187] S602: The management node constructs a dependency relationship between the N grouping tasks according to the N grouping tasks and the quantities of the third fields respectively corresponding to the N grouping tasks.

[0188] In an embodiment of the present application, the dependency relationship between N grouping tasks may include L layers, where L is an integer greater than or equal to 2. The dependency relationship includes a root node and N nodes located below the root node, wherein the root node is located at the first layer of the dependency relationship, and the N nodes are located at other layers of the dependency relationship except the first layer. The N nodes correspond to the N grouping tasks, which can also be understood as a one-to-one correspondence between the N nodes and the N grouping tasks.

[0189] For any node at the second level in the dependency relationship, the node is a child node of the root node, and the grouping task corresponding to the node does not depend on the grouping tasks corresponding to other nodes.

[0190] For any node outside the first and second layers in the dependency relationship, based on the parent-child relationship between the node and its parent node, the dependency relationship between the grouping task corresponding to the node and the grouping task corresponding to the parent node of the node can be determined, that is, the grouping task corresponding to the node depends on the grouping task corresponding to the parent node of the node.

[0191] In summary, since the dependency relationship includes a root node and N nodes, the dependency relationship can be used to represent the dependency relationship between N grouped tasks.

[0192] In one possible implementation, dependency relationships include two types. For different types of dependency relationships, dependency relationships can be constructed through the following two possible implementations.

[0193] In the first embodiment, when the dependency relationship includes L layers and L is equal to 2, the dependency relationship can be constructed by the method shown in FIG7 , including the following steps:

[0194] S701: The management node sets a root node at the first level of the dependency relationship.

[0195] In the embodiment of the present application, there is a root node in the dependency relationship.

[0196] S702 : The management node selects P2 grouping tasks with the smallest number of third fields from the numbers of third fields corresponding to N grouping tasks, where P2 is an integer equal to N.

[0197] In the embodiment of the present application, the number of third fields corresponding to the above-mentioned P2 grouping tasks is the same and the smallest.

[0198] S703: The management node sets P2 nodes at the second level of the dependency relationship, wherein the P2 nodes are all child nodes of the root node.

[0199] In the embodiment of the present application, the P2 nodes in the second layer correspond one-to-one to the P2 grouping tasks.

[0200] It should be understood that the positions of the P2 nodes at the second level of the dependency relationship are not prioritized.

[0201] For example, when the enhanced grouping function is the grouping sets() function, the query statement is select company,sum(salary),avg(age)from table1 group by grouping sets(company,dept). The grouping tasks corresponding to grouping sets(company,dept) and the number of third fields corresponding to the grouping tasks are as follows:

[0202] <Tasks grouped by (company, null), 1>

[0203] <Tasks grouped by (null, dept), 1>

[0204] The management node can construct a dependency relationship as shown in Figure 8(a) based on the grouping tasks corresponding to the grouping sets (company, dept) and the number of the third field corresponding to the grouping tasks, including the following process:

[0205] The management node first sets the root node at the first level of the dependency relationship. Since the number of the third field of each of the two grouped tasks corresponding to the grouping set (company, dept) is the smallest, the management node sets two nodes at the second level of the dependency relationship: the left node is the task grouped by (company, null), and the right node is the task grouped by (null, dept). Furthermore, both nodes set at the second level are children of the root node.

[0206] It should be understood that the management node can also construct a dependency relationship as shown in Figure 8(b). In the dependency relationship shown in Figure 8(b), the left node is the task grouped according to (null, dept), and the right node is the task grouped according to (company, null).

[0207] The above method can quickly build the dependency relationship of L layers, where L is equal to 2.

[0208] In the second embodiment, when the dependency relationship includes L layers, where L is an integer greater than 2, the dependency relationship can be constructed by the method shown in FIG9 , including the following steps:

[0209] S901: The management node sets a root node at the first level of the dependency relationship.

[0210] In the embodiment of the present application, there is a root node in the dependency relationship.

[0211] S902 : The management node selects P2 grouping tasks with the smallest number of third fields from the numbers of third fields corresponding to the N grouping tasks, where P2 is an integer smaller than N.

[0212] In the embodiment of the present application, the number of third fields corresponding to the above-mentioned P2 grouping tasks is the same and the smallest.

[0213] S903: The management node sets P2 nodes at the second level of the dependency relationship, wherein the P2 nodes are all child nodes of the root node.

[0214] In the embodiment of the present application, the P2 nodes in the second layer correspond one-to-one to the P2 grouping tasks. In the dependency relationship, the other layers except the first and second layers include P1 nodes, where P1 is an integer less than N, and P1+P2=N.

[0215] S904: The management node sets P3 nodes at the i-th layer of the dependency relationship, where i is an integer ranging from [3, L], and P3 is less than or equal to P1.

[0216] In an embodiment of the present application, the number of third fields of the grouping tasks corresponding to the above-mentioned P3 nodes in the i-th layer is the same. Among the P3 nodes in the i-th layer, the number of third fields of the grouping tasks corresponding to the p3-th node is greater than the number of third fields of the grouping tasks corresponding to each node in the i-1-th layer, where p3 is an integer that passes through [1, P3]. The difference between the number of third fields of the grouping tasks corresponding to the p3-th node and the number of third fields of the grouping tasks corresponding to each node in the i-1-th layer is a preset value. Generally speaking, the preset value is 1, but it can also be other values, such as 2.

[0217] One of the nodes in the i-1th layer is the parent node of the p3th node in the i-th layer, and the M second fields of the grouping task corresponding to the p3th node and the M second fields of the grouping task corresponding to the parent node of the p3th node satisfy the following relationship: when the mth second field in the M second fields of the grouping task corresponding to the parent node of the p3th node is the third field, the mth second field in the M second fields of the grouping task corresponding to the p3th node is also the third field, where m is an integer ranging from [0,M].

[0218] It should be understood that the positions of the nodes at each layer of the dependency relationship are not prioritized.

[0219] The above method can quickly construct the dependency relationship of L layers, where L is an integer greater than 2.

[0220] In combination with the method for constructing a dependency relationship shown in FIG7 and the method for constructing a dependency relationship shown in FIG9 , an embodiment of the present application provides a method for constructing an L-layer dependency relationship, where L is an integer greater than or equal to 2. The method for constructing a dependency relationship may include the following steps as shown in FIG10 :

[0221] S1001: The management node sets a root node at the first level of the dependency relationship.

[0222] S1002: The management node sets the current layer B=2.

[0223] S1003: The management node sets a set A and adds N grouping tasks to the set A.

[0224] S1004, the management node determines whether the set A is empty. If so, the process ends, that is, S1005 to S1013 are no longer executed; otherwise, S1005 is executed.

[0225] S1005 , the management node selects S grouping tasks with the smallest number of third fields from set A, and deletes the S grouping tasks from set A, where S is a positive integer.

[0226] In the embodiment of the present application, the number of third fields corresponding to the selected S grouping tasks is the same.

[0227] S1006, the management node determines whether B is equal to 2, and if so, executes S1007; otherwise, executes S1009.

[0228] S1007: The management node sets S nodes at the Bth layer of the dependency relationship, and all of the S nodes are child nodes of the root node.

[0229] In the embodiment of the present application, there is a one-to-one correspondence between S nodes and S grouping tasks.

[0230] Combined with the dependency construction method described above, the S nodes set in the second layer in S1007 are equivalent to the P2 nodes in S703 and also equivalent to the P2 nodes in S903.

[0231] S1008, the management node executes B=B+1, and after completing S1008, jumps to S1004.

[0232] S1009: The management node sets the variable s=1.

[0233] S1010, the management node determines whether s is equal to S. If so, execute S1004; otherwise, execute S1011.

[0234] S1011: The management node determines the parent node of the sth node at the B-1 layer.

[0235] In an embodiment of the present application, the parent node of the sth node is determined in the following manner: for any node in the B-1th layer, if the mth second field among the M second fields of the grouping task corresponding to the node in the B-1th layer is the third field, and the mth second field among the M second fields of the grouping task corresponding to the sth node is also the third field, where m is an integer ranging from [0,M], then the node in the B-1th layer can be used as the parent node of the sth node.

[0236] Combined with the dependency relationship construction method described above, the sth node in S1011 is equivalent to the p3th node in S904.

[0237] S1012: The management node sets the sth node at the Bth layer of the dependency relationship according to the parent node of the sth node.

[0238] In the embodiment of the present application, the sth node set in the B layer is a child node of the parent node of the sth node.

[0239] S1013, the management node executes s=s+1, and after completing S1013, jumps to S1010.

[0240] The above method can quickly construct the dependency relationship of L layers, where L is an integer greater than or equal to 2.

[0241] For example, if the enhanced grouping function is rollup(), the query statement is select company,sum(salary),avg(age)from table1 group by rollup(company,dept). The grouping tasks corresponding to rollup(company,dept) and the number of third fields corresponding to the grouping tasks are as follows:

[0242] <Tasks grouped by (company, dept), 0>

[0243] <Tasks grouped by (company, null), 1>

[0244] <Tasks grouped by (null,null), 2>

[0245] The management node can construct a dependency relationship as shown in FIG11 based on the grouped tasks corresponding to rollup (company, dept) and the number of the third field corresponding to the grouped tasks, including the following process:

[0246] The management node first sets a root node at the first level of the dependency relationship. Among the three grouping tasks corresponding to rollup (company, dept), the management node selects the grouping task with the smallest third field count. This is the task grouped by (company, dept). Based on the selected grouping task and the corresponding third field counts <(company, dept), 0>, the management node sets a node at the second level of the dependency relationship. This node represents the task grouped by (company, dept). Furthermore, the nodes set at the second level are children of the root node.

[0247] Among the remaining two grouping tasks corresponding to rollup (company, dept), the grouping task with the smallest third field count is selected, namely, the task grouped by (company, null). Based on the selected grouping task and the corresponding third field count (task grouped by (company, null), 1), the management node sets a node at the third level of the dependency relationship. This node is the task grouped by (company, null). Furthermore, the node set at the third level is a child of the node grouped by (company, dept) in the second level.

[0248] Of the remaining third fields corresponding to the grouped tasks corresponding to rollup(company,dept), only <2 tasks grouped by (null,null)> remain. The management node selects the tasks grouped by (null,null) and sets a node at the fourth level of the dependency relationship, which is the task grouped by (null,null). The two second fields of the grouped tasks corresponding to the node in the third level are (company,null), and the second of these two second fields is null. The two second fields of the grouped tasks corresponding to the node in the fourth level are (null,null), and the second of these two second fields is also null. In addition, the node set at the fourth level is a child node of the node for the task grouped by (company,null) in the third level.

[0249] For example, when the enhanced grouping function is the cube() function, the query statement is select company,sum(salary),avg(age)from table1 group by cube(company,dept). The grouping tasks corresponding to cube(company,dept) and the number of third fields corresponding to the grouping tasks are as follows:

[0250] <Tasks grouped by (company, dept), 0>

[0251] <Tasks grouped by (company, null), 1>

[0252] <Tasks grouped by (null, dept), 1>

[0253] <Tasks grouped by (null,null), 2>

[0254] The management node can construct a dependency relationship as shown in FIG12 based on the grouping task corresponding to cube (company, dept) and the number of the third field corresponding to the grouping task, including the following process:

[0255] The management node first sets a root node at the first level of the dependency relationship. Among the four grouping tasks corresponding to cube(company, dept), the management node selects the grouping task with the smallest number of third fields. This is the task grouped by (company, dept). Based on the selected grouping task and the number of third fields corresponding to the grouping task, <(company, dept), 0>, the management node sets a node at the second level of the dependency relationship. This node represents the task grouped by (company, dept). Furthermore, the nodes set at the second level are children of the root node.

[0256] Among the remaining three grouping tasks corresponding to cube(company,dept), the grouping task with the smallest number of third fields is selected, including the task grouped by (company,null) and the task grouped by (null,dept). Based on the selected grouping tasks and the number of third fields corresponding to the grouping tasks, <tasks grouped by (company,null), 1> and <tasks grouped by (null,dept), 1>, the management node sets two nodes at the third level of the dependency relationship. The left node at the third level is the task grouped by (company,null), and the right node is the task grouped by (null,dept); alternatively, the left node at the third level is the task grouped by (null,dept), and the right node is the task grouped by (company,null). Furthermore, both the left and right nodes set at the third level are child nodes of the node for the task grouped by (company,dept) in the second level.

[0257] The dependency relationship shown in FIG12 is described by taking the third layer where the left node is a task grouped according to (company, null) and the right node is a task grouped according to (null, dept) as an example.

[0258] For the number of third fields corresponding to the remaining grouping tasks corresponding to cube(company,dept), the management node sets one node at the fourth level of the dependency relationship based on the selected grouping task, namely, the task grouped according to (null,null). This node is the task grouped according to (null,null). The two second fields of the grouping task corresponding to the left node in the third level are (company,null), and the second of these two second fields is null. The two second fields of the grouping task corresponding to the node in the fourth level are (null,null), and the second of these two second fields is also null. Therefore, the node set at the fourth level can be a child node of the left node in the third level. Similarly, the node set at the fourth level can also be a child node of the right node in the third level.

[0259] The dependency relationship shown in FIG12 is described by taking the node set in the fourth layer as the child node of the left node in the third layer as an example.

[0260] It should be understood that both S202 and S203 in FIG. 2 can be encapsulated in an expand operator in the database engine.

[0261] S204 , when N grouping tasks are executed according to the plan tree, the management node executes the N grouping tasks according to the dependency relationship.

[0262] In an embodiment of the present application, the management node schedules the computing nodes based on the tasks in the plan tree. The computing nodes then execute the tasks and determine the execution results of the tasks. For example, for a scan data table task in the plan tree, the management node sends the scan data table task to the computing node responsible for scanning, which then executes the scan data table task. For a grouping task in the plan tree, the management node sends the grouping task to the computing node responsible for grouping, which then executes the grouping task.

[0263] In addition, the management node can also schedule the computing nodes responsible for grouping according to the dependency relationship between the N grouping tasks. The computing nodes responsible for grouping execute the corresponding grouping tasks according to the assigned grouping tasks, and finally achieve the purpose of executing N grouping tasks.

[0264] In one possible implementation, when the management node schedules N group tasks according to the dependency relationship, it first schedules the group tasks with the least number of third fields, and then schedules the group tasks with the larger number of third fields, and sends each group task to the computing node to execute the corresponding group task. In the process of the computing node executing N group tasks, the execution result of the parent node in the dependency relationship is used as the input data for executing the child node until the N group tasks are completed.

[0265] There are P1 grouping tasks among the N grouping tasks. The group aggregation result corresponding to the p1th grouping task in the P1 grouping tasks is determined based on the group aggregation results corresponding to the grouping tasks on which the p1th grouping task depends. P1 is an integer less than N, and p1 is an integer that spans [0, P1]. In addition, there are P2 grouping tasks among the N grouping tasks. The group aggregation result corresponding to each grouping task in the P2 grouping tasks is determined based on the first data table. Here, P1 + P2 = N.

[0266] In one possible implementation, the management node traverses the dependency relationships hierarchically, determines the nodes in each layer except the first layer, and sends the grouping tasks corresponding to each node to the computing node. The computing node executes each grouping task and obtains the grouping aggregation results corresponding to each task.

[0267] Since dependency relationships include two types, for different types of dependency relationships, the group aggregation results corresponding to the N group tasks can be determined through the following two possible implementations.

[0268] In the first embodiment, when the dependency relationship includes L layers and L is equal to 2, the group aggregation results corresponding to the N group tasks can be determined by the following steps as shown in FIG13 :

[0269] S1301: The management node traverses the dependency relationship to obtain P2 nodes located at the second level in the dependency relationship.

[0270] S1302, for the p2th node among the P2 nodes, the management node sends the grouping task corresponding to the p2th node to the computing node, and the computing node groups and aggregates the first data table to obtain the grouping aggregation result of the grouping task corresponding to the p2th node, where p2 is an integer that traverses [1, P2].

[0271] The above method provides a convenient way to determine the group aggregation results corresponding to the grouping tasks.

[0272] In a possible implementation, the computing node may determine the grouping aggregation result of the grouping task corresponding to the p2-th node in S1302 through the following steps shown in FIG. 14 .

[0273] S1401: The computing node selects Q2 projection fields from Q1 projection fields in the query statement according to the M second fields in the grouping task corresponding to the p2th node, where Q2 is an integer less than or equal to Q1.

[0274] In the embodiment of the present application, for the q1th projection field among Q1 projection fields, where q1 is an integer ranging from [1, Q1], the following steps are performed:

[0275] When the q1th projection field is an aggregate function field, the computing node retains the q1th projection field;

[0276] If the q1th projection field is a non-aggregation function field and the M second fields in the grouping task corresponding to the p2th node include the q1th projection field, the computing node retains the q1th projection field;

[0277] If the q1th projection field is a non-aggregation function field and the M second fields in the grouping task corresponding to the p2th node do not include the q1th projection field, the computing node deletes the q1th projection field;

[0278] Finally, the retained projection fields in the Q1 projection fields form Q2 projection fields, and the Q2 projection fields are the projection fields of the grouping task corresponding to the p2th node.

[0279] It should be understood that when the grouping tasks corresponding to different nodes in the dependency relationship are different, the Q2 projection fields selected from the same Q1 projection fields are also different.

[0280] For example, the query statement is select company,sum(salary),avg(age)from table1 group by grouping sets(company,dept). Company, sum(salary), and avg(age) are all projected fields, and grouping sets() is an enhanced grouping function. The number of grouping tasks and third fields corresponding to grouping sets(company,dept) are as follows:

[0281] <Tasks grouped by (company, null), 1>

[0282] <Tasks grouped by (null, dept), 1>

[0283] The management node constructs a dependency relationship as shown in FIG8( a ) based on the grouping tasks corresponding to the grouping sets (company, dept) and the number of the third field corresponding to the grouping tasks.

[0284] Taking the left node of the second layer of the dependency relationship in Figure 8(a) as an example, we will introduce in detail how to determine the projection field of the grouping task corresponding to the left node of the second layer:

[0285] The grouping task corresponding to the left node of the second layer is a task of grouping according to (company, null), and the grouping task includes two second fields, namely company and null.

[0286] For the projection field company, the projection field company is a non-aggregate field, and the two second fields (company, null) in the grouping task corresponding to the left node of the second layer include the projection field company. The calculation node retains the projection field company.

[0287] For the projected field sum(salary), the projected field sum(salary) is an aggregated field, and the calculation node retains the projected field sum(salary).

[0288] For the projected field avg(age), the projected field avg(age) is an aggregated field, and the calculation node retains the projected field avg(age).

[0289] In summary, for the grouping task corresponding to the left node of the second layer in Figure 8(a), three projection fields can be selected from the three projection fields in the query statement. The three selected projection fields are company, sum(salary), and avg(age).

[0290] For the right node of the second layer of the dependency relationship in Figure 8(a), the method of determining the projection field of the grouping task corresponding to the right node of the second layer is the same as the method of determining the projection field of the grouping task corresponding to the left node of the second layer, and will not be repeated here.

[0291] S1402: The computing node performs grouping and aggregation on the first data table using the grouping task corresponding to the p2th node and Q2 projection fields to obtain the grouping and aggregation result of the grouping task corresponding to the p2th node.

[0292] In an embodiment of the present application, the computing node groups the first data table according to the M second fields in the grouping task corresponding to the p2th node, and then performs aggregation calculation on the records in each group according to the Q2 projection fields to obtain the grouping aggregation result of the grouping task corresponding to the p2th node.

[0293] In one possible implementation, you can perform aggregation calculations on the records in each group in the following way:

[0294] In any group, for the q2th projected field among the Q2 projected fields, if the q2th projected field is an aggregate function field, the compute node performs an aggregation calculation on the records in the group based on the q2th projected field, obtaining the aggregate result corresponding to the q2th projected field. If the q2th projected field is a non-aggregate function field, the compute node does not perform an aggregation operation on the records in the group, but instead directly obtains the data corresponding to the q2th projected field from the group, where q2 is an integer spanning [1, Q2]. Finally, the compute node uses the aggregate result corresponding to the aggregate function field and the data corresponding to the non-aggregate function field in the Q2 projected fields as the group aggregation result corresponding to the group.

[0295] In the above method, first, according to the M second fields in the grouping task corresponding to the node in the dependency relationship, the relevant Q2 projection fields are selected from the Q1 projection fields. Since the selected Q2 projection fields are all related to the M second fields of the node, the first data table is grouped and aggregated according to the grouping task corresponding to the node and the Q2 projection fields, which is conducive to improving the efficiency of grouping and aggregation.

[0296] In the second embodiment, when the dependency relationship includes L layers, where L is an integer greater than 2, the group aggregation results corresponding to the N group tasks can be determined by the following steps as shown in FIG15 :

[0297] S1501: The management node traverses the dependency relationship to obtain P2 nodes located at the second level in the dependency relationship.

[0298] S1502, for the p2th node among the P2 nodes, the management node sends the grouping task corresponding to the p2th node to the computing node, and the computing node groups and aggregates the first data table to obtain the grouping aggregation result of the grouping task corresponding to the p2th node, where p2 is an integer that traverses [1, P2].

[0299] It should be understood that the method for obtaining the grouping aggregation result of the grouping task corresponding to the p2th node in S1502 can refer to the method for obtaining the grouping aggregation result of the grouping task corresponding to the p2th node in S1302, which is not repeated here.

[0300] S1503: The management node traverses the dependency relationship to obtain P3 nodes located at the i-th layer in the dependency relationship, where i is an integer traversing [3, L].

[0301] In this embodiment of the present application, each layer in the dependency relationship, except for the first and second layers, includes P1 nodes. The grouping aggregation result of the grouping task corresponding to each node in the P1 node is determined based on the pre-aggregation result of each node. The pre-aggregation result of each node is the grouping aggregation result of the grouping task corresponding to the parent node of each node.

[0302] S1504, for the p3th node among the P3 nodes, the management node sends the grouping task corresponding to the p3th node to the computing node, and the computing node obtains the pre-aggregation result corresponding to the p3th node. The pre-aggregation result corresponding to the p3th node is the grouping aggregation result of the grouping task corresponding to the parent node of the p3th node, and p3 is an integer that traverses [1, P3].

[0303] S1505 , the computing node uses the M second fields in the grouping task corresponding to the p3 th node to perform grouping aggregation on the pre-aggregation result corresponding to the p3 th node, and obtains the grouping aggregation result of the grouping task corresponding to the p3 th node.

[0304] In the above method, when calculating the group aggregation results of the grouping tasks corresponding to the nodes at the i-th layer in the dependency relationship, where i is an integer ranging from [3, L], the computing node groups and aggregates the pre-aggregation results of the nodes at the i-th layer instead of grouping and aggregating the first data table. Since the records in the pre-aggregation results are much smaller than the records in the first data table, the above method is conducive to improving query efficiency and reducing time overhead.

[0305] In a possible implementation, the computing node may determine the grouping aggregation result of the grouping task corresponding to the p3th node in S1505 through the following steps shown in FIG. 16 .

[0306] S1601: The computing node selects Q2 projection fields from Q1 projection fields in the query statement according to the M second fields in the grouping task corresponding to the p3th node, where Q2 is an integer less than or equal to Q1.

[0307] For the q1th projection field among Q1 projection fields, where q1 is an integer spanning [1, Q1], perform the following steps:

[0308] When the q1th projection field is an aggregate function field, the computing node retains the q1th projection field;

[0309] If the q1th projection field is a non-aggregation function field and the M second fields in the grouping task corresponding to the p3th node include the q1th projection field, the computing node retains the q1th projection field;

[0310] If the q1th projection field is a non-aggregation function field and the M second fields in the grouping task corresponding to the p3th node do not include the q1th projection field, the computing node deletes the q1th projection field;

[0311] Finally, the retained projection fields in the Q1 projection fields form Q2 projection fields, and the Q2 projection fields are the projection fields of the grouping task corresponding to the p3th node.

[0312] It should be understood that when the grouping tasks corresponding to different nodes in the dependency relationship are different, the Q2 projection fields selected from the same Q1 projection fields are also different.

[0313] For example, the query statement is select company,sum(salary),avg(age)from table1 group by rollup(company,dept). Company, sum(salary), and avg(age) are all projected fields, and rollup() is an enhanced grouping function. The number of grouping tasks corresponding to rollup(company,dept) and the number of third fields corresponding to the grouping tasks are as follows:

[0314] <Tasks grouped by (company, dept), 0>

[0315] <Tasks grouped by (company, null), 1>

[0316] <Tasks grouped by (null,null), 2>

[0317] The management node constructs a dependency relationship as shown in FIG11 based on the grouping task corresponding to rollup (company, dept) and the number of the third field corresponding to the grouping task.

[0318] For the nodes of the second layer of the dependency relationship in Figure 11, the method of determining the projection field of the grouping task corresponding to the nodes of the second layer is the same as the method of determining the projection field of the grouping task corresponding to the left node of the second layer of the dependency relationship in Figure 8(a), and will not be repeated here.

[0319] Taking the nodes in the third layer of the dependency relationship in Figure 11 as an example, this article describes in detail how to determine the projection fields of the grouping tasks corresponding to the nodes in the third layer:

[0320] The grouping task corresponding to the nodes in the third layer is a task of grouping according to (company, null), which includes two second fields, namely company and null.

[0321] For the projected field company, the projected field company is a non-aggregated field, and the two second fields (company, null) in the grouping task corresponding to the third-layer node include the projected field company. Therefore, the calculation node retains the projected field company.

[0322] For the projected field sum(salary), the projected field sum(salary) is an aggregated field. Therefore, the calculation node retains the projected field sum(salary).

[0323] For the projected field avg(age), the projected field avg(age) is an aggregated field. Therefore, the calculation node retains the projected field avg(age).

[0324] In summary, for the grouping task corresponding to the third-layer node in Figure 11, that is, the task of grouping by (company, null), three projection fields can be selected from the three projection fields in the query statement. The selected three projection fields are company, sum(salary), and avg(age).

[0325] For the nodes in the fourth layer of the dependency relationship in Figure 11, the method of determining the projection fields of the grouping tasks corresponding to the nodes in the fourth layer is the same as the method of determining the projection fields of the grouping tasks corresponding to the nodes in the third layer, and will not be repeated here.

[0326] S1602: The computing node uses the grouping task corresponding to the p3th node and Q2 projection fields to group and aggregate the pre-aggregation result corresponding to the p3th node to obtain the grouping aggregation result of the grouping task corresponding to the p3th node.

[0327] In one possible implementation, the computing node groups the pre-aggregation results corresponding to the p3th node according to the M second fields in the grouping task corresponding to the p3th node, and then performs aggregation calculation on the records in each group according to the Q2 projection fields to obtain the group aggregation result of the grouping task corresponding to the p3th node.

[0328] In one possible implementation, you can perform aggregation calculations on the records in each group in the following way:

[0329] In any group, for the q2th projected field among the Q2 projected fields, if the q2th projected field is an aggregate function field, the compute node performs an aggregation calculation on the records in the group based on the q2th projected field, obtaining the aggregate result corresponding to the q2th projected field. If the q2th projected field is a non-aggregate function field, the compute node does not perform an aggregation operation on the records in the group and directly obtains the data corresponding to the q2th projected field from the group, where q2 is an integer spanning [1, Q2]. Finally, the compute node uses the aggregate result corresponding to the aggregate function field and the data corresponding to the non-aggregate function field in the Q2 projected fields as the group aggregation result corresponding to the group.

[0330] In the above method, first, according to the M second fields in the grouping task corresponding to the node in the dependency relationship, the relevant Q2 projection fields are selected from the Q1 projection fields. Since the selected Q2 projection fields are all related to the M second field groups of the node, the pre-aggregation results of the node are grouped and aggregated according to the grouping task corresponding to the node and the Q2 projection fields, which is conducive to improving the grouping and aggregation efficiency.

[0331] It should be understood that S204 in FIG. 2 can be encapsulated in a hash aggregation operator.

[0332] In the above method, for query statements containing enhanced grouping functions, there is no need to group and aggregate the records in the data table every time. Instead, the obtained grouping and aggregation results can be grouped and aggregated. Since the records in the grouping and aggregation results are much smaller than the records in the data table, the above method is conducive to improving query efficiency and reducing time overhead.

[0333] Based on the above embodiments, the present application also provides a data query device, which is applied to the management node shown in FIG1A and is used to implement the data query method provided in the embodiment shown in FIG2. Referring to FIG17, the device includes: a receiving module 1701, a generating module 1702, a establishing module 1703, and an executing module 1704.

[0334] A receiving module 1701 is configured to receive a query statement, the query statement including an enhanced grouping function, the enhanced grouping function being configured to group data in a table according to M first fields, where M is a positive integer;

[0335] A generating module 1702 is configured to generate a plan tree according to a query statement, the plan tree including a plurality of tasks, the plurality of tasks including N grouping tasks generated according to a grouping function, and the M second fields in at least one of the N grouping tasks including at least one third field, the third field indicating that grouping is not required;

[0336] Establishing module 1703, configured to establish a dependency relationship among N grouping tasks according to the number of the third fields, wherein, among grouping tasks with adjacent numbers of third fields, the grouping task with a larger number of third fields serves as a child node, and the grouping task with a smaller number of third fields serves as a parent node, and the child node depends on the parent node;

[0337] Execution module 1704 is used to execute N grouping tasks according to the dependency relationship when executing N grouping tasks according to the plan tree, among which the grouping task with the least number of third fields is executed first, and the execution result of the parent node is used as input data for executing the child node until the N grouping tasks are completed.

[0338] In a possible implementation, the enhanced grouping function includes any one of a grouping sets() function, a rollup() function, or a cube() function.

[0339] In one possible implementation, the dependency relationship includes a root node and N nodes located below the root node; the N nodes correspond to N grouping tasks; the dependency relationship includes L layers, L is an integer greater than or equal to 2, and the root node is located at the first layer in the dependency relationship; the second layer in the dependency relationship includes P1 nodes, the P1 node is a child node of the root node, the number of third fields of the grouping tasks corresponding to the P1 nodes are the same, the number of third fields of the grouping tasks corresponding to the P1 nodes is the smallest among the numbers of third fields of the N grouping tasks, and P1 is an integer less than or equal to N.

[0340] In one possible implementation, the other layers in the dependency relationship except the first layer and the second layer include P2 nodes; the i-th layer in the dependency relationship includes P3 nodes, the number of third fields of the grouping tasks corresponding to the P3 nodes is the same, and the number of third fields of the grouping tasks corresponding to the p3-th node in the P3 nodes is greater than the number of third fields of the grouping tasks corresponding to each node in the i-1-th layer in the dependency relationship; when the m-th second field among the M second fields of the grouping task corresponding to the parent node of the p3-th node is the third field, the m-th second field among the M second fields of the grouping task corresponding to the p3-th node is the third field, P2 is an integer less than N, m is an integer that traverses [0, M], P3 is an integer less than or equal to P2, i is an integer that traverses [3, L], and p3 is an integer that traverses [1, P3].

[0341] In a possible implementation, the execution module 1704 is specifically configured to perform a hierarchical traversal of dependency relationships and execute N grouping tasks.

[0342] In the embodiments of the present application, the receiving module, generating module, establishing module, and executing module can all be implemented by software or hardware. For example, the following describes the implementation of the executing module using the executing module as an example. Similarly, the implementation of the receiving module, generating module, and establishing module can refer to the implementation of the executing module.

[0343] As an example of a software functional unit, a module may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the execution module may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.

[0344] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.

[0345] As an example of a hardware functional unit, an execution module may include at least one computing device, such as a server. Alternatively, the execution module may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0346] The multiple computing devices included in the execution module can be distributed in the same region or in different regions. The multiple computing devices included in the execution module can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the execution module can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.

[0347] It should be noted that, in other embodiments, a receiving module is used to receive a query statement, the query statement includes an enhanced grouping function, the enhanced grouping function is used to group the data in the table according to M first fields, where M is a positive integer; a generating module is used to generate a plan tree according to the query statement, the plan tree includes multiple tasks, the multiple tasks include N grouping tasks generated according to the grouping function, and the M second fields of at least one of the N grouping tasks include at least one third field, and the third field indicates that grouping is not required; an establishing module is used to establish a dependency relationship of the N grouping tasks according to the number of third fields, wherein, among the grouping tasks with adjacent numbers of third fields, the grouping task with a larger number of third fields serves as a child node, and the grouping task with a smaller number of third fields serves as a parent node, and the child node depends on the parent node; an executing module is used to execute the N grouping tasks according to the dependency relationship when the N grouping tasks are executed according to the plan tree, wherein the grouping task with the least number of third fields is executed first, and the execution result of the parent node is used as input data for executing the child node until the N grouping tasks are completed. The steps that the receiving module, generating module, establishing module and executing module are responsible for implementing can be specified as needed. The receiving module, generating module, establishing module and executing module respectively implement different steps in the data query method to realize the full functions of the data query device.

[0348] Based on the above embodiments, the present application also provides a data query device, which is used to implement the data query method shown in FIG2 and has the functions of the data query device shown in FIG17. Referring to FIG18, the data query device 1800 includes: a processor 1801 and a memory 1802.

[0349] The processor 1801 and the memory 1802 are interconnected. Optionally, the processor 1801 and the memory 1802 may be interconnected via a bus 1803; the bus 1803 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, FIG18 shows only one thick line, but this does not mean that there is only one bus or one type of bus.

[0350] Optionally, the data query device 1800 further includes a communication module 1804 for communicating with other devices. Optionally, the communication module 1804 can communicate with other devices via a wireless connection, for example, the communication module 1804 can be an RF circuit, a WiFi module, etc. The communication module 1804 can also communicate with other devices via a physical connection, for example, the communication module 1804 can be a communication interface.

[0351] The processor 1801 is used to implement the data query method shown in FIG2 . The specific process can refer to the specific description in the above embodiment and will not be repeated here.

[0352] The memory 1802 is used to store programs and data. Specifically, the program may include program code, which includes instructions for computer operations. The memory 1802 may include random access memory (RAM) and may also include non-volatile memory (non-volatile memory), such as at least one disk storage device. The processor 1801 executes the program stored in the memory 1802 to implement the above functions, thereby realizing the data query method shown in Figure 2.

[0353] In summary, the embodiments of the present application provide a data query device that can improve query efficiency and reduce time overhead.

[0354] This application also provides a computing device 1900. As shown in Figure 19, computing device 1900 includes a bus 1901, a processor 1902, a memory 1904, and a communication interface 1903. Processor 1902, memory 1904, and communication interface 1903 communicate with each other via bus 1901. Computing device 1900 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 1900.

[0355] Bus 1901 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG19 illustrates a single bus line, but this does not imply a single bus or type of bus. Bus 1901 may include a path for transmitting information between various components of computing device 1900 (e.g., memory 1904, processor 1902, and communication interface 1903).

[0356] The processor 1902 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0357] The memory 1904 may include volatile memory, such as random access memory (RAM). The processor 1902 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0358] The memory 1904 stores executable program code, and the processor 1902 executes the executable program code to respectively implement the functions of the aforementioned receiving module, generating module, establishing module, and executing module, thereby implementing the data query method. In other words, the memory 1904 stores instructions for executing the data query method.

[0359] The communication interface 1903 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1900 and other devices or a communication network.

[0360] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0361] As shown in Figure 20, the computing device cluster includes at least one computing device 1900. The memory 1904 in one or more computing devices 1900 in the computing device cluster may store the same instructions for executing the data query method.

[0362] In some possible implementations, the memory 1904 of one or more computing devices 1900 in the computing device cluster may also store some instructions for executing the data query method. In other words, the combination of one or more computing devices 1900 can jointly execute the instructions for executing the data query method.

[0363] It should be noted that the memory 1904 in different computing devices 1900 in the computing device cluster can store different instructions, each for executing a portion of the functions of the data query apparatus. In other words, the instructions stored in the memory 1904 in different computing devices 1900 can implement the functions of one or more of the receiving module, generating module, establishing module, and executing module.

[0364] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network (WAN) or a local area network (LAN), among others. FIG. 21 illustrates a possible implementation. As shown in FIG. 21 , two computing devices 1900A and 1900B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 1904 in the computing device 1900A stores instructions for executing the functions of a receiving module and a generating module. Simultaneously, the memory 1904 in the computing device 1900B stores instructions for executing the functions of a establishing module and an executing module.

[0365] It should be understood that the functionality of the computing device 1900A shown in FIG21 may also be implemented by multiple computing devices 1900. Similarly, the functionality of the computing device 1900B may also be implemented by multiple computing devices 1900.

[0366] The present application also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similar to the connection method of the computing device cluster described in Figures 20 and 21. However, the memory 1904 in one or more computing devices 1900 in this computing device cluster can store the same instructions for executing the data query method.

[0367] In some possible implementations, the memory 1904 of one or more computing devices 1900 in the computing device cluster may also store some instructions for executing the data query method. In other words, the combination of one or more computing devices 1900 can jointly execute the instructions for executing the data query method.

[0368] The present application also provides a computer program product comprising instructions. The computer program product may be software or a program product comprising instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the data query method.

[0369] The present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the data query method.

[0370] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the various embodiments of the present invention.

[0371] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0372] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each flow and / or box in the flow chart and / or block diagram, as well as the combination of the flow chart and / or box in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more flow charts and / or one or more boxes in the block diagram.

[0373] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0374] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0375] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. A data query method, characterized in that: The method comprises: Receive a query statement, the query statement including an enhanced grouping function, the enhanced grouping function being used to group data in a first data table according to M first fields, where M is a positive integer; Generate a plan tree according to the query statement, the plan tree including a plurality of tasks, the plurality of tasks including N grouping tasks generated according to the enhanced grouping function, and the M second fields in at least one grouping task among the N grouping tasks include at least one third field, the third field indicating that grouping is not required; A dependency relationship is established among the N grouping tasks according to the number of the third fields, wherein, among the grouping tasks with adjacent numbers of the third fields, the grouping task with a larger number of the third fields serves as a child node, and the grouping task with a smaller number of the third fields serves as a parent node, and the child node depends on the parent node; When the N grouping tasks are executed according to the plan tree, the N grouping tasks are executed according to the dependency relationship, wherein the grouping task with the least number of third fields is executed first, and the execution result of the parent node is used as input data for executing the child node until the N grouping tasks are completed.

2. The method according to claim 1, wherein The enhanced grouping function includes any one of a grouping sets() function, a rollup() function, or a cube() function.

3. The method according to any one of claims 1-2, characterized in that The dependency relationship includes a root node and N nodes located below the root node; the N nodes correspond to the N grouping tasks; The dependency relationship includes L layers, where L is an integer greater than or equal to 2, and the root node is located at the first layer in the dependency relationship; The second layer in the dependency relationship includes P1 nodes, which are child nodes of the root node. The number of the third fields of the grouping tasks corresponding to the P1 nodes is the same. The number of the third fields of the grouping tasks corresponding to the P1 nodes is the smallest among the numbers of the third fields of the N grouping tasks, and P1 is an integer less than or equal to N.

4. The method according to claim 3, wherein The other layers in the dependency relationship except the first layer and the second layer include P2 nodes; the i-th layer in the dependency relationship includes P3 nodes, the number of the third fields of the grouping tasks corresponding to the P3 nodes is the same, and the number of the third fields of the grouping tasks corresponding to the p3-th node in the P3 nodes is greater than the number of the third fields of the grouping tasks corresponding to each node in the i-1-th layer in the dependency relationship; In the case where the mth second field among the M second fields of the grouping task corresponding to the parent node of the p3th node is the third field, the mth second field among the M second fields of the grouping task corresponding to the p3th node is the third field, P2 is an integer less than N, m is an integer that runs through [0, M], P3 is an integer less than or equal to P2, i is an integer that runs through [3, L], and p3 is an integer that runs through [1, P3].

5. The method according to any one of claims 3-4, characterized in that: The executing the N grouping tasks according to the dependency relationship includes: The dependency relationship is traversed hierarchically, and the N grouping tasks are executed.

6. A data query device, characterized in that: include: A receiving module, configured to receive a query statement, wherein the query statement includes an enhanced grouping function, wherein the enhanced grouping function is configured to group data in a table according to M first fields, where M is a positive integer; a generating module, configured to generate a plan tree according to the query statement, the plan tree including a plurality of tasks, the plurality of tasks including N grouping tasks generated according to the grouping function, and the M second fields in at least one grouping task of the N grouping tasks including at least one third field, the third field indicating that grouping is not required; an establishing module, configured to establish a dependency relationship among the N grouping tasks according to the number of the third fields, wherein, among the grouping tasks with adjacent numbers of the third fields, the grouping task with a larger number of the third fields serves as a child node, and the grouping task with a smaller number of the third fields serves as a parent node, and the child node depends on the parent node; An execution module is used to execute the N grouping tasks according to the dependency relationship when executing the N grouping tasks according to the plan tree, wherein the grouping task with the least number of third fields is executed first, and the execution result of the parent node is used as input data for executing the child node until the N grouping tasks are completed.

7. A data query device, characterized in that: Including memory and processor: The memory is used to store computer programs; The processor is configured to call and execute the computer program to implement the method according to any one of claims 1 to 5.

8. A computing device cluster, characterized in that: comprising at least one computing device, each computing device including a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in a memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 5.

9. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster is caused to perform the method according to any one of claims 1 to 5.

10. A computer-readable storage medium, characterized in that The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Batch data query method and device

    CN105677683A

  • Data aggregation in hierarchical structure for query execution

    CN118043798A

  • Using relational structures to create and support a cube within a relational database system

    US20040034616A1