Database query statement processing method and related product

By identifying and converting the dereplicated aggregation function in the database query statement, generating grouping subqueries, and calculating the aggregation function using the hash grouping method, the problem of low processing performance of the dereplicated aggregation function in the existing technology is solved, and the database query performance is improved.

CN119311731APending Publication Date: 2025-01-14CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411311424.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

When processing query statements, the processing performance of derelocated aggregation functions is low, which affects the improvement of database query performance.

Method used

By determining whether there is a dereplicated aggregation function in the database query statement, and performing corresponding conversion operations based on its number, eliminating the dereplicated nature, thereby generating a grouping subquery, and using hash grouping method to calculate the aggregation function to avoid the problem that the optimizer cannot operate in parallel. .

Benefits of technology

It improves the processing performance of the database for dereplicating aggregation functions, significantly reducing the consumption of database resources and query time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311731A_ABST
    Figure CN119311731A_ABST
Patent Text Reader

Abstract

The invention provides a database query statement processing method and a related product. The method comprises the following steps: acquiring a database query statement; judging whether the database query statement has a deduplication aggregation function or not, wherein the deduplication aggregation function is an aggregation function with a deduplication property; if yes, counting the number of deduplication aggregation functions; and performing corresponding conversion operation on the database query statement according to the number of the deduplication aggregation functions, thereby eliminating the deduplication properties in the deduplication aggregation functions. By means of the method, after the aggregation function with the deduplication property is converted, the database can also calculate the aggregation function through the Hash grouping method, so that the situation that due to the fact that deduplication keywords exist in the aggregation function in an original statement, an optimizer cannot operate in parallel is avoided, and the processing performance of the database on the deduplication aggregation function is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a method for processing database query statements and related products. Background Art

[0002] For a given query statement, there are usually multiple possible strategies. Query optimization is the process of finding the most effective query execution plan. For the same query statement, the cost of different execution plans may be very different. The task of the database system optimizer is to generate the optimal query execution.

[0003] In the database system in the prior art, the optimizer has low processing performance in deduplication operations, which affects the improvement of database query performance. Summary of the invention

[0004] In view of the above problems, the present invention proposes a method for processing database query statements and related products that overcome the above problems or at least partially solve the above problems.

[0005] One object of the present invention is to improve the execution efficiency of a database for a de-duplication aggregation function.

[0006] A further object of the present invention is to improve the processing performance of the database.

[0007] In particular, the present invention provides a method for processing a database query statement, comprising:

[0008] Get database query statements;

[0009] Determine whether there is a deduplication aggregation function in the database query statement, where the deduplication aggregation function is an aggregation function with deduplication properties;

[0010] If so, count the number of de-aggregation functions;

[0011] According to the number of the de-duplication aggregation functions, the database query statement is converted accordingly, thereby eliminating the de-duplication property in the de-duplication aggregation function.

[0012] Optionally, the step of determining whether a database query statement contains a de-aggregation function includes:

[0013] Parse the database query statement and obtain the parsing result;

[0014] Determine whether there is an aggregation function keyword in the database query statement based on the parsing results;

[0015] When there is an aggregation function keyword in the database query statement, it is determined whether there is a target keyword in the content corresponding to the aggregation function keyword, and the target keyword is used to query non-duplicate values;

[0016] If so, it is determined that there is a de-aggregation function in the database query statement.

[0017] Optionally, the step of performing a corresponding conversion operation on the database query statement according to the number of de-aggregation functions includes:

[0018] When the number of de-aggregation functions is 1, a grouping subquery is generated for the de-aggregation function;

[0019] Convert the reference column in the de-aggregation function to the target column of the grouping subquery and delete the target keyword to eliminate the de-aggregation nature of the de-aggregation function.

[0020] Optionally, the step of performing a corresponding conversion operation on the database query statement according to the number of de-aggregation functions includes:

[0021] When the number of de-aggregation functions exceeds 1, determine whether the reference columns of multiple de-aggregation functions are the same;

[0022] When the reference columns of multiple de-aggregation functions are the same, a grouped subquery is generated based on the reference columns;

[0023] The reference columns in multiple de-duplicate aggregation functions are converted into target columns of grouping subqueries, and the target keywords are deleted, thereby eliminating the de-duplicate nature in the multiple de-duplicate aggregation functions.

[0024] Optionally, the step of determining whether the reference columns of multiple de-aggregation functions are the same includes:

[0025] In the case where the reference columns of multiple de-aggregation functions are different, corresponding de-aggregation subqueries are generated for the multiple de-aggregation functions according to the different reference columns, and the de-aggregation subqueries are connected through the connection keyword. The reference columns corresponding to the de-aggregation functions in the de-aggregation subqueries are all the same;

[0026] In each de-aggregation subquery, generate the corresponding grouping subquery based on the referenced columns;

[0027] In each de-aggregation subquery, the reference column in the de-aggregation function is converted into the target column of the corresponding grouping subquery, and the target keyword is deleted, thereby eliminating the de-aggregation property in the de-aggregation function.

[0028] Optionally, the target keyword is distinct;

[0029] Aggregate function keywords include sum, avg, min, max, and stddev.

[0030] Optionally, after the step of performing a corresponding conversion operation on the database query statement according to the number of de-aggregation functions, the step further includes:

[0031] Determine whether there is a common aggregate function in the database query statement. A common aggregate function is an aggregate function that does not contain deduplication properties.

[0032] If yes, copy the common aggregate function in the parent query to the target column of the grouped subquery, and generate an alias for the common aggregate function in the grouped subquery;

[0033] Replace referenced columns in ordinary aggregate functions in the parent query with aliases.

[0034] According to another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods for processing database query statements are implemented.

[0035] According to another aspect of the present invention, a computer program product is provided, which includes a computer program. When the computer program is executed by a processor, the steps of any one of the above-mentioned methods for processing database query statements are implemented.

[0036] According to another aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, and the processor implements the steps of any of the above-mentioned database query statement processing methods when executing the machine executable program.

[0037] The method for processing database query statements of the present invention first obtains the database query statement; then determines whether the database query statement has a deduplication aggregation function, wherein the deduplication aggregation function is an aggregation function with a deduplication property; if so, counts the number of deduplication aggregation functions; and performs corresponding conversion operations on the database query statement according to the number of deduplication aggregation functions, thereby eliminating the deduplication property in the deduplication aggregation function. Through this method, after the aggregation function with the deduplication property is converted, the database can also use the hash grouping method to calculate the aggregation function, thereby avoiding the existence of deduplication keywords in the aggregation function in the original statement, which causes the optimizer to be unable to operate in parallel, and improves the processing performance of the database for the deduplication aggregation function.

[0038] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0040] Figure 1 is a flowchart of a method for processing a database query statement according to an embodiment of the present invention;

[0041] Figure 2 is a flowchart of a method for processing a database query statement according to another embodiment of the present invention;

[0042] Figure 3 is a schematic diagram of a computer program product according to an embodiment of the present invention;

[0043] Figure 4 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and

[0044] Figure 5 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0045] It should be understood by those skilled in the art that the embodiments described below are only some embodiments of the present invention, rather than all embodiments of the present invention, and these embodiments are intended to explain the technical principles of the present invention, rather than to limit the protection scope of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should still fall within the protection scope of the present invention.

[0046] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or equipment (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or equipment and execute instructions), or used in combination with these instruction execution systems, devices or equipment.

[0047] The present invention provides a method for processing a database query statement. Figure 1 FIG. 1 is a flow chart of a method for processing a database query statement according to an embodiment of the present invention. Figure 1 As shown, the method for processing the database query statement at least includes the following steps S101 to S104.

[0048] Step S101, obtaining a database query statement. An optional example is SQL (Structured Query Language). SQL statements have multiple functions such as data manipulation and data definition. This language has interactive characteristics and can provide great convenience for users. In this step, the way to receive the database query statement can generally be that the user actively inputs it, or the database program automatically generates it due to business needs during operation. Those skilled in the art can decide on their own how to receive the database query statement according to actual conditions.

[0049] Step S102, determining whether the database query statement contains a deduplication aggregation function. A deduplication aggregation function is an aggregation function with a deduplication property.

[0050] In some optional embodiments, the step of determining whether a database query statement contains a deduplication aggregation function may generally include: parsing the database query statement to obtain a parsing result; determining whether there are aggregation function keywords in the database query statement based on the parsing result, including but not limited to checking the target column, order by, having, etc.; in the case where there are aggregation function keywords in the database query statement, determining whether there are target keywords in the content corresponding to the aggregation function keywords, the target keywords are used to query non-duplicate values; if so, determining whether there are deduplication aggregation functions in the database query statement. The target keyword is generally distinct, and the aggregation function keywords may generally include sum, avg, min, max, stddev, etc. An optional example is shown in Formula 1:

[0051] select sum(distinct id)from t1 Formula 1

[0052] The purpose of the SQL statement shown in Formula 1 is to select the id column from table t1 and calculate the sum of all unique id values. The distinct keyword ensures that each id value is calculated only once, and the sum function calculates the sum of these unique values. The sum function is an aggregation function, and distinct id finds all non-repeated id values ​​in table t1, that is, removes duplicates. Therefore, sum(distinct id) is called an aggregation function with a deduplication property, that is, a deduplication aggregation function.

[0053] Step S103, counting the number of de-aggregation functions.

[0054] Step S104, performing corresponding conversion operations on the database query statement according to the number of the de-duplication aggregation functions, thereby eliminating the de-duplication property in the de-duplication aggregation function.

[0055] Through this method, after the aggregate function with deduplication properties is converted, the database can also use the hash grouping method to calculate the aggregate function, thereby avoiding the existence of deduplication keywords in the aggregate function in the original statement, which causes the optimizer to be unable to operate in parallel, and improves the database's processing performance for deduplication aggregate functions.

[0056] In some optional embodiments, the step of performing corresponding conversion operations on the database query statement according to the number of de-duplication aggregation functions may generally include: when the number of de-duplication aggregation functions is 1, generating a grouping subquery for the de-duplication aggregation function; converting the reference column in the de-duplication aggregation function into a target column of the grouping subquery, and deleting the target keyword, thereby eliminating the de-duplication property in the de-duplication aggregation function.

[0057] To clearly illustrate the processing flow of the present method, the SQL statement shown in Formula 1 is still taken as an example. There is only one de-aggregation function inside it, namely sum(distinct id). Therefore, according to the method of the present invention, a grouping subquery is generated for it. A grouping subquery is a subquery that groups by a grouping keyword, such as group by. In addition, the reference column (ie, id) in the de-aggregation function needs to be converted to the target column of the grouping subquery, and the target keyword (distinct) needs to be deleted. The SQL statement finally obtained is shown in Formula 2:

[0058] select sum(id)from(Select id from t1 group by id)Equation 2

[0059] It can be seen from the SQL statement shown in Formula 2 that the target keyword (distinct) has been removed, so that the SQL statement shown in Formula 1 eliminates the deduplication attribute. Subsequently, the database optimizer does not need to perform deduplication operations on the SQL statement shown in Formula 2, and can use the hash grouping method to calculate the aggregation function. The results of actual tests show that the database generally takes 220.008ms to process the SQL statement shown in Formula 1, while the converted SQL statement shown in Formula 2 generally takes 62.700ms. This shows that the method of the present invention can greatly improve the processing efficiency of SQL statements and reduce the consumption of database resources after converting SQL statements that meet the conditions.

[0060] In other optional embodiments, the step of performing corresponding conversion operations on the database query statement according to the number of de-duplication aggregation functions may generally include: when the number of de-duplication aggregation functions exceeds 1, determining whether the reference columns of multiple de-duplication aggregation functions are the same; when the reference columns of multiple de-duplication aggregation functions are the same, generating a grouping subquery based on the reference columns; converting the reference columns in the multiple de-duplication aggregation functions into target columns of the grouping subquery, and deleting the target keywords, thereby eliminating the de-duplication properties in the multiple de-duplication aggregation functions.

[0061] In order to clearly illustrate the processing flow of this method, an optional example is proposed as shown in Formula 3:

[0062] select count(distinct id),sum(distinct id)from t1 Formula 3

[0063] It can be seen from the SQL statement shown in Formula 3 that there are two de-duplicate aggregation functions (count(distinct id), sum(distinct id)) inside it. According to the process of this method, it is necessary to determine whether the reference columns of multiple de-duplicate aggregation functions are the same. It can be seen from Formula 3 that the reference columns of the two de-duplicate aggregation functions are both id. In this case, it is necessary to generate a grouping subquery (group by) based on the reference column (id), and then convert the reference columns in multiple de-duplicate aggregation functions into the target columns of the grouping subquery, and delete the target keywords, thereby eliminating the de-duplicate nature in multiple de-duplicate aggregation functions. The converted SQL statement is shown in Formula 4:

[0064] select count(id),sum(id)from(select id from t1 group by id)Equation 4

[0065] It can be seen from the SQL statement shown in Formula 4 that the target keyword (distinct) has been removed, so that the SQL statement shown in Formula 3 eliminates the deduplication attribute. Subsequently, the database optimizer does not need to perform deduplication operations on the SQL statement shown in Formula 4, and can use the hash grouping method to calculate the aggregation function. The results of actual tests show that the database generally takes 255.987ms to process the SQL statement shown in Formula 3, while the converted SQL statement shown in Formula 4 generally takes 64.799ms.

[0066] In some other optional embodiments, the step of determining whether the reference columns of multiple de-aggregation functions are the same may generally include: when the reference columns of multiple de-aggregation functions are different, generating corresponding de-aggregation sub-queries for the multiple de-aggregation functions according to the different reference columns, and connecting the de-aggregation sub-queries through connection keywords, and the reference columns corresponding to the de-aggregation functions in the de-aggregation sub-queries are all the same; in each de-aggregation sub-query, generating a corresponding grouping sub-query according to the reference column; in each de-aggregation sub-query, converting the reference column in the de-aggregation function into the target column of the grouping sub-query corresponding to itself, and deleting the target keyword, thereby eliminating the de-duplication property in the de-aggregation function.

[0067] For the case where the reference columns of multiple de-aggregation functions are different, an optional example is also proposed as shown in Formula 5:

[0068] select count(distinct id),sum(distinct age)from t1 Formula 5

[0069] It can be seen from the SQL statement shown in Formula 5 that there are two de-aggregation functions (count(distinct id), sum(distinct age)) inside it. According to the process of this method, it is necessary to determine whether the reference columns of multiple de-aggregation functions are the same. It can be seen from Formula 5 that the reference columns of the two de-aggregation functions are different. In this case, it is necessary to generate corresponding de-aggregation subqueries for multiple de-aggregation functions according to the different reference columns, and connect the de-aggregation subqueries through the connection keyword, where an optional example of the connection keyword is join. The converted SQL statement is shown in Formula 6:

[0070] select*from(select count(distinct id)from t1)a join(select count(distinct age)from t1)b on true Formula 6

[0071] It can be seen from the SQL statement shown in Formula 6 that the reference columns corresponding to the de-aggregation function in each de-aggregation subquery are different reference columns. Then, each de-aggregation subquery can be converted again according to the conversion logic of the previous de-aggregation function, that is, in each de-aggregation subquery, the corresponding grouping subquery is generated according to the reference column; in each de-aggregation subquery, the reference column in the de-aggregation function is converted to the target column of the corresponding grouping subquery, and the target keyword is deleted, thereby eliminating the de-aggregation property in the de-aggregation function. The SQL statement after conversion is shown in Formula 7:

[0072] elect*from(select count(id)from(select id from t1 group by id))a join(select count(age)from(select age from t1 group by age))b on true Formula 7

[0073] It can be seen from the SQL statement shown in Formula 7 that the select count (distinct id) from t1 in the original formula 6 is converted to select count (id) from (select id from t1 group by id), select count (distinct age) from t1 is converted to select count (age) from (select age from t1 groupby age), and finally the SQL statement shown in Formula 5 is converted to Formula 7. Then, the database optimizer does not need to perform a deduplication operation on the SQL statement shown in Formula 7, and can use the hash grouping method to calculate the aggregation function. And the results after the actual test show that the database generally takes 1070.832ms to process the SQL statement shown in Formula 5, and the database generally takes 468.711ms to process the SQL statement shown in Formula 6, and the SQL statement shown in Formula 7 after conversion generally takes 164.982ms. It can be seen that the method of the present invention can greatly improve the processing efficiency of SQL statements and reduce the consumption of database resources after converting the SQL statements that meet the conditions.

[0074] In some other optional embodiments, after the step of performing corresponding conversion operations on the database query statement according to the number of deduplication aggregation functions, it can generally also include: determining whether the database query statement has a common aggregation function, and the common aggregation function is an aggregation function that does not contain deduplication properties; if so, copying the common aggregation function in the parent query to the target column of the grouped subquery, and generating an alias for the common aggregation function in the grouped subquery; replacing the reference column in the common aggregation function in the parent query with the alias. In order to clearly illustrate this embodiment, an optional example is proposed as shown in Formula 8:

[0075] select sum(distinct id),min(id)from t1 Formula 8

[0076] It can be seen from the SQL statement shown in Formula 8 that there is only one deduplication aggregation function inside it, namely sum(distinct id), but there is also a common aggregation function min(id). Therefore, in the conversion process of this method, the common aggregation function min(id) needs to be processed. The processing method is to copy the common aggregation function in the parent query to the target column of the grouped subquery, and generate an alias for the common aggregation function in the grouped subquery; replace the reference column in the common aggregation function in the parent query with the alias. The final SQL statement is shown in Formula 9:

[0077] select sum(id),min(m_id)from(Select id,min(id)m_id from t1 group byid)Equation 9

[0078] It can be seen from the sql statement shown in formula 9 that the target keyword (distinct) has been removed, and the ordinary aggregation function min(id) is copied to the target column of the grouped subquery, and an alias m_id is generated for the result. The reference column corresponding to the ordinary aggregation function in the parent query target column is replaced with the alias m_id. Through this conversion method, the execution result of the ordinary aggregation function can be eliminated while eliminating the duplicate aggregation function. According to the results of the actual test, it generally takes 244.130ms for the database to process the sql statement shown in formula 8, and it generally takes 70.505ms for the converted sql statement shown in formula 9. It can be seen that the method of the present invention can greatly improve the processing efficiency of sql statements and reduce the consumption of database resources after converting the sql statements that meet the conditions.

[0079] Those skilled in the art may also generate corresponding aliases for the target columns corresponding to the de-aggregation function according to actual conditions, for example, changing Formula 9 to the SQL statement shown in Formula 10:

[0080] select sum(item_1),min(m_id)from(Select id as item_1,min(id)m_id fromt1group by id)Equation 10

[0081] As shown in the SQL statement in Formula 10, after rewriting sum(distinct id), the subquery target column is changed to: idas item_1, and the target column generated by the parent query is sum(item_1).

[0082] In addition, you can also assign values ​​to flags in the parent query and subquery during the conversion process, such as setting the aggregation function parameter hasAggs=false of the subquery or view.

[0083] Figure 2 FIG. 1 is a flow chart of a method for processing a database query statement according to another embodiment of the present invention. Figure 2 As shown, the method for processing the database query statement at least includes the following steps S201 to S210.

[0084] Step S201, obtaining a database query statement.

[0085] Step S202, determining whether the database query statement contains a de-aggregation function.

[0086] Step S203: If the result of the determination in step S202 is no, the database query statement is not rewritten.

[0087] Step S204: if the answer in step S202 is yes, count the number of de-aggregation functions.

[0088] Step S205: when the number of de-duplicate aggregation functions is 1, a grouping subquery is generated for the de-duplicate aggregation function.

[0089] Step S206, converting the reference column in the de-duplication aggregation function into the target column of the grouping subquery, and deleting the target keyword, thereby eliminating the de-duplication property in the de-duplication aggregation function.

[0090] Step S207, when there are multiple de-duplicate aggregation functions, determine whether the reference columns of the multiple de-duplicate aggregation functions are the same. If so, process according to the execution logic of step S205.

[0091] Step S208, when the judgment in step S207 is no, corresponding de-re-aggregation sub-queries are generated for the multiple de-re-aggregation functions according to the different referenced columns, and the de-re-aggregation sub-queries are connected through the connection keywords.

[0092] Step S209: in each de-aggregation subquery, generate a corresponding grouping subquery according to the referenced column.

[0093] Step S210, in each de-duplication subquery, convert the reference column in the de-duplication aggregation function into the target column of the corresponding grouping subquery, and delete the target keyword, so as to eliminate the de-duplication property in the de-duplication aggregation function.

[0094] It should be noted that the method of the present invention does not limit the content in the function reference column, that is, the content in the reference column may not only be a column name, but may also be a function, etc. An optional example is shown in Formula 11;

[0095] select sum(distinct(id|age))from t1 Formula 11

[0096] It can be seen from the SQL statement shown in Formula 11 that there is a deduplication aggregation function sum(distinct(id|age)), and the reference column inside it is not a column, but (id|age), which means that the values ​​of the id column and the age column are bitwise operated. Faced with such SQL statements, the method of the present invention still treats it as a target column, that is, it still chooses to generate a grouping subquery for it, but because it is a function, it chooses to generate a corresponding alias for it to be referenced by the aggregation function in the parent query and the grouping target of the grouping subquery statement. The SQL statement obtained after removing the deduplication property by the method of the present invention is shown in Formula 12:

[0097] select sum(id_age)from(select(id|age)as id_age from t1 group by id_age)Equation 12

[0098] As shown in the SQL statement shown in Formula 12, the grouping subquery statement is select (id|age) as id_age from t1 group by id_age, and an alias id_age is established for (id|age), and grouping is performed according to this alias in the grouping subquery statement, that is, grouping is performed according to the result of (id|age). In addition, this alias is used to replace the reference column in the aggregation function of the parent query. And the results after real testing show that the database generally takes 339.785ms to process the SQL statement shown in Formula 11, and the database generally takes 116.923ms to process the SQL statement shown in Formula 12. It can be seen that the method of the present invention can greatly improve the processing efficiency of SQL statements after converting the SQL statements that meet the conditions.

[0099] Through this method, after the aggregate function containing distinct is converted, the database can also use the hash grouping method to calculate the aggregate function, thereby avoiding the optimizer's inability to operate in parallel due to the presence of the distinct keyword in the aggregate function in the original statement, and improving the database's processing performance for aggregate functions containing distinct.

[0100] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes may be made to the above method.

[0101] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0102] This embodiment also provides a computer program product 10 , a computer readable storage medium 20 , and a computer device 30 . Figure 3 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention, Figure 4 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention, Figure 5 is a schematic diagram of a computer device 30 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, which implements the steps of any of the above-mentioned methods for processing database query statements when executed by a processor 32. The computer-readable storage medium 20 stores the above-mentioned computer program 11, which implements the steps of any of the above-mentioned methods for processing database query statements when executed by a processor 32. The computer device 30 may include a memory 31, a processor 32, and the computer program 11 stored in the memory 31 and running on the processor 32.

[0103] The computer program 11 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-related instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages ​​and process programming languages. The computer program 11 may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider via the Internet). In some embodiments, in order to perform various aspects of the present invention, an electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.

[0104] For the purposes of the description of the present embodiment, the computer program product 10 is a related product that includes the computer program 11. For the purposes of the description of the present embodiment, the computer readable storage medium 20 is a tangible device capable of retaining and storing the computer program 11, which may be any device that can contain, store, communicate, propagate or transmit the program 11 for use with or in conjunction with an instruction execution system, device or apparatus. More specific examples (a non-exhaustive list) of the computer readable storage medium 20 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the foregoing.

[0105] The computer device 30 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 30 may be a cloud computing node. The computer device 30 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, target programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 30 may be implemented in a distributed cloud computing environment where remote processing devices linked via a communication network perform tasks. In a distributed cloud computing environment, program modules may be located on a local or remote computing system storage medium including a storage device.

[0106] The computer device 30 may include a processor 32 adapted to execute stored instructions, and a memory 31 providing temporary storage space for the operation of the instructions during operation. The processor 32 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 31 may include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.

[0107] The computer device 30 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows data to be input and output with external devices that may be connected to the computer device. The network adapter / interface may provide communication between the computer device and a network, which is typically shown as a communication network.

[0108] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A method for processing a database query statement, comprising: Obtaining the database query statement; Determine whether the database query statement has a deduplication aggregation function, where the deduplication aggregation function is an aggregation function with a deduplication property; If yes, then counting the number of said de-aggregation functions; The database query statement is converted accordingly according to the number of the de-duplication aggregation functions, thereby eliminating the de-duplication property in the de-duplication aggregation function.

2. The method for processing a database query statement according to claim 1, wherein: The step of determining whether the database query statement has a de-aggregation function comprises: Parsing the database query statement to obtain a parsing result; Determine whether there is an aggregation function keyword in the database query statement according to the analysis result; In the case where the aggregation function keyword exists in the database query statement, determining whether there is a target keyword in the content corresponding to the aggregation function keyword, wherein the target keyword is used to query a non-repeated value; If so, it is determined that the de-aggregation function exists in the database query statement.

3. The method for processing a database query statement according to claim 2, wherein: The step of performing a corresponding conversion operation on the database query statement according to the number of the de-aggregation functions comprises: When the number of the de-aggregation function is 1, generating a grouping subquery for the de-aggregation function; The reference column in the de-duplication aggregation function is converted into the target column of the grouping subquery, and the target keyword is deleted, thereby eliminating the de-duplication property in the de-duplication aggregation function.

4. The method for processing a database query statement according to claim 3, wherein: The step of performing a corresponding conversion operation on the database query statement according to the number of the de-aggregation functions comprises: When the number of the de-aggregation functions exceeds 1, determining whether the reference columns of the plurality of de-aggregation functions are the same; In the case where the reference columns of the plurality of de-aggregation functions are the same, generating the grouping subquery according to the reference columns; The reference columns in the plurality of de-duplication aggregation functions are converted into target columns of the grouping subquery, and the target keywords are deleted, thereby eliminating the de-duplication property in the plurality of de-duplication aggregation functions.

5. The method for processing a database query statement according to claim 4, wherein: The step of determining whether the reference columns of the plurality of de-aggregation functions are the same comprises: In the case where the reference columns of the multiple de-aggregation functions are different, corresponding de-aggregation subqueries are generated for the multiple de-aggregation functions according to the differences in the reference columns, and the de-aggregation subqueries are connected through connection keywords, and the reference columns corresponding to the de-aggregation functions in the de-aggregation subqueries are all the same; In each of the de-aggregation subqueries, generating the corresponding grouping subquery according to the reference column; In each of the de-duplication subqueries, the reference column in the de-duplication function is converted into the target column of the grouping subquery corresponding to itself, and the target keyword is deleted, thereby eliminating the de-duplication property in the de-duplication function.

6. The method for processing a database query statement according to claim 5, wherein: The target keyword is distinct; The aggregation function keywords include sum, avg, min, max, and stddev.

7. The method for processing a database query statement according to claim 5, wherein: After the step of performing a corresponding conversion operation on the database query statement according to the number of the de-aggregation functions, the following step is further included: Determine whether there is a common aggregation function in the database query statement, where the common aggregation function is the aggregation function that does not include the deduplication property; If yes, copy the common aggregate function in the parent query to the target column of the grouped subquery, and generate an alias for the common aggregate function in the grouped subquery; The referenced column in the ordinary aggregate function in the parent query is replaced with the alias.

8. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method for processing a database query statement according to any one of claims 1 to 7 are implemented.

9. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the method for processing a database query statement according to any one of claims 1 to 7.

10. A computer device comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, wherein the processor implements the steps of the method for processing a database query statement according to any one of claims 1 to 7 when executing the machine executable program.