Database operation statement processing method and related product
By judging and converting sub-connections into array sub-connections in the database operation statement, the problem of data filtering when the tables involved in the sub-connection is not timely and the local table index is not used, achieving more efficient database operation execution efficiency and resource utilization.
Patent Information
- Application Number
- CN202411897571.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-15
AI Technical Summary
In the database operation statement, when the table involved in the sub-connection is an external table, the data cannot be filtered in advance after the sub-connection is promoted, resulting in large amount of data, long network transmission time, and low performance; at the same time, if the table involved in the sub-connection is a local table but the index column is not used, it will also affect the execution efficiency.
By determining whether there is a sub-connection in the database operation statement, and determining whether the sub-connection meets the preset conversion conditions, if it meets the sub-connection, the sub-connection is converted into an array sub-connection. When the table involved in the sub-connection is an external table, this conversion can perform data filtering in the remote database in advance and process the result locally, thereby reducing resource consumption in network transmission; when the table involved in the sub-connection is a local table and the index column exists, the index column can be continued to be used for rapid data scanning.
By converting sub-joins into array sub-joins, data can be filtered in advance when the tables involved in sub-joins are external tables, reducing resource consumption and improving execution speed; in the case of local tables, index columns can be effectively used to improve scanning performance, and avoiding the problem of unused indexes after improvement.
Smart Images

Figure CN119829604A_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] In current common database technology, when a sub-join appears in a database operation statement, in order to improve query efficiency, a common processing method is to promote the sub-join, generate a new join predicate based on the association predicate between the sub-join and the external query structure, so that the table in the external query structure is connected with the table in the sub-join, and finally obtain the connected result set.
[0003] In most cases, promoting a sub-join will bring about optimization effects. However, if the table involved in the sub-join is a foreign table, after promoting the sub-join, the join predicate cannot be sent to the remote database together with the foreign table, and the foreign table cannot filter data in advance, resulting in too much data in the foreign table returned from the remote end, spending more time on network transmission, and poor performance. If the table involved in the sub-join is not a foreign table, but a local table, but there is an index on the local table, and the sub-join predicate involves the index column, if the sub-join is promoted, the index may not be used, which will also affect the execution efficiency of database operation statements. Summary of the invention
[0004] 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.
[0005] An object of the present invention is to improve the execution efficiency of database operation statements.
[0006] A further object of the present invention is to filter data in advance and reduce resource consumption when the table involved in the sub-connection is a foreign table.
[0007] Yet another further object of the present invention is to improve scanning performance by using the index column when the table involved in the sub-join is a local table but the column involved is an index column.
[0008] In particular, the present invention provides a method for processing a database operation statement, comprising:
[0009] Get database operation statements;
[0010] Determine whether there is a sub-connection in the database operation statement;
[0011] In the case where a database operation statement has a sub-connection, determining whether the sub-connection meets a preset conversion condition, where the preset conversion condition is a conversion condition required to convert the sub-connection into an array sub-connection;
[0012] If the sub-connection meets the preset conversion conditions, the sub-connection is converted to an array sub-connection.
[0013] Optionally, the step of determining whether the sub-connection meets a preset conversion condition includes:
[0014] Determine whether the sub-connection type corresponding to the sub-connection belongs to any of the target types, including IN, SOME, ANY, and ALL;
[0015] When the sub-join type belongs to any of the target types, it is determined whether the sub-join belongs to a non-associative sub-join, where a non-associative sub-join means that the condition in the sub-join does not depend on an external data column;
[0016] In the case where the sub-connection is a non-associative sub-connection, it is determined whether the sub-connection contains a volatile function;
[0017] In the case where the sub-connection does not contain a volatile function, determine whether the sub-connection involves only a single data table;
[0018] When the sub-connection involves only a single data table, determine whether the data table meets the data table conversion conditions;
[0019] If so, it is determined that the sub-connection meets the preset conversion condition.
[0020] Optionally, the step of determining whether the data table meets the data table conversion condition includes:
[0021] Determine whether the data table is a local table;
[0022] When the data table is not a local table but a foreign table, it is determined that the data table meets the data table conversion conditions.
[0023] Optionally, after the step of determining whether the data table is a local table, the following steps are further included:
[0024] If the data table is a local table, determine whether the variable involved in the sub-join predicate in the sub-join is an index column;
[0025] If so, it is determined that the data table meets the data table conversion conditions.
[0026] Optionally, the step of determining whether the sub-connection type corresponding to the sub-connection belongs to any of the target types includes:
[0027] Parse the database operation statement to obtain the query structure of the database operation statement;
[0028] The query structure is traversed to execute the step of determining whether the sub-connection type corresponding to the sub-connection belongs to any of the target types.
[0029] Optionally, the step of converting the sub-connection to an array sub-connection includes:
[0030] Move the sub-connection to the array and change the sub-connection type to ARRAY type.
[0031] Optionally, after the step of converting the sub-connection into an array sub-connection, the step further includes:
[0032] Determine whether there are other sub-connections in the database operation statement;
[0033] If so, the step of determining whether the sub-connection meets the first conversion condition is recursively executed.
[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 operation statements are implemented.
[0035] 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.
[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 operation statement processing methods when executing the machine executable program.
[0037] The method for processing database operation statements of the present invention comprises the following steps: when obtaining a database operation statement, determining whether the database operation statement has a sub-connection; when the database operation statement has a sub-connection, determining whether the sub-connection meets a preset conversion condition, the preset conversion condition being a conversion condition required for converting the sub-connection into an array sub-connection; and then converting the sub-connection into an array sub-connection when the sub-connection meets the preset conversion condition. By means of this method, database operation statements that meet the conditions can be converted into array sub-connections, thereby giving priority to processing the processing results of the sub-connections and reducing the number of execution times of the sub-connections, thereby improving the execution efficiency of the database operation statements.
[0038] Furthermore, the method for processing database operation statements of the present invention determines that the data table meets the data table conversion condition when the data table involved in the sub-connection does not belong to the local table but to the external table, thereby converting the sub-connection into an array sub-connection. Through this method, when the table involved in the sub-connection is the external table, data filtering can be performed in advance in the remote database before the result is transmitted to the local through the network, thereby avoiding a large amount of invalid remote data consuming network resources, reducing resource consumption, and improving execution speed.
[0039] Furthermore, the method for processing database operation statements of the present invention determines whether the variable involved in the sub-connection predicate in the sub-connection is an index column when the data table belongs to a local table; if so, the data table is determined to meet the data table conversion condition, thereby converting the sub-connection into an array sub-connection. After the sub-connection is converted into an array sub-connection by this method, the array sub-connection can continue to use the index column for fast data scanning, thereby avoiding the situation where the index cannot be used after the sub-connection is promoted, thereby improving the scanning performance.
[0040] 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
[0041] 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:
[0042] Figure 1 is a flowchart of a method for processing database operation statements according to an embodiment of the present invention;
[0043] Figure 2 is a flowchart of a method for processing database operation statements according to another embodiment of the present invention;
[0044] Figure 3 is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0045] Figure 4 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and
[0046] Figure 5 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 can be considered as a sequenced list of executable instructions for implementing logical functions, which 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 S105.
[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 method of obtaining 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 how to obtain database operation statements according to actual conditions.
[0051] Step S102, determine whether there is a sub-connection in the database operation statement. A sub-connection is also often called a sub-query connection, which generally refers to another complete SQL query statement (inner sub-query) nested in an SQL query statement (outer query). The result of the inner sub-query is usually used by the outer query in some way to achieve more complex data screening, association, and acquisition of data with specific requirements.
[0052] Step S103: if the result of step S102 is yes, it is determined whether the sub-connection meets the preset conversion condition. The preset conversion condition is the conversion condition required to convert the sub-connection into an array sub-connection.
[0053] In some optional embodiments, the step of determining whether a sub-connection satisfies a preset conversion condition may generally include: determining whether a sub-connection type corresponding to the sub-connection belongs to any of the target types, the target types generally including IN, SOME, ANY, and ALL; in the case where the sub-connection type belongs to any of the target types, determining whether the sub-connection belongs to a non-associated sub-connection, a non-associated sub-connection means that the condition in the sub-connection does not depend on an external data column; in the case where the sub-connection belongs to a non-associated sub-connection, determining whether the sub-connection contains a volatile function; in the case where the sub-connection does not contain a volatile function, determining whether the sub-connection involves only a single data table; in the case where the sub-connection involves only a single data table, determining whether the data table meets the data table conversion condition; if so, determining that the sub-connection meets the preset conversion condition.
[0054] Among them, the IN type sub-join is generally used to determine whether a certain value in the outer query is in the result set returned by the subquery; the ANY operator is generally used to determine whether a certain value in the outer query satisfies a certain comparison relationship with any value in the result set returned by the subquery (for example, >, <, >=, <=, etc.); the ALL operator is used to determine whether a certain value in the outer query satisfies a certain comparison relationship with all values in the result set returned by the subquery. The SOME operator is generally used to determine whether a certain value in the outer query satisfies a certain comparison relationship with any value in the result set returned by the subquery. The above target types all require that a certain value in the outer query satisfies a certain comparison relationship with any value in the result set returned by the subquery. Those skilled in the art can determine the specific type of target type based on actual conditions.
[0055] In addition, whether a sub-join is a non-correlated sub-join is determined because the execution of a correlated sub-join depends on each row of data in the external query. In other words, the sub-query will reference the columns of the table in the outer query, and will execute the sub-query multiple times for different values of the current row of the outer query to perform corresponding condition judgments, and the sub-join cannot be executed independently. A non-correlated sub-join means that the conditions in the sub-join do not depend on external data columns, so a non-correlated sub-join can be executed independently.
[0056] Volatile functions are functions that may return different results each time they are called, even if the input parameters are the same, such as RANDOM(), CURRENT_TIMESTAMP, etc. Using such functions in a sub-connection will cause the result of the sub-connection to be uncertain. When the sub-connection is converted to the ARRAY type, the query execution plan may perform some optimization and pre-calculation based on this array. However, due to the existence of volatile functions, the results obtained from each execution of the sub-connection may be different, which may make the pre-calculation and optimization based on the previous results invalid, resulting in inaccurate or unstable query results. Therefore, it is necessary to ensure that there are no volatile functions in the sub-connection of the database operation statement.
[0057] In some optional embodiments, the step of determining whether a data table meets the data table conversion condition may generally include: determining whether the data table belongs to a local table; and determining that the data table meets the data table conversion condition when the data table does not belong to a local table but belongs to a foreign table. Among them, a local table generally refers to a table stored on a physical storage medium local to the server where the current database instance is located, and its data access is relatively direct. A foreign table is generally relative to a local table, and generally refers to a data table introduced by some remote connections of the database, external data source links, etc., such as a table connected to other database instances through a database link. Foreign table data may be stored on a remote server or other external storage medium, and network transmission and other issues may be involved when accessing it. If the table involved in the sub-connection is a foreign table, after the sub-connection is promoted by the existing method, the connection predicate cannot be sent to the remote database together with the foreign table, and the foreign table cannot filter the data in advance, resulting in too much data in the foreign table returned from the remote end, spending more time on network transmission, and poor performance. Therefore, it is necessary to convert such database operation statements by the method of the present invention to reduce the consumption of redundant network transmission resources.
[0058] Step S104, when the judgment in step S103 is yes, convert the sub-connection into an array sub-connection.
[0059] In some optional embodiments, the step of converting a sub-connection into an array sub-connection may generally include: moving the sub-connection into an array, and modifying the type of the sub-connection to an ARRAY type. After being converted into an ARRAY type, when processing the converted database operation statement, the database will first query to obtain the result of the sub-connection and place the result in an array to perform the next step of operation with the external query. In this way, when the table involved in the sub-connection is a foreign table, data filtering can be performed in advance in the remote database before the result is transmitted to the local through the network, thereby avoiding a large amount of invalid remote data consuming network resources, reducing resource consumption, and improving execution speed.
[0060] Through this method, the database operation statements that meet the conditions can be converted into array sub-connections, so as to give priority to the processing results of the sub-connections and reduce the execution times of the sub-connections, thereby improving the execution efficiency of the database operation statements.
[0061] In some optional embodiments, after the step of determining whether the data table belongs to a local table, the following may be generally included: if the data table belongs to a local table, determining whether the variable involved in the sub-connection predicate in the sub-connection is an index column; if so, determining that the data table meets the data table conversion condition. If the data table belongs to a local table and the variable involved in the sub-connection predicate in its sub-connection is an index column, the index may not be used after the sub-connection is promoted. However, the method of the present invention places the sub-connection in an array and can also use the index of the index column to scan data, thereby avoiding the situation where the index cannot be used after the sub-connection is promoted, thereby improving scanning performance.
[0062] In some other optional embodiments, after the step of converting the sub-connection into an array sub-connection, the following steps may be generally included: determining whether there are other sub-connections in the database operation statement; if so, recursively executing the step of determining whether the sub-connection meets the first conversion condition. In some complex database operation statements, repeated nesting may occur, that is, the next layer of the sub-query still has a sub-query nested. For such a situation, the method of the present invention may be recursively executed to replace layer by layer to improve the performance of the database.
[0063] In some other optional embodiments, the step of determining whether the sub-connection type corresponding to the sub-connection belongs to any of the target types may generally include: parsing the database operation statement to obtain the query structure of the database operation statement; traversing the query structure, and executing the step of determining whether the sub-connection type corresponding to the sub-connection belongs to any of the target types. The parsing step usually involves converting the database operation statement into a data format that is easier for the computer to understand and operate. Usually, this involves identifying keywords (such as SELECT, FROM, WHERE, etc.), table names, field names, conditional expressions, etc. in SQL, and organizing them according to a certain logical structure. This parsed form is called a "query structure" or "abstract syntax tree", which represents all the components of the original SQL statement and their relationships in a more intuitive way. In this way, the above judgment process can be accelerated through the query structure.
[0064] 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 S209.
[0065] Step S201, obtaining a database operation statement.
[0066] Step S202: determine whether the sub-connection type corresponding to the sub-connection belongs to any of the target types.
[0067] Step S203: if the answer in step S202 is yes, determine whether the sub-connection is a non-associated sub-connection.
[0068] Step S204: if the answer in step S203 is yes, determine whether the sub-connection contains a volatile function.
[0069] Step S205: if the result of step S204 is no, it is determined whether the sub-connection involves only a single data table.
[0070] Step S206: If the answer in step S205 is yes, determine whether the data table is a local table.
[0071] Step S207: If the result of the determination in step S206 is no, it is determined whether the variable involved in the sub-join predicate in the sub-join is an index column.
[0072] Step S208, when the determination result in step S206 is no or the determination result in step S207 is yes, the sub-connection is moved to the array, and the type of the sub-connection is modified to the ARRAY type.
[0073] Step S209, when any of steps S202, S203, S205, and S207 is judged as no, or step S204 is judged as yes, or step S208 is executed, continue to execute other optimization operations.
[0074] It should be noted that in some complex database operation statements, repeated nesting may occur, that is, the next layer of the subquery still has subqueries nested. For such situations, you can choose to recursively execute the method of the present invention, so as to replace layer by layer to improve the performance of the database.
[0075] Through this method, when the table involved in the sub-connection is a foreign table, data can be filtered in the remote database in advance before the result is transmitted to the local through the network, avoiding a large amount of invalid remote data consuming network resources, reducing resource consumption, and improving execution speed. Or when the data table is a local table and the variable involved in the sub-connection predicate in its sub-connection is an index column, the sub-connection can be placed in an array and the index of the index column can also be used for data scanning, thereby avoiding the situation where the index cannot be used after the sub-connection is promoted, and improving scanning performance.
[0076] In order to clearly illustrate the processing flow of this method, some optional embodiments are proposed as follows:
[0077] Embodiment 1:
[0078] select * from t1 where t1.a = any (select a from t2) Formula 1
[0079] In the SQL statement shown in Formula 1, table t1 is a local table, and table t2 is a foreign table, that is, a table in a remote database. When the database receives the SQL statement shown in Formula 1, it first executes step S202: Since there is a sub-connection select a from t2 inside it, and the sub-connection type of the sub-connection is any, it belongs to the target type.
[0080] If the judgment in step S202 is yes, step S203 is executed: since the data table involved in the sub-join is table t2 and is not related to table t1, the sub-join is a non-associative sub-join;
[0081] If the answer in step S203 is yes, step S204 is executed: since the sub-connection select a from t2 only queries the data of column a from table t2, its result value is a fixed value and will not change, so it is not a volatile function.
[0082] If the result of the judgment in step S204 is no, step S205 is executed: since the sub-join only involves the t2 table, it is a case where only a single data table is involved.
[0083] If the result of step S205 is yes, step S206 is executed: according to the pre-set configuration, table t2 belongs to the outer table, so the result of step S206 is no.
[0084] If the result of step S206 is negative, step S208 is executed: the sub-connection select a from t2 is moved to the array, and the type of the sub-connection is changed to ARRAY type. The database operation statement finally obtained is shown in Formula 2:
[0085] select * from t1 where t1.a = any(array(select a from t2)) Formula 2
[0086] When the database faces the SQL statement shown in Formula 2, it will first filter the outer table t2 in the remote database to obtain the data in column a of the t2 table, and then transmit the data in column a to the local database through the network for query. This can avoid transmitting all the data in the t2 table to the local database and directly filter it in the remote database. When the amount of data is large, it can reduce the resource consumption of network transmission.
[0087] It should be noted that different databases may use different array keywords. The art can make adjustments based on the actual conditions of different databases as long as the purpose of the present invention can be achieved.
[0088] Embodiment 2:
[0089] select*from test2 where test2.a in(select a from test1)Equation 3
[0090] In the SQL statement shown in Formula 3, the test2 table is a local table, and the test1 table is a foreign table, that is, a table in a remote database. When the database receives the SQL statement shown in Formula 3, it first executes step S202: Since there is a sub-connection select a from test1 inside it, and the sub-connection type of the sub-connection is in, it belongs to the target type.
[0091] If the judgment in step S202 is yes, step S203 is executed: since the data table involved in the sub-join is table t2 and is not related to table t1, the sub-join is a non-associative sub-join;
[0092] If the judgment in step S203 is yes, step S204 is executed: since the sub-connection select a from test1 only queries the data of column a from the test1 table, its result value is a fixed value and will not change, so it does not belong to a volatile function.
[0093] If the result of the judgment in step S204 is no, step S205 is executed: since the sub-join only involves the test1 table, it is a case where only a single data table is involved.
[0094] If the result of step S205 is yes, step S206 is executed: according to the pre-set configuration, the test1 table belongs to the foreign table, so the result of step S206 is no.
[0095] If the judgment in step S206 is no, step S208 is executed: the sub-connection select a from test1 is moved to the array, and the type of the sub-connection is changed to ARRAY type. The database operation statement finally obtained is shown in Formula 4:
[0096] select*from test2 where test2.a in(array(select a from test1))Equation 4
[0097] When the database faces the SQL statement shown in Formula 4, it will first filter the outer table test1 in the remote database to obtain the data in column a of the test1 table, and then transmit the data in column a to the local database through the network for query. This can avoid transmitting all the data in the t2 table to the local database and directly filter in the remote database. In the case of large amounts of data, it can reduce the resource consumption of network transmission and improve the execution speed. After actual testing, the execution time was reduced from 8264.951ms to 731.278ms.
[0098] Embodiment three:
[0099] select test2.b from test2 where test2.a in(select max(test1.a)fromtest1 group by test1.a)Equation 5
[0100] In the SQL statement shown in Formula 5, the test2 table is a local table, and the test1 table is a foreign table, that is, a table in a remote database. When the database receives the SQL statement shown in Formula 5, it first executes step S202: Since there is a sub-connection select max(test1.a)from test1 group by test1.a inside it, and the sub-connection type of the sub-connection is in, it belongs to the target type.
[0101] If the judgment in step S202 is yes, step S203 is executed: since the data table involved in the sub-join is table t2 and is not related to table t1, the sub-join is a non-associative sub-join;
[0102] If the judgment in step S203 is yes, step S204 is executed: since the sub-join queries the maximum value of column a from the test1 table, the result value is a fixed value and will not change, so it is not a volatile function.
[0103] If the result of the judgment in step S204 is no, step S205 is executed: since the sub-join only involves the test1 table, it is a case where only a single data table is involved.
[0104] If the result of step S205 is yes, step S206 is executed: according to the pre-set configuration, the test1 table belongs to the foreign table, so the result of step S206 is no.
[0105] If the judgment in step S206 is no, execute step S208: move the sub-connection select max(test1.a)from test1 group by test1.a to the array, and change the type of the sub-connection to ARRAY type. The database operation statement finally obtained is shown in Formula 6:
[0106] select test2.b from test2 where test2.a in(array(select max(test1.a)from test1group by test1.a)) Formula 6
[0107] When the database faces the SQL statement shown in Formula 6, it will first filter the outer table test1 in the remote database to obtain the maximum value of column a in the test1 table, and then transmit the maximum value of column a to the local database through the network for query. This can avoid transmitting all the data of the t2 table to the local database and directly filter in the remote database. In the case of large amounts of data, it can reduce the resource consumption of network transmission and improve the execution speed. After actual testing, the execution time was reduced from 45.318ms to 36.936ms.
[0108] 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.
[0109] 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.
[0110] 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 5is 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.
[0111] 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.
[0112] 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.
[0113] 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.
[0114] 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.
[0115] 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.
[0116] 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 a sub-connection in the database operation statement; In the case where the sub-connection exists in the database operation statement, determining whether the sub-connection meets a preset conversion condition, where the preset conversion condition is a conversion condition required to convert the sub-connection into an array sub-connection; When the sub-connection meets the preset conversion condition, the sub-connection is converted into the array sub-connection.
2. The method for processing database operation statements according to claim 1, wherein: The step of determining whether the sub-connection meets the preset conversion condition comprises: Determine whether the sub-connection type corresponding to the sub-connection belongs to any of the target types, where the target types include IN, SOME, ANY, and ALL; In the case where the sub-connection type belongs to any of the target types, determining whether the sub-connection belongs to a non-associative sub-connection, wherein the non-associative sub-connection means that a condition in the sub-connection does not depend on an external data column; In the case where the sub-connection belongs to the non-associative sub-connection, determining whether the sub-connection contains a volatile function; In the case where the sub-connection does not include the volatile function, determining whether the sub-connection involves only a single data table; In the case where the sub-connection involves only a single data table, determining whether the data table meets a data table conversion condition; If so, it is determined that the sub-connection meets the preset conversion condition.
3. The method for processing database operation statements according to claim 2, wherein: The step of judging whether the data table meets the data table conversion condition comprises: Determine whether the data table belongs to a local table; When the data table does not belong to a local table but to a foreign table, it is determined that the data table meets the data table conversion condition.
4. The method for processing database operation statements according to claim 2, wherein: After the step of determining whether the data table belongs to a local table, the following step further includes: In the case where the data table is a local table, determining whether a variable involved in a sub-join predicate in the sub-join is an index column; If so, it is determined that the data table meets the data table conversion condition.
5. The method for processing database operation statements according to claim 2, wherein: The step of determining whether the sub-connection type corresponding to the sub-connection belongs to any of the target types includes: Parsing the database operation statement to obtain a query structure of the database operation statement; The query structure is traversed to execute the step of determining whether the sub-connection type corresponding to the sub-connection belongs to any one of the target types.
6. The method for processing database operation statements according to claim 1, wherein: The step of converting the sub-connection into the array sub-connection comprises: Move the sub-connection to an array, and change the type of the sub-connection to an ARRAY type.
7. The method for processing database operation statements according to claim 1, wherein: After the step of converting the sub-connection into the array sub-connection, the following steps are further included: Determine whether there are other sub-connections in the database operation statement; If so, the step of determining whether the sub-connection meets the first conversion condition is recursively executed.
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.