Database operation statement processing method and related product

By judging the existence of or logical keywords and related sub-connections in the database operation statement, and pushing down the condition clause to eliminate useless sub-connections, it solves the problem of limited performance improvement when sub-connections and external conditions are connected with or in the database, and realizes the More efficient database execution efficiency.

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

Patent Information

Application Number
CN202411598147.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the database, when the sub-connection condition is connected with another external condition using or, the existing optimization methods cannot effectively eliminate the sub-connection, resulting in limited performance improvement.

Method used

By determining whether there is an or logical keyword in the conditional statement of the database operation statement, and in the case of a related sub-connection, another conditional clause of the or logical keyword association is pushed down into the related sub-connection to complete the conversion. Eliminate useless subconnections.

Benefits of technology

This method can eliminate useless sub-connections in or logical keywords that meet the conditions, simplify execution plans, expand the optimization space of database operation statements, improve the execution efficiency of databases, and support optimization operations such as semi-connection conversion and anti-half-connection conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441278A_ABST
    Figure CN119441278A_ABST
Patent Text Reader

Abstract

The invention provides a database operation statement processing method and a related product. The method comprises the following steps: acquiring a database operation statement; judging whether an OR logic keyword exists in a conditional statement of the database operation statement or not; if yes, judging whether related sub-connections corresponding to the judgment keywords are recorded in the two conditional clauses connected with the logic keywords or not; and under the condition that the relevant sub-connection corresponding to the judgment keyword exists in the record, converting the database operation statement according to the judgment keyword existing in the record. Through the method, useless sub-connections in conditional or logic keywords can be eliminated, so that an execution plan is simplified, the optimization space of database operation statements is expanded, the execution efficiency of a database is improved, the database operation statements after elimination can execute optimization operations such as semi-connection conversion, reverse semi-connection conversion and the like, and the execution efficiency of the database is improved. And the processing speed of the database operation statement is further 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 operation statements and related products. Background Art

[0002] When processing a sub-join, the database often converts it into a semi-join operation to reduce repeated scanning of the sub-query, thereby improving performance. For example:

[0003] Select*from t1 where exists(select 1from t2 where t1.id=t2.id);

[0004] Can be converted into

[0005] Select*from t1 semi join t2 on t1.id=t2.id;

[0006] Optimization point: In the original statement, each piece of data in the outer table needs to be substituted into the sub-join and executed once, which generates a high cost. After optimization, each piece of data in the outer table is scanned to make conditional judgments with the data in the inner table. When the first pair of data is selected, the next piece of data in the outer table can be scanned. The cost is much lower than that of the original statement, and the performance is improved.

[0007] However, this optimization cannot be used when the sub-join condition is connected with another outer condition using or, such as:

[0008] Select*from t1 where value<10or exists(select 1from t2 where t1.id=t2.id). Summary of the invention

[0009] 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.

[0010] One object of the present invention is to enable a database operation statement that meets the conditions to also eliminate sub-connections.

[0011] A further object of the present invention is to improve the execution efficiency of the database.

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

[0013] Get database operation statements;

[0014] Determine whether there are OR logical keywords in the conditional statements of database operation statements;

[0015] If so, then determine whether the two conditional clauses connected by the judgment or logical keyword have records that determine the relevant sub-connection corresponding to the keyword;

[0016] In the case where there is a related sub-connection corresponding to the record existence determination keyword, the database operation statement is converted according to the record existence determination keyword.

[0017] Optionally, the record existence determination keywords include: exists;

[0018] The steps of converting database operation statements according to the record existence determination keyword include:

[0019] When the record existence determination keyword is exists, determine whether the sub-join query table in the relevant sub-join is an empty table;

[0020] If not, the other conditional clause associated with the OR logical keyword is pushed down to the relevant sub-connection to complete the conversion.

[0021] Optionally, when the record existence determination keyword is exists, after the step of determining whether the sub-connection query table in the relevant sub-connection is an empty table, the method further includes:

[0022] When the sub-connection query table in a related sub-connection is an empty table, the related sub-connection is eliminated.

[0023] Optionally, after the step of judging whether two conditional clauses of the logical keyword connection have records or whether there are related sub-connections corresponding to the judgment keywords, the following step is further included:

[0024] If there is no record of a related sub-connection corresponding to the judgment keyword between the two conditional clauses connected by the OR logical keyword, determine whether there is a sub-connection corresponding to a multi-value matching keyword between the two conditional clauses connected by the OR logical keyword. The multi-value matching keywords include: any, some;

[0025] If so, the sub-connection corresponding to the multi-value matching keyword is equivalently converted to the relevant sub-connection corresponding to exists;

[0026] According to the converted database operation statement, when the record existence determination keyword is exists, a step of determining whether the sub-connection query table in the related sub-connection is an empty table is executed.

[0027] Optionally, the record existence determination keywords include: not exists;

[0028] The steps of converting database operation statements according to the record existence determination keyword include:

[0029] When the record existence judgment keyword is not exists, determine whether the sub-connection query table in the relevant sub-connection is an empty table;

[0030] If not, the other conditional clause associated with the OR logical keyword is pushed down to the relevant sub-connection to complete the conversion.

[0031] Optionally, the step of pushing down another conditional clause associated with the OR logical keyword into the relevant sub-connection to complete the conversion includes:

[0032] Use the lnnvl function to wrap another conditional clause and push it down into the relevant sub-join to complete the transformation.

[0033] Optionally, when the record existence determination keyword is not exists, after the step of determining whether the sub-connection query table in the relevant sub-connection is an empty table, the method further includes:

[0034] Eliminate conditional statements when the sub-join query table in a correlated sub-join is an empty table.

[0035] 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.

[0036] 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.

[0037] 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.

[0038] The method for processing database operation statements of the present invention first obtains the database operation statement; determines whether there is an OR logic keyword in the conditional statement of the database operation statement; if so, determines whether there is a related sub-connection corresponding to the record existence determination keyword in two conditional clauses connected by the OR logic keyword; in the case where there is a related sub-connection corresponding to the record existence determination keyword, the database operation statement is converted according to the record existence determination keyword. Through this method, useless sub-connections in the OR logic keyword that meets the conditions can be eliminated, thereby simplifying the execution plan, expanding the optimization space of the database operation statement, and improving the execution efficiency of the database, and the eliminated database operation statement can perform optimization operations such as semi-join conversion and anti-semi-join conversion, further improving the processing speed of the database operation statement.

[0039] 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

[0040] 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:

[0041] Figure 1 is a flowchart of a method for processing database operation statements according to an embodiment of the present invention;

[0042] Figure 2 is a flowchart of a method for processing database operation statements according to another embodiment of the present invention;

[0043] Figure 3 is a flowchart of a method for processing database operation statements according to yet another embodiment of the present invention;

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

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

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

[0047] 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.

[0048] 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.

[0049] 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 S104.

[0050] 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.

[0051] Step S102, determining whether there is an OR logic keyword in the conditional statement of the database operation statement.

[0052] Step S103, determine whether the two conditional clauses connected by the OR logic keyword have a related sub-connection corresponding to the record existence determination keyword. The related sub-connection is a special sub-query, and its execution depends on the current row of the external query, that is, the existence of the external table information inside the conditional clause. The requirement that the conditional clause corresponding to the record existence determination keyword must be a related sub-connection before conversion is performed is to ensure the rationality of the optimization plan and avoid converting non-related sub-connections into related sub-connections, or the logic keyword is or in the SQL statement.

[0053] Step S104, converting the database operation statement according to the record existence determination keyword.

[0054] Through this method, useless sub-joins in qualified or logical keywords can be eliminated, thereby simplifying the execution plan, expanding the optimization space of database operation statements, and improving the execution efficiency of the database. In addition, the eliminated database operation statements can perform optimization operations such as semi-join conversion and anti-semi-join conversion, further improving the processing speed of database operation statements.

[0055] In some optional embodiments, the record existence determination keyword may generally include: exists; the step of converting the database operation statement according to the record existence determination keyword may generally include: when the record existence determination keyword is exists, determining whether the sub-connection query table in the related sub-connection is an empty table; if not, pushing down another conditional clause associated with the OR logical keyword to the related sub-connection to complete the conversion. Exists is used to test whether the sub-query returns at least one row of data. If the sub-query returns at least one row, the exists condition is true (true), otherwise it is false (false). This is usually used to check whether a row in a table exists in another table.

[0056] Optionally, when the record existence determination keyword is exists, after the step of determining whether the sub-connection query table in the relevant sub-connection is an empty table, it can generally also include: when the sub-connection query table in the relevant sub-connection is an empty table, eliminating the relevant sub-connection.

[0057] In order to clearly illustrate the conversion scheme of the present invention, a specific embodiment is provided as follows:

[0058] Select * from t1 where value<10 or exists(select 1 from t2 wheret1.id=t2.id) Formula 1

[0059] As can be seen from the SQL statement shown in Formula 1, there is a conditional statement "where value<10orexists(select 1from t2 where t1.id=t2.id)" in Formula 1. And there is a keyword or in the conditional statement, so it can be determined that the two conditional clauses connected by the keyword or are "value<10" and "exists(select 1from t2 where t1.id=t2.id)".

[0060] Then determine whether there are records in the two conditional clauses. The related sub-join corresponding to the keyword exists is a special sub-query, and its execution depends on the current row of the external query, that is, the existence of the external table information inside the conditional clause. The above conditional clause "exists (select 1 from t2 where t1.id = t2.id)" refers to t1.id inside it, so it can be determined that the SQL statement shown in formula 1 meets the conversion condition.

[0061] In the process of converting the SQL statement shown in Formula 1, it is first necessary to determine whether the content of the sub-connection query table (that is, the t2 table) is empty. Here, t2 needs to be a table without filtering conditions. If the content of the t2 table is determined to be empty, the content returned by "exists(select 1from t2 where t1.id=t2.id)" is false, which will cause the final result of the SQL statement shown in Formula 1 to be filtered only according to "value<10", thereby directly eliminating this related sub-connection. The final optimized SQL statement is shown in Formula 2:

[0062] Select * from t1 where value<10 Equation 2

[0063] As shown in Formula 2, the optimized SQL statement no longer needs to perform related sub-join operations, but only needs to filter the content of "value<10" in the t1 table. This greatly increases the execution speed of the SQL statement shown in Formula 1 and reduces database resource consumption.

[0064] Alternatively, if the content of table t2 is not empty, the result of the conditional clause "exists(select 1from t2 where t1.id=t2.id)" will affect the final result. At this time, another conditional clause associated with the keyword or (that is, "value<10") can be pushed down to the relevant sub-connection to complete the conversion. The SQL statement after push-down is shown in Formula 3:

[0065] Select*from t1 where exists(select 1from t2 where t1.id=t2.id ort1.value<10) Formula 3

[0066] As shown in Formula 3, after push-down, the SQL statement pushes the keyword or down to the relevant sub-join, and the SQL statement can be converted into a semi-join as needed, thereby optimizing the sub-join into a semi-join and improving performance.

[0067] In some other alternative embodiments, after the step of determining whether there is a relevant sub-connection corresponding to the record existence determination keyword for two conditional clauses connected by an OR logical keyword, the following steps may generally be included: In the case where there is no relevant sub-connection corresponding to the record existence determination keyword for two conditional clauses connected by an OR logical keyword, determine whether there is a sub-connection corresponding to a multi-value matching keyword for two conditional clauses connected by an OR logical keyword. The multi-value matching keywords include: any, some; if so, equivalently convert the sub-connection corresponding to the multi-value matching keyword into a relevant sub-connection corresponding to exists; execute the step of determining whether the sub-connection query table in the relevant sub-connection is an empty table in the case where the record existence determination keyword is exists according to the converted database operation statement. Among them, any and some are usually used in combination with a subquery to test whether a value meets the condition of being compared with any one value in the subquery result set, and the comparison operation is generally implemented through comparison operators (such as =, <, >, <>, etc.) to specify the condition to be met.

[0068] An optional SQL statement is shown in Formula 4:

[0069] Select * from t1 where value<10 or id < any(select id from t2) Formula 4

[0070] In the SQL statement shown in Formula 4, "id<any(select id from t2)" can generally be equivalently converted into an exists keyword. Its original meaning is to determine whether t1.id is less than any one id in the t2 table. Thus, after conversion, it becomes exists(select 1from t2 where t1.id<t2.id). Finally, the SQL statement obtained after converting the SQL statement shown in Formula 4 is shown in Formula 5:

[0071] Select * from t1 where value<10 or exists(select 1 from t2 wheret1.id<t2.id) Formula 5

[0072] As shown in Formula 5, the SQL statement is a connection between two conditional clauses using the keyword or, and there is a related sub-connection corresponding to the keyword exists, so it meets the conversion conditions, and can perform the step of judging whether the sub-connection query table in the related sub-connection is an empty table when the record existence judgment keyword is exists. Its conversion logic is the same as that of Formula 1, and will not be repeated here. In addition, the conversion logic of SQL statements using other comparison operators (such as =, <, >, <>, etc.) is the same as that of Formula 4, and those skilled in the art can perform equivalent conversion of SQL statements according to actual conditions.

[0073] In some other optional embodiments, the record existence determination keyword may generally include: not exists. Wherein not exists is opposite to exists, and is used to test whether the subquery does not return any rows. If the subquery does not return any rows, the not exists condition is true, otherwise it is false.

[0074] Optionally, the step of converting the database operation statement according to the record existence determination keyword can generally include: when the record existence determination keyword is not exists, determining whether the sub-connection query table in the related sub-connection is an empty table; if not, pushing down another conditional clause associated with the OR logical keyword to the related sub-connection to complete the conversion.

[0075] Optionally, the step of pushing down another conditional clause associated with the OR logical keyword into a related sub-connection to complete the conversion may generally include: using the lnnvl function to wrap the other conditional clause and push it down into the related sub-connection to complete the conversion.

[0076] In order to clearly illustrate the conversion scheme of the present invention, a specific embodiment is provided as shown in Formula 6:

[0077] Select*from t1 where value<10or not exists(select 1from t2 wheret1.id=t2.id)Equation 6

[0078] As can be seen from the SQL statement shown in Formula 6, there is a conditional statement "where value<10or notexists(select 1from t2 where t1.id=t2.id)" in Formula 6. And there is the keyword or in the conditional statement, so it can be determined that the two conditional clauses connected by the keyword or are "value<10" and "not exists(select1from t2where t1.id=t2.id)". Then, it is determined whether there are records in the two conditional clauses. The related sub-connection corresponding to the keyword not exists is determined. The conditional clause "not exists(select 1from t2 where t1.id=t2.id)" refers to t1.id inside it, so it can be determined that the SQL statement shown in Formula 6 meets the conversion condition.

[0079] In the process of converting the SQL statement shown in Formula 1, it is first necessary to determine whether the content of the sub-connection query table (i.e., table t2) is empty. Here, t2 needs to be a table without filtering conditions. If the content of table t2 is not empty, the result of the conditional clause "not exists (select 1 from t2 where t1.id = t2.id)" will affect the final result. At this time, another conditional clause associated with the keyword or (i.e., "value < 10") can be pushed down to the relevant sub-connection to complete the conversion.

[0080] In the process of pushing down the conditional clause "value<10", since the results of not exists and exists are completely opposite, in order to ensure that the converted SQL statement will not affect the final result, the lnnvl function is chosen to wrap the other conditional clause (that is, value<10) and push it down to the relevant sub-connection. The lnnvl function is generally used for the conditions in the where clause. If the condition is true, it returns false; if the condition is unknown or false, it returns true. The lnnvl function can reverse the result of "value<10", and then convert it into the correct result through the conversion of not exists. The final SQL statement after push-down is shown in Formula 7:

[0081] Select*from t1 where not exists(select 1from t2 where t1.id=t2.id orlnnvl(t1.value<10)) Formula 7

[0082] The SQL statement shown in Formula 7 can now be converted and optimized to anti join to improve performance.

[0083] Optionally, when the record existence judgment keyword is not exists, after the step of judging whether the sub-connection query table in the relevant sub-connection is an empty table, it can generally also include: when the sub-connection query table in the relevant sub-connection is an empty table, eliminating the conditional statement. Still taking the SQL statement shown in Formula 6 as an example, when it is determined that the content of the t2 table is empty, the content returned by "not exists (select 1 from t2 where t1.id = t2.id)" is true, which will cause the SQL statement shown in Formula 6 to eventually return all data, so its conditional statement (that is, "where value < 10 or not exists (select 1 from t2 where t1.id = t2.id)") can be completely eliminated, and the final optimized SQL statement is shown in Formula 8:

[0084] Select*from t1 formula8

[0085] As shown in Formula 8, the optimized SQL statement no longer needs to perform the screening operation of the conditional statement, but only needs to search the content of the t1 table. This greatly increases the execution speed of the SQL statement shown in Formula 6 and reduces the resource consumption of the database.

[0086] 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 S207.

[0087] Step S201, obtaining a database operation statement.

[0088] Step S202, determining whether there is an (exists / any / some) or statement in the conditional statement of the database operation statement.

[0089] Step S203, if the judgment in step S202 is yes, it is judged whether there are relevant sub-connections corresponding to the record existence determination keyword in the two conditional clauses connected by the logical keyword. It should be noted that the conditional clause corresponding to the record existence determination keyword must be a relevant sub-connection before conversion is performed in order to ensure the rationality of the optimization plan and avoid converting non-relevant sub-connections into relevant sub-connections.

[0090] To illustrate this exception, an example is provided as shown in Formula 9:

[0091] Select * from t1 where values<10 or exists(select 1 from t2) Formula 9

[0092] If the SQL statement shown in Formula 9 is converted according to the conversion scheme of the present invention, the resulting SQL statement is shown in Formula 10:

[0093] Select * from t1 where exists(select 1 from t2 or values<10) Equation 10

[0094] By comparing Formula 9 with Formula 10, it can be seen that the non-correlated sub-join in the SQL statement shown in Formula 9 can be executed only once to get the result, but the SQL statement shown in Formula 10 is forced to become a correlated sub-join and a semi-join due to the conversion rule, which makes the execution logic of the SQL statement complicated. Therefore, it is necessary to restrict it and only convert the conditional clauses containing correlated sub-joins.

[0095] Step S204, when the judgment in step S202 is no or the judgment in step S203 is no, the corresponding operation is performed according to the original database operation statement.

[0096] Step S205: If the result of step S203 is yes, it is determined whether the sub-connection query table in the relevant sub-connection is an empty table.

[0097] Step S206, if the judgment in step S205 is yes, eliminate the relevant sub-connection. When it is determined that the content of the sub-connection query table is empty, the content returned by the relevant sub-connection is all false, which will cause the final result of the SQL statement to be filtered only according to another conditional clause, so the relevant sub-connection can be directly eliminated, and only the other conditional clause is retained in the end. The optimized SQL statement no longer needs to execute the operation of the relevant sub-connection, which greatly increases the execution speed of the SQL statement and reduces the resource consumption of the database.

[0098] Step S207, when the judgment in step S205 is no, another conditional clause associated with the OR logic keyword is pushed down to the relevant sub-connection to complete the conversion.

[0099] It should be noted that when the keyword is any or some, the relevant sub-connection needs to be equivalently converted into the relevant sub-connection corresponding to exists, and then the subsequent steps are executed.

[0100] An optional example is shown in Formula 11:

[0101] Select * from t1 where value<10 or id <> any(select id from t2) Equation 11

[0102] In the SQL statement shown in Formula 11, "id<>any(select id from t2)" can generally be equivalently converted to the exists keyword. Its original meaning is to determine whether t1.id is not equal to any id in the t2 table. After conversion, it is converted to exists(select 1from t2 where t1.id<>t2.id). Finally, the SQL statement shown in Formula 11 is converted to the SQL statement shown in Formula 12:

[0103] Select * from t1 where value<10 or exists(select 1 from t2 wheret1.id<>t2.id) Equation 12

[0104] As shown in Formula 12, the SQL statement uses the keyword or to connect two conditional clauses, and there is a related sub-connection corresponding to the keyword exists, so it meets the conversion conditions and can continue to execute step S205.

[0105] It should be noted that the conversion logic of the SQL statements of the comparison operators (such as =, <, >, <>, etc.) that can be used with any and some is the same as formula 11, and technical personnel in this field can perform equivalent conversion of SQL statements according to actual conditions.

[0106] Through this method, useless sub-joins in the keyword or that meets the conditions can be eliminated, thereby simplifying the execution plan, expanding the optimization space of database operation statements, and improving the execution efficiency of the database. In addition, the eliminated database operation statements can perform optimization operations such as semi-join conversion and anti-semi-join conversion, further improving the processing speed of database operation statements.

[0107] Figure 3 FIG. 1 is a flow chart of a method for processing a database operation statement according to another embodiment of the present invention. Figure 3 As shown, the method for processing the database operation statement at least includes the following steps S301 to S307.

[0108] Step S301, obtaining a database operation statement.

[0109] Step S302, determine whether there is a (not exists) or statement in the conditional statement of the database operation statement. Not exists is the opposite of exists, and it is used to test whether the subquery does not return any rows. If the subquery does not return any rows, the not exists condition is true, otherwise it is false.

[0110] Step S303, when the judgment in step S302 is yes, it is judged whether there are records of related sub-connections corresponding to the judgment keywords in the two conditional clauses connected by the OR logical keywords.

[0111] Step S304: When the judgment in step S302 is No or the judgment in step S303 is No, the corresponding operation is performed according to the original database operation statement.

[0112] Step S305: If the result of the determination in step S303 is yes, it is determined whether the sub-connection query table in the relevant sub-connection is an empty table.

[0113] Step S306, if the judgment in step S305 is yes, eliminate the conditional statement. If it is determined that the content of the sub-connection query table is empty, the content returned by the relevant sub-connection is true, which will cause the SQL statement to return all data in the end, so all its conditional statements can be eliminated, and finally the optimized SQL statement no longer needs to perform the screening operation of the conditional statement, which greatly increases the execution speed of the SQL statement and reduces the resource consumption of the database.

[0114] Step S307, if the judgment in step S305 is no, use the lnnvl function to wrap another conditional clause and push it down to the relevant sub-connection to complete the conversion. In the process of pushing down the conditional clause, since the results of not exists and exists are completely opposite, in order to ensure that the converted SQL statement will not affect the final result, the lnnvl function is selected to wrap another conditional clause and push it down to the relevant sub-connection, wherein the lnnvl function is generally used for the conditions in the where clause, and returns false if the condition is true; and returns true if the condition is unknown or false. The result can be reversed by the lnnvl function, and then converted to the correct result through the conversion of not exists. The converted database operation statement can then perform optimization operations such as semi-join conversion and anti-semi-join conversion.

[0115] Through this method, useless sub-joins in the keyword or that meets the conditions can be eliminated, thereby simplifying the execution plan, expanding the optimization space of database operation statements, and improving the execution efficiency of the database. In addition, the eliminated database operation statements can perform optimization operations such as semi-join conversion and anti-semi-join conversion, further improving the processing speed of database operation statements.

[0116] 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.

[0117] 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.

[0118] This embodiment also provides a computer program product 10 , a computer readable storage medium 20 , and a computer device 30 . Figure 4 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention, Figure 5 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention, Figure 6 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.

[0119] 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.

[0120] 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.

[0121] 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.

[0122] 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.

[0123] 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.

[0124] 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 there is an OR logical keyword in the conditional statement of the database operation statement; If so, determine whether there are records of the two conditional clauses connected by the OR logical keyword and whether there are related sub-connections corresponding to the judgment keyword; In the case where the relevant sub-connection corresponding to the record existence determination keyword exists, the database operation statement is converted according to the record existence determination keyword.

2. The method for processing database operation statements according to claim 1, wherein: The record existence determination keywords include: exists; The step of converting the database operation statement according to the record existence determination keyword comprises: In the case where the record existence determination keyword is exists, determining whether the sub-connection query table in the related sub-connection is an empty table; If not, the other conditional clause associated with the OR logical keyword is pushed down into the relevant sub-connection to complete the conversion.

3. The method for processing database operation statements according to claim 2, wherein: After the step of determining whether the sub-connection query table in the related sub-connection is an empty table when the record existence determination keyword is exists, the following step further comprises: When the sub-connection query table in the related sub-connection is an empty table, the related sub-connection is eliminated.

4. The method for processing database operation statements according to claim 2, wherein: After the step of determining whether there are records of related sub-connections corresponding to the judgment keywords for the two conditional clauses connected by the OR logic keywords, the following step is further included: In the case that there is no record of a related sub-connection corresponding to the judgment keyword in the two conditional clauses connected by the OR logical keyword, it is determined whether there is a sub-connection corresponding to a multi-value matching keyword in the two conditional clauses connected by the OR logical keyword, and the multi-value matching keywords include: any, some; If so, convert the sub-connection corresponding to the multi-value matching keyword into a related sub-connection corresponding to exists; According to the converted database operation statement, a step of determining whether the sub-connection query table in the related sub-connection is an empty table is executed when the record existence determination keyword is exists.

5. The method for processing database operation statements according to claim 1, wherein: The record existence determination keywords include: not exists; The step of converting the database operation statement according to the record existence determination keyword comprises: In the case where the record existence determination keyword is not exists, determining whether the sub-connection query table in the related sub-connection is an empty table; If not, the other conditional clause associated with the OR logical keyword is pushed down into the relevant sub-connection to complete the conversion.

6. The method for processing database operation statements according to claim 5, wherein: The step of pushing down another conditional clause associated with the OR logical keyword into the relevant sub-connection to complete the conversion comprises: The conversion is completed by wrapping another conditional clause using the lnnvl function and pushing it down into the relevant sub-connection.

7. The method for processing database operation statements according to claim 5, wherein: After the step of determining whether the sub-connection query table in the related sub-connection is an empty table when the record existence determination keyword is not exists, the following step further comprises: When the sub-connection query table in the related sub-connection is an empty table, the conditional statement is eliminated.

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.