Database operation statement processing method and related product
By pushing down the filtering conditions of aggregate functions into conditional clauses, the problem of resource waste and inefficiency in existing databases when processing database operation statements is solved, and more efficient database resource utilization and execution efficiency are achieved.
Patent Information
- Application Number
- CN202411310865.8
- 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
When an existing database processes database operation statements containing aggregation functions, it reads all data and filters it, resulting in waste of resources and inefficiency.
By judging whether the database operation statement meets the preset push-down conditions, if so, the filter conditions corresponding to the aggregate function are pushed down to the condition clause, thereby directly reducing the amount of data during the data scanning phase.
It reduces the amount of data processed by aggregate functions, reduces the consumption of database resources, and improves the execution efficiency of the database.
Smart Images

Figure CN119311730A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a method for processing database operation statements and related products. Background Art
[0002] When receiving a database operation statement, the existing database generally processes the database operation statement itself directly. However, for some database operation statements, for example:
[0003] select sum(id)filter(where id<5)from t1;
[0004] When facing the above-mentioned database operation statements, the database will usually read all the data in table t1 and then use the aggregate function to filter out the data that meets the filter condition id<5 and perform a sum operation. The data with id>=5 is not used, which increases the amount of data processed by the aggregate function and causes a waste of database resources. Summary of the invention
[0005] In view of the above problems, the present invention proposes a method for processing database operation statements and related products that overcome the above problems or at least partially solve the above problems.
[0006] It is an object of the present invention to reduce the amount of data processed by aggregate functions.
[0007] A further object of the present invention is to reduce the consumption of database resources.
[0008] A further object of the present invention is to improve the execution efficiency of the database.
[0009] In particular, the present invention provides a method for processing a database operation statement, comprising:
[0010] Get database operation statements;
[0011] Determine whether the database operation statement meets the preset push-down conditions;
[0012] If so, push the filter condition corresponding to the aggregate function in the database operation statement into the conditional clause.
[0013] Optionally, the step of determining whether the database operation statement meets the preset push-down condition includes:
[0014] Determine whether there are only aggregate functions in the target column of the database operation statement;
[0015] If only aggregate functions exist in the target column, determine whether the filter conditions of all aggregate functions in the target column are the same and do not contain grouping statements;
[0016] When the filtering conditions of all aggregate functions are the same and no grouping statements are included, the database operation statement is determined to meet the preset push-down conditions.
[0017] Optionally, the step of determining whether only aggregate functions exist in the target column of the database operation statement includes:
[0018] Parse the database operation statement and obtain the parsing result;
[0019] Identify query keywords in database operation statements based on parsing results;
[0020] Determine the target column based on the query keywords;
[0021] Determines whether only aggregate functions exist in the target column.
[0022] Optionally, the step of determining whether the filtering conditions of all the aggregate functions in the target column are the same and do not contain a group statement includes:
[0023] Identify the filtering keywords corresponding to the aggregate functions in the database operation statements based on the parsing results;
[0024] Determine the filtering conditions corresponding to the aggregation function based on the filtering keywords;
[0025] Determine whether the filtering conditions corresponding to all aggregate functions are the same and do not contain grouping statements.
[0026] Optionally, the step of pushing the filter condition corresponding to the aggregate function in the database operation statement into the conditional clause includes:
[0027] Get the filtering condition corresponding to the aggregate function;
[0028] Identify data source and specify keywords based on parsing results;
[0029] Push the filter condition to the condition clause after the keyword specified in the data source.
[0030] Optionally, after the step of determining whether only aggregate functions exist in the target column of the database operation statement, the step further includes:
[0031] When the target column of the database operation statement does not contain only aggregate functions, it is determined that the database operation statement does not meet the preset push-down condition;
[0032] Execute the corresponding operation according to the original database operation statement.
[0033] Optionally, after the step of pushing the filter condition corresponding to the aggregate function in the database operation statement into the conditional clause, the step further includes:
[0034] Verify the pushed-down database operation statements to determine whether the pushed-down database operation statements can be executed normally;
[0035] If so, an execution plan is generated and executed based on the pushed-down database operation statement.
[0036] 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 operation statements are implemented.
[0037] According to another aspect of the present invention, a computer program product is provided, which includes a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned methods for processing database operation statements are implemented.
[0038] 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 operation statement processing methods when executing the machine executable program.
[0039] The method for processing database operation statements of the present invention comprises the following steps: firstly, performing a database operation statement; determining whether the database operation statement meets a preset push-down condition; and if so, pushing down the filter condition corresponding to the aggregate function in the database operation statement to the conditional clause. By this method, the filter condition corresponding to the aggregate function can be pushed down to the conditional clause, so that the database can directly reduce the amount of data returned by the table reading data in the stage of scanning data, and at the same time reduce the amount of data for the aggregate operation, reduce the consumption of database resources, and improve the execution efficiency of the database.
[0040] Furthermore, the method for processing database operation statements of the present invention, after the step of pushing down the filter condition corresponding to the aggregate function in the database operation statement to the conditional clause, performs verification according to the pushed-down database operation statement to determine whether the pushed-down database operation statement can be executed normally; if so, generates an execution plan according to the pushed-down database operation statement and executes it. This method can verify whether the execution result of the database operation statement is affected after the push-down is completed, and will continue to execute if there is no impact, thereby avoiding the push-down operation affecting the result of the database operation statement.
[0041] 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
[0042] 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:
[0043] Figure 1 is a flowchart of a method for processing database operation statements according to an embodiment of the present invention;
[0044] Figure 2 is a flowchart of a method for processing database operation statements according to another embodiment of the present invention;
[0045] Figure 3 is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0046] Figure 4 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and
[0047] Figure 5 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0048] 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.
[0049] 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.
[0050] The present invention provides a method for processing database operation statements. Figure 1 FIG. 1 is a flow chart of a method for processing a database operation statement according to an embodiment of the present invention. Figure 1 As shown, the method for processing the database operation statement at least includes the following steps S101 to S103.
[0051] Step S101, obtaining database operation statements. 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 database operation statements can generally be active input by the user, or automatically generated by the database program during operation due to business needs. Those skilled in the art can decide the way to receive database operation statements according to actual conditions.
[0052] Step S102, determining whether the database operation statement meets the preset push-down condition.
[0053] In some optional embodiments, the step of determining whether the database operation statement meets the preset push-down condition may generally include: determining whether there are only aggregate functions in the target column of the database operation statement; if there are only aggregate functions in the target column, determining whether the filter conditions of all aggregate functions in the target column are the same and do not contain grouping statements; if the filter conditions of all aggregate functions are the same and do not contain grouping statements, determining that the database operation statement meets the preset push-down condition. Some optional examples of aggregate functions include SUM, AVG, COUNT, MIN, MAX, etc.
[0054] The reason for judging whether there are only aggregate functions in the target column of the database operation statement is that when there are only aggregate functions in the target column, the data in the table is read for aggregate operation. Data that does not meet the filter conditions of the aggregate function is useless data. For such useless data, reading or not reading will not affect the result set. The reason for judging whether the filter conditions of all aggregate functions in the target column are the same is that under the premise that the filter conditions of multiple aggregate functions are the same, each aggregate function will eliminate the data that does not meet the filter conditions. The filter conditions of the aggregate functions are the same, and the conditions are pushed down, which will not affect the result set. The reason for not including the grouping statement is that after obtaining the data, the grouping statement generally groups the data first, and then hands it over to the aggregate function for processing. The aggregate function will output null or 0 for the columns that do not meet the conditions. After the filter conditions are pushed down, the data obtained will not have data that does not meet the filter conditions of the aggregate function, which will affect the execution results. Therefore, when there is a grouping statement, the aggregate function filter conditions cannot be pushed down. In summary, the filter conditions of the aggregate function that meet the above conditions can be pushed down without affecting the execution results.
[0055] Step S103: push the filter condition corresponding to the aggregate function in the database operation statement into the conditional clause.
[0056] Through this method, the filtering conditions corresponding to the aggregate function can be pushed down to the conditional clause, so that the database can directly reduce the amount of data returned by reading data from the table during the data scanning stage, while reducing the amount of data for the aggregate operation, reducing the consumption of database resources, and improving the execution efficiency of the database.
[0057] In some optional embodiments, the step of determining whether only aggregate functions exist in the target column of a database operation statement may generally include: parsing the database operation statement to obtain a parsing result; identifying a query keyword in the database operation statement according to the parsing result; determining a target column according to the query keyword; and determining whether only aggregate functions exist in the target column. In the current database, aggregate functions are generally used in query statements, and an example of a query statement in a database operation statement is a Select statement, so an optional example of a query keyword is Select, and the content after the query keyword is generally the target column corresponding to the query statement.
[0058] Optionally, the step of determining whether the filtering conditions of all the aggregate functions in the target column are the same and do not contain a grouping statement may generally include: identifying the filtering keywords corresponding to the aggregate function in the database operation statement according to the parsing result; determining the filtering conditions corresponding to the aggregate function according to the filtering keywords; and determining whether the filtering conditions corresponding to all the aggregate functions are the same and do not contain a grouping statement. An optional example of a filtering keyword is FILTER. In SQL, the FILTER clause is used to limit the calculation scope of the aggregate function and only calculate the rows that meet the specific conditions. The FILTER clause allows a condition to be specified within the aggregate function so that only those rows that meet the condition are aggregated.
[0059] An optional example of a grouping statement is GROUP BY. In SQL, the GROUP BY clause is used to group query results according to the values of one or more columns. It is usually used with aggregate functions to summarize statistics for each group. The GROUP BY clause can group data and then apply aggregate functions to each group. After obtaining data, the grouping statement generally groups the data first and then passes it to the aggregate function for processing. The aggregate function will output null or 0 for columns that do not meet the conditions. After the filter conditions are pushed down, the data obtained will not contain data that does not meet the aggregate function filter conditions. This will affect the execution results. Therefore, when there is a grouping statement, the aggregate function filter condition cannot be pushed down.
[0060] Optionally, the step of pushing the filter conditions corresponding to the aggregate function in the database operation statement to the conditional clause may generally include: obtaining the filter conditions corresponding to the aggregate function; identifying the data source specified keywords according to the parsing results; pushing the filter conditions to the conditional clause after the data source specified keywords. Among them, an optional example of the data source specified keywords is FROM. In SQL, the FROM clause is used to specify the table or view of the query data source. The FROM clause is a basic component of the SQL query statement, which is used to tell the database management system which table or tables to retrieve data from. The original database operation statement usually places the filter conditions corresponding to the target column before FROM. At this time, when the database executes such database operation statements, it will first obtain the corresponding data source according to the FROM keyword, and then filter and filter according to the filter conditions. After pushing down, filtering and filtering will be performed in the process of obtaining the data source, so that the database does not need to obtain all data sources, which greatly reduces the amount of data in the execution process.
[0061] Optionally, after the step of determining whether only aggregate functions exist in the target column of the database operation statement, the following may generally be included: if the target column of the database operation statement does not only contain aggregate functions, determining that the database operation statement does not meet the preset push-down conditions; and executing the corresponding operation according to the original database operation statement.
[0062] After the step of pushing down the filter condition corresponding to the aggregate function in the database operation statement to the conditional clause, the following steps may be generally included: verifying the pushed-down database operation statement to determine whether the pushed-down database operation statement can be executed normally; if so, generating an execution plan and executing it according to the pushed-down database operation statement. In some special cases, the filter condition may affect the execution result after being pushed down, so it is necessary to verify it after each push-down to predict whether it will affect the execution result. If it still has an impact, the original database operation statement will be executed to ensure the accuracy of the execution result.
[0063] Figure 2 FIG. 1 is a flow chart of a method for processing a database operation statement according to another embodiment of the present invention. Figure 2 As shown, the method for processing the database operation statement at least includes the following steps S201 to S208.
[0064] Step S201, obtaining a database operation statement.
[0065] Step S202, determining whether there are only aggregate functions in the target column of the database operation statement. Some optional examples of aggregate functions include SUM, AVG, COUNT, MIN, MAX, etc. When there are only aggregate functions in the target column, the data in the table is read for the purpose of performing the aggregate operation, and the data that does not meet the filter conditions of the aggregate function is useless data. For such useless data, reading or not reading will not affect the result set.
[0066] Step S203, if the judgment in step S202 is yes, determine whether the filtering conditions of all the aggregate functions in the target column are the same and do not contain group statements. Since each aggregate function will eliminate data that does not meet the filtering conditions, when the filtering conditions of the aggregate functions are the same, the filtering conditions will be pushed down, which will not affect the result set. The reason why it does not contain a group statement is that after obtaining the data, the group statement will generally group the data first, and then hand it over to the aggregate function for processing. The aggregate function will output null or 0 for the columns that do not meet the conditions. After the filter conditions are pushed down, the data obtained will not contain data that does not meet the filter conditions of the aggregate function, which will affect the execution result. Therefore, when there is a group statement, the aggregate function filter condition cannot be pushed down. In summary, the filter conditions of the aggregate function that meet the above conditions can be pushed down without affecting the execution result.
[0067] Step S204: When the judgment in step S202 is no or the judgment in step S203 is no, a corresponding operation is performed according to the original database operation statement.
[0068] Step S205, when the judgment in step S203 is yes, obtain the filtering condition corresponding to the aggregation function.
[0069] Step S206, determining the data source specified keyword.
[0070] Step S207, push the filter condition down to the conditional clause after the keyword specified by the data source. Among them, an optional example of the keyword specified by the data source is FROM. In SQL, the FROM clause is used to specify the table or view of the query data source. The FROM clause is a basic component of the SQL query statement, which is used to tell the database management system which table or tables to retrieve data from. The original database operation statement usually places the filter condition corresponding to the target column before FROM. At this time, when the database executes such a database operation statement, it will first obtain the corresponding data source according to the FROM keyword, and then filter according to the filter condition. After pushing down, filtering will be performed in the process of obtaining the data source, so that the database does not need to obtain all data sources, which greatly reduces the amount of data during the execution process.
[0071] Step S208, executing corresponding operations according to the pushed-down database operation statements.
[0072] Through this method, the filtering condition of the aggregate function is pushed down, and the conditions for reading data from the table are added, thereby reducing the amount of data returned after the table reads data, while reducing the amount of data for aggregate operations and improving the efficiency of database queries.
[0073] In order to explain this method more clearly, some specific SQL statements are provided for pushing down the filter conditions.
[0074] Embodiment 1;
[0075] Original SQL statement: Select count(id)filter(where id<5)from t1.
[0076] The SQL statement after the filter condition is pushed down: Select count(id) from t1 where id<5.
[0077] It can be seen in this embodiment that the query keyword of the original SQL statement is Select, and according to the query keyword, it is determined that its target column only contains the aggregation function count(id). The filtering keyword is filter, and the subsequent filtering condition is where id<5. The data source specification keyword is from, and the specified data source is data table t1. It can be seen that when the database executes the original SQL statement, it needs to first obtain all the data in data table t1, and then filter it according to the filtering condition where id<5, and then process the filtered data according to the aggregation function count(id), that is, calculate the number of all rows in data table t1 that meet the condition id<5.
[0078] During the execution, data with id greater than or equal to 5 is not used. Therefore, in order to improve the execution efficiency, the filter condition where id<5 can be pushed down to the conditional clause after the keyword from specified by the data source. That is, it becomes Select count(id)from t1 where id<5. When the database executes this SQL statement, it will filter the data in the data table t1, so as to obtain only the data with id<5, and then perform subsequent calculations of aggregate functions.
[0079] After the above push-down process, the database will not obtain data with id greater than or equal to 5 when obtaining data, thereby reducing the amount of data returned after the table reads data, and at the same time reducing the amount of data for aggregation operations, thereby improving the efficiency of database queries.
[0080] Embodiment 2:
[0081] Original SQL statement: Select count(distinct t1.id)filter(where t1.id<5)from t1join t2on t1.id=t2.id.
[0082] The SQL statement after the filter condition is pushed down: Select count(distinct t1.id)from t1 join t2on t1.id=t2.id where t1.id<5.
[0083] In the second embodiment, the execution logic of the original SQL statement is that the database first obtains all the data of table t1 and table t2; then, according to the condition of t1.id=t2.id, table t1 and table t2 are connected to generate a temporary result set; then the rows with t1.id<5 are filtered out from the temporary result set; then, according to distinct t1.id, the value of t1.id is extracted from the filtered rows, and the duplicate values are removed; finally, the number of t1.id after deduplication is calculated. In this process, after the connection of table t1 and table t2, only the data rows with t1.id<5 are used, and the other data rows are not used, so they can be processed according to the method of the present invention.
[0084] After processing, the SQL statement with the filter condition pushed down is obtained: Select count(distinct t1.id)from t1 join t2 on t1.id=t2.id where t1.id<5.
[0085] Its execution logic becomes: first, according to the condition of t1.id=t2.id, table t1 and table t2 are connected to generate a temporary result set; then, the rows with t1.id<5 are filtered out in this temporary result set; then, the value of t1.id is extracted from the filtered rows, and duplicate values are removed; finally, the number of t1.id after deduplication is calculated. The pushed-down SQL statement will filter out the rows with t1.id<5 during the connection process, thereby reducing the amount of data returned after the table reads the data, and at the same time reducing the amount of data for aggregation operations, improving the efficiency of database queries.
[0086] Embodiment three;
[0087] Original SQL statement: Select count(v.id)filter(where v.id<5),sum(v.age)filter(where v.id<5)from(select id,age from t1)v.
[0088] The SQL statement after the filter condition is pushed down: Select count(v.id),sum(v.age)from(select id,age from t1)v where v.id<5.
[0089] In Example 3, the execution logic of the original SQL statement is to first execute the subquery (SELECT id, age FROMt1) to obtain the values of id and age; then use COUNT(v.id)FILTER(WHERE v.id<5) to calculate the number of all ids that meet the condition v.id<5; at the same time, use SUM(v.id)FILTER(WHERE v.id<5) to calculate the sum of all ids that meet the condition v.id<5; and finally output the results of two aggregate functions. In this process, only the data rows with v.id<5 are used, and other data rows are not used. In addition, the SQL statement meets the requirement that only aggregate functions exist in the target column, and the filter conditions of the aggregate functions are the same and do not contain grouping statements. Therefore, it can be processed according to the method of the present invention.
[0090] After processing, the SQL statement with the filter condition pushed down is obtained: Select count(v.id),sum(v.age)from(select id,age from t1)v where v.id<5.
[0091] First, execute the subquery (SELECT id, age FROM t1) to obtain the values of id and age; then, filter out the rows that meet the condition based on the condition WHERE v.id<5. Use COUNT(v.id) to calculate the number of all ids that meet the condition v.id<5. Use SUM(v.age) to calculate the sum of all ages that meet the condition v.id<5. The pushed-down SQL statement will filter out the rows with v.id<5 before executing the aggregate function, thereby reducing the amount of data returned after the table reads the data, and at the same time reducing the amount of data for the aggregate operation, improving the efficiency of database queries.
[0092] 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.
[0093] 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.
[0094] 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 operation 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 operation 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.
[0095] 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.
[0096] 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.
[0097] 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.
[0098] 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.
[0099] 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.
[0100] 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 operation statement, comprising: Obtaining the database operation statement; Determine whether the database operation statement meets the preset push-down condition; If so, the filter condition corresponding to the aggregate function in the database operation statement is pushed down to the conditional clause.
2. The method for processing database operation statements according to claim 1, wherein: The step of determining whether the database operation statement meets the preset push-down condition comprises: Determine whether only the aggregate function exists in the target column of the database operation statement; In the case that only the aggregate function exists in the target column, determining whether the filtering conditions of all the aggregate functions in the target column are the same and do not contain a group statement; When the filtering conditions of all the aggregate functions are the same and do not contain the grouping statement, it is determined that the database operation statement meets the preset push-down condition.
3. The method for processing database operation statements according to claim 2, wherein: The step of determining whether only the aggregate function exists in the target column of the database operation statement comprises: Parsing the database operation statement to obtain a parsing result; Identify query keywords in the database operation statement according to the analysis result; Determine the target column according to the query keyword; It is determined whether only the aggregate function exists in the target column.
4. The method for processing database operation statements according to claim 3, wherein: The step of determining whether the filtering conditions of all the aggregate functions in the target column are the same and do not contain a group statement comprises: Identify the filtering keywords corresponding to the aggregation function in the database operation statement according to the analysis result; Determine the filtering condition corresponding to the aggregation function according to the filtering keyword; Determine whether the filtering conditions corresponding to all the aggregate functions are the same and do not contain the grouping statement.
5. The method for processing database operation statements according to claim 3, wherein: The step of pushing the filter condition corresponding to the aggregate function in the database operation statement into the conditional clause comprises: Obtain the filtering condition corresponding to the aggregation function; Identify data source specified keywords according to the analysis results; The filtering condition is pushed down to the conditional clause after the keyword specified by the data source.
6. The method for processing database operation statements according to claim 2, wherein: After the step of determining whether only the aggregate function exists in the target column of the database operation statement, the following step is further included: When the target column of the database operation statement does not contain only the aggregate function, determining that the database operation statement does not meet the preset push-down condition; Execute corresponding operations according to the original database operation statement.
7. The method for processing database operation statements according to claim 1, wherein: After the step of pushing the filter condition corresponding to the aggregate function in the database operation statement into the conditional clause, the following step is further included: Perform verification according to the pushed-down database operation statement to determine whether the pushed-down database operation statement can be executed normally; If so, an execution plan is generated and executed according to the pushed-down database operation statement.
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 operation 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 operation 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 database operation statements according to any one of claims 1 to 7 when executing the machine executable program.