Table self-connection optimization method and database
By rewriting the SQL statement, the self-join operation is converted into an equivalence comparison of the target column and a non-equivalence comparison of the non-target column, and aggregate functions are used to filter the data, which solves the problem of inefficiency and redundant data in the table self-join operation. problem, achieving more efficient execution plans and query results.
Patent Information
- Application Number
- CN202310308355.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-27
- Publication Date
- 2024-10-11
AI Technical Summary
The current query optimizer is inefficient in table self-join operations, resulting in low efficiency in the table self-join operation process, and cannot effectively solve the problem of redundant data in self-join output results.
By rewriting the SQL statement entered by the user, an execution plan with equivalent execution effect but better execution performance is generated. The specific method includes converting the self-join operation into an equivalence comparison of the target column and a non-equivalence comparison of the non-target column, and Filter out target data through aggregate functions and generate new execution plans to improve efficiency.
It reduces the performance overhead caused by the expansion of the number of self-join rows, removes redundant data in self-join output results, and improves the execution efficiency of the database and the accuracy of query results.
Smart Images

Figure CN118760701A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of cloud computing, and more specifically, to a method and a database for optimizing table self-join. Background Art
[0002] In order to extract important information from different tables, the method of connecting tables in the database is widely used, and then the important information in different tables is matched together to achieve a streamlined effect. In actual operation, structured query language SQL statements are generally used to connect tables. Therefore, the execution efficiency of SQL statements has a great impact on the efficiency of connecting tables. The query optimizer included in the database can optimize SQL statements and find out the equivalent transformation form of the original complex SQL statements, making the database execution more efficient.
[0003] However, at present, the application scenarios of table self-join are gradually increasing, and the optimization method in the current query optimizer is not effective for optimizing table self-join, resulting in low efficiency of the table self-join operation process. Summary of the invention
[0004] The embodiment of the present application provides a method and database for optimizing table self-join, which rewrites the SQL statement input by the user into the database, generates an execution plan with equivalent execution effect but better execution performance, and improves the execution efficiency of the database.
[0005] In a first aspect, a method for optimizing table self-join is provided, the method being applied to a database, the method comprising: the database obtaining a first structured query language SQL statement corresponding to a first execution plan, the first execution plan being used to execute a self-join operation of at least two first tables to obtain a target data table for business processing, the first SQL statement being used to describe the execution process of the self-join operation; the database rewriting the first SQL statement to generate a second execution plan, the second execution plan being used to execute a join operation of a first table and at least one second table, the second table being determined by screening data of the first table; the database executing the second execution plan to obtain the target data table for business processing.
[0006] According to the technical solution provided in the present application, the database can modify the first SQL statement corresponding to the original execution plan, and then generate a new execution plan with higher execution efficiency. The execution effect of the new execution plan is equivalent to the execution effect of the original execution plan, and the performance of the execution plan is better than the original execution plan.
[0007] In combination with the first aspect, in certain implementations of the first aspect, the self-join operation includes performing an equality comparison on the data of the target columns of at least two first tables and a non-equality comparison on the data of the non-target columns, where the target column is one or more data columns in the first table to which the target data table belongs, and the non-target column is one or more data columns in the first table other than the target column.
[0008] According to the technical solution provided by the present application, the table self-join optimization method of the present application is applied to scenarios where self-join operations use more equal comparisons of target columns and non-equal comparisons of non-target columns, thereby reducing the performance overhead caused by the expansion of the number of self-join rows in this scenario.
[0009] In combination with the first aspect, in some implementations of the first aspect, the second table is determined after performing an aggregation operation on the first table, where the aggregation operation is used to sort and filter the data of the target column in the first table by using an aggregation function.
[0010] According to the technical solution provided in the present application, redundant data of the self-join output results is removed, the amount of data in the query result set is reduced, and the execution efficiency is improved.
[0011] In combination with the first aspect, in certain implementations of the first aspect, the aggregation operation includes using an aggregation function to count the number of non-repeating data values in the non-target column corresponding to each data value in the target column, and filtering out the target data value in the target column, the number of non-repeating data values in the non-target column corresponding to the target data value being greater than or equal to the target number threshold.
[0012] According to the technical solution provided in the present application, through logical conversion, the application method of the above-mentioned equal value comparison of the target column and the non-equal value comparison of the non-target column is converted into comparing the number of non-repeating data values of the non-target column, thereby improving the execution efficiency of the table connection process.
[0013] In combination with the first aspect, in certain implementations of the first aspect, the database rewrites the first SQL statement to generate a second execution plan, including: the database rewrites the first SQL statement into a second SQL statement, where the second SQL statement is used to describe the execution process of a connection operation between a first table and at least one second table; and the database generates a second execution plan based on the second SQL statement.
[0014] According to the technical solution provided in the present application, the SQL statement originally used for table self-connection is converted into an SQL statement for self-connection of different tables, thereby generating an execution plan with higher execution efficiency.
[0015] In a second aspect, a database is provided, comprising: an acquisition module, used to acquire a first structured query language SQL statement corresponding to a first execution plan, the first execution plan being used to execute a self-join operation of at least two first tables to obtain a target data table for business processing, the first SQL statement being used to describe the execution process of the self-join operation; a rewrite module, used to rewrite the first SQL statement to generate a second execution plan, the second execution plan being used to execute a join operation of a first table and at least one second table, the second table being determined by screening the data of the first table; and an execution module, used to execute the second execution plan to obtain the target data table for business processing.
[0016] In combination with the second aspect, in certain implementations of the second aspect, the self-join operation implemented by the first SQL statement includes performing an equality comparison on the data of the target columns of at least two first tables and a non-equality comparison on the data of the non-target columns, where the target column is one or more data columns in the first table to which the target data table belongs, and the non-target column is one or more data columns in the first table other than the target column.
[0017] In combination with the second aspect, in some implementations of the second aspect, the second table is determined after performing an aggregation operation on the first table, and the aggregation operation is used to sort and filter the data of the target column in the first table by using an aggregation function.
[0018] In combination with the second aspect, in certain implementations of the second aspect, the aggregation operation includes using an aggregation function to count the number of non-repeating data values in the non-target column corresponding to each data value in the target column, and filtering out the target data value in the target column, the number of non-repeating data values in the non-target column corresponding to the target data value being greater than or equal to the target number threshold.
[0019] In combination with the second aspect, in some implementations of the second aspect, the rewriting module is specifically used to rewrite the first SQL statement into a second SQL statement, where the second SQL statement is used to describe the execution process of a connection operation between a first table and at least one second table, and generate a second execution plan based on the second SQL statement.
[0020] In a third aspect, a computing device is provided, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory, so that the computing device executes the method in the first aspect or any possible implementation of the first aspect.
[0021] In a fourth aspect, a computing device cluster is provided, comprising at least two computing devices, each computing device comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, so that the computing device cluster executes the method in the first aspect or any possible implementation of the first aspect.
[0022] Optionally, the processor may be a general-purpose processor, which may be implemented by hardware or software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc.; when implemented by software, the processor may be a general-purpose processor, which is implemented by reading software codes stored in a memory, which may be integrated in the processor or may be located outside the processor and exist independently.
[0023] In a fifth aspect, a chip is provided, which obtains instructions and executes the instructions to implement the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0024] Optionally, as an implementation, the chip includes a processor and a data interface, and the processor reads instructions stored in the memory through the data interface to execute the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0025] Optionally, as an implementation method, the chip may also include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the method in the above-mentioned first aspect or any possible implementation method of the first aspect.
[0026] In a sixth aspect, a computer program product comprising instructions is provided. When the instructions are executed by a computing device or a computing device cluster, the computing device or the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0027] In the seventh aspect, a computer-readable storage medium is provided, comprising computer program instructions. When the computer instructions are executed by a computing device or a computing device cluster, the computing device or the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0028] By way of example, these computer-readable storage media include, but are not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), Flash memory, electrically EPROM (EEPROM), and hard drive.
[0029] Optionally, as an implementation manner, the above-mentioned storage medium may specifically be a non-volatile storage medium. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a system diagram based on a cloud server system provided in an embodiment of the present application.
[0031] Figure 2 It is a schematic diagram of a system architecture for database query optimization provided in an embodiment of the present application.
[0032] Figure 3 It is a schematic block diagram of a method for optimizing table self-join provided in an embodiment of the present application.
[0033] Figure 4 It is a schematic block diagram of an execution plan before and after rewriting provided in an embodiment of the present application.
[0034] Figure 5 It is a schematic block diagram of another execution plan before and after rewriting provided in an embodiment of the present application.
[0035] Figure 6 It is a schematic block diagram of another execution plan before and after rewriting provided in an embodiment of the present application.
[0036] Figure 7 It is a schematic structural block diagram of a database provided in an embodiment of the present application.
[0037] Figure 8 It is a schematic structural block diagram of a computing device provided in an embodiment of the present application.
[0038] Fig. 9 It is a schematic structural block diagram of a computing device cluster provided in an embodiment of the present application.
[0039] Fig.10 It is a schematic structural block diagram of another computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0041] Unless otherwise specified, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art of the present application. The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit the scope of this application.
[0042] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0043] In addition, in the embodiments of the present application, words such as "exemplary" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.
[0044] In the embodiments of the present application, "corresponding (corresponding, relevant)" and "corresponding (corresponding)" can sometimes be used interchangeably. It should be pointed out that when the distinction between them is not emphasized, the meanings they intend to express are consistent.
[0045] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are equally applicable to similar technical problems.
[0046] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0047] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: including the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0048] In order to facilitate understanding of the technical solution of the present application, the professional terms mentioned in the present application are briefly explained below.
[0049] SQL statement: Structured query language (SQL) is a standard language used for database programming. SQL statements can complete all activities in the database life cycle, including defining relationship models, entering data, establishing databases, querying, updating, maintaining, reconstructing databases, and controlling database security.
[0050] Database: A database is a warehouse that organizes, stores and manages data according to data structures. It is a collection of large amounts of data that is stored for a long time, organized, shareable and uniformly managed. A database can organize data more appropriately, maintain data more conveniently, control data more closely and use data more effectively.
[0051] Outer join: In the process of joining two tables, the result of the join operation not only returns the rows that meet the join conditions, but also returns the rows that do not meet the conditions in at least one of the two tables. This kind of connection is called an outer join. Outer joins are generally used when all data needs to be queried in the process of querying multiple tables.
[0052] Inner join: In the process of joining two tables, the rows of two or more tables with the same column are merged, and the final output result set does not contain rows that do not match one table with another table. This kind of connection is called an inner join.
[0053] Self-join: The join operation between a table and itself is called self-join. By using self-join, a mirror image of its own table can be treated as another table, thereby completing related query operations on the table itself.
[0054] Query optimization: SQL statements are descriptive languages. Database users only describe the desired results and do not care about the specific way to obtain data. It is difficult to express the SQL statements entered into the database in the optimal form. This information can be mined to generate more efficient SQL statements. Query optimization is to convert the SQL statements entered by users into more efficient equivalent SQL statements to generate more efficient execution plans.
[0055] Execution plan: The execution plan is the specific execution process of the SQL statement.
[0056] At present, with the development of the Internet and the advent of the era of big data, the Internet is flooded with a large amount of data, including text data, image data, sound data, etc. A database with a large storage space can be used to store a large amount of data in a regular manner, so that users who use the database can quickly query the data. The database can be an external hardware, such as a local computer or local server that stores data, or a database deployed in a cloud environment, such as a cloud database deployed in a cloud server. For example, with the development of cloud computing technology, cloud databases are gradually being used by enterprises in large quantities. Cloud databases aim to integrate a large number of existing database resources located in the network background through cloud computing, and provide database resource access at the infrastructure level for cloud computing applications, thereby reducing enterprise operating costs and improving the utilization rate of enterprise database resources.
[0057] To understand the cloud environment, Figure 1 A schematic diagram of a system based on a cloud server system is shown. Figure 1 As shown, the cloud management platform 110 is used to manage the infrastructure that provides multiple cloud services, the infrastructure includes multiple cloud data centers, each cloud data center includes multiple servers, each server includes cloud service resources, and provides corresponding cloud services for tenants. The cloud database can be deployed on the server in the cloud data center.
[0058] The cloud management platform 110 provides an access interface (such as an interface or an application program interface (API)). The tenant can operate the client remote access access interface to register a cloud account and password on the cloud management platform and log in to the cloud management platform. After the cloud management platform successfully authenticates the cloud account and password, the tenant can further pay to select and purchase a virtual machine with specific specifications (processor, memory, disk) on the cloud management platform. After the payment is successful, the cloud management platform provides the remote login account and password of the purchased virtual machine. The client can remotely log in to the virtual machine and install and run the tenant's application in the virtual machine. Tenants of cloud services can be individuals, enterprises, schools, hospitals, administrative agencies, etc.
[0059] The functions of the cloud management platform 110 include, but are not limited to, user console, computing management service, network management service, storage management service, authentication service, and image management service. The user console provides an interface or API to interact with tenants, the computing management service is used to manage servers running virtual machines and containers and bare metal servers, the network management service is used to manage network services (such as gateways, firewalls, etc.), the storage management service is used to manage storage services (such as data bucket services), the authentication service is used to manage tenant accounts and passwords, and the image management service is used to manage virtual machine images. Tenants can use the client 130 to log in to the cloud management platform 110 through the Internet 120 to manage the rented cloud services.
[0060] For example, in an embodiment of the present application, a tenant can configure and operate data instances in a table through the cloud management platform 110, such as inputting an SQL statement and optimizing and rewriting the SQL statement through the query optimizer of the cloud database, and finally generating an execution plan with higher performance.
[0061] A database may contain multiple tables, each of which may contain a lot of data. Some of the data in the database is worth the user's attention, and the database user needs to extract the data that is worth the attention from the database. However, in most cases, the data that is worth the attention may belong to different tables, and the user can generate a new table by connecting the tables. The new table contains all the data that is worth the user's attention. The user can then filter out the data that is worth the attention in the new table by filtering conditions.
[0062] The principle of the table connection operation is to compare or filter the data of at least two tables to form a general table, and then filter out the data that meets the filter conditions given by the user according to the query conditions. For example, Table 1 describes the family numbers of different objects, Table 2 describes the home addresses corresponding to different family numbers, and Table 3 describes the landline numbers corresponding to different family numbers. The user is concerned about the home addresses and landline numbers of different objects. Furthermore, the user can generate a new Table 4 through the connection operation of Table 1, Table 2 and Table 3. The specific connection operation is to correspond the family number to the object in Table 1, the home address in Table 2 and the landline number in Table 3 respectively.
[0063] Table 1
[0064] Object Family Number A1 B1 A2 B3 A3 B5 A4 B7 A5 B9
[0065] Table 2
[0066] Family Number Home address B1 No.1, A Road B3 No. 3, B Road B7 No. 8 H Road B9 No. 9, C Road
[0067] Table 3
[0068] Family Number Landline Number B3 123XXX B1 456XXX B9 789XXX
[0069] Table 4
[0070] Object Family Number Home address Landline Number A1 B1 No.1, A Road 456XXX A2 B3 No. 3, B Road 123XXX A3 B5 / / A4 B7 No. 8 H Road / A5 B9 No. 9, C Road 789XXX
[0071] According to Table 4 after Tables 1 to 3 are connected, the home addresses and landline numbers corresponding to different objects can be easily obtained, and missing data can also be determined through Table 4, for example, the home address and landline number corresponding to object A3 are missing. Furthermore, through the connection operation between tables, more comprehensive and specific data can be displayed through the connected table. Users can then filter out the data of interest through query operations, and can also perform other operations on the original Tables 1 to 3 through Table 4, such as adding missing data.
[0072] Generally speaking, the table connection operation generates a new table according to the different characteristics of different tables. For example, Tables 1 to 3 are three different tables. In addition, the multiple tables used for the connection operation can also be the same table. The connection operation for the same table is called a self-connection operation. For example, as shown in Table 5, Table 5 gives the family numbers and home addresses of different objects, where the same family number should correspond to the same home address.
[0073] Table 5
[0074] Object Family Number Home address A1 1 No.1, A Road A2 1 No. 2, A Road B1 2 No. 9, C Road B2 2 No. 9, C Road C1 3 No. 6, D Road C2 3 No. 5, D Road C3 3 No. 4, D Road
[0075] The principle of the self-join operation is to compare the table itself with itself to achieve data screening. For example, in Table 5, since the same family number should correspond to the same home address, the user needs to find the family numbers with different home addresses or wrong home addresses in the data. In the actual operation logic, the process of finding the family numbers with different home addresses in the data is to compare each row of data in the two identical Tables 5. For example, the data row with the object A1 in the first Table 5 is compared with all the data rows in the second Table 5, and the data row with the same family number as the object A1 but different home address in the second Table 5 is found. Similarly, the data row with the object A2 in the first Table 5 is compared with all the data rows in the second Table 5. The final output table result is shown in Table 6, which shows the family numbers with different home addresses.
[0076] Table 6
[0077] Object Family Number Home address A1 1 No.1, A Road A2 1 No. 2, A Road C1 3 No. 6, D Road C2 3 No. 5, D Road C3 3 No. 4, D Road
[0078] However, in actual operation, developers or database users may only focus on one column in Table 6, for example, only the family number, and not on who the object is and which specific wrong home addresses are. In subsequent operations, developers or database users can directly modify the home addresses corresponding to each family number with a numerical value according to the family number screened out by the query, without the need for the two columns of information "object" and "home address" in Table 6. In this case, the generated output table lacks the two columns of data "object" and "home address" compared to Table 6, leaving only the data in the "family number" column. However, it can be seen from Table 6 that if the output table only has the "family number" column, the output result of the "family number" column will have duplicate data, that is, there will be two "1"s and three "3".
[0079] Therefore, it is necessary to optimize the data screening process of the above self-join operation, that is, to optimize the SQL statement corresponding to the database execution process, and convert the SQL statement into an SQL statement that can generate the output results that developers or database users are most concerned about, such as generating a "family number" column that does not contain duplicate data. At this stage, the database can convert the SQL statement entered by the user or tenant into a more efficient equivalent SQL statement through the query optimizer. The execution plan corresponding to the converted SQL statement is better than the execution plan corresponding to the original SQL statement in terms of performance such as execution time and resource usage. Figure 2 A schematic diagram of a system architecture 200 for implementing a process of converting SQL statements in a database is shown.
[0080] The first is the client communication layer for entering SQL statements. The client can be Figure 1The cloud management platform 110 in the embodiment of the present invention is shown in FIG. 1. A user or a tenant using a cloud service can input an SQL statement according to the operation to be performed on the table. However, since the execution efficiency of the SQL statement has a great influence on the efficiency of the database, the user or tenant cannot directly determine the execution efficiency of the input SQL statement and mostly only pays attention to the final output result. Therefore, the database needs to perform semantic analysis and statement optimization on the SQL statement input by the user or tenant.
[0081] The second is the query parsing layer, where the database parses the SQL statements entered by the user or tenant, including syntax and semantic analysis and checking of the SQL statements, as well as object access rights checking. For example, the compiler of the query parsing layer can analyze the SQL statements entered by the user or tenant through the syntax tree and check its syntax. If there is a syntax error, the compiler stops processing and returns an error message; if there is no syntax problem, the compiler converts the SQL statement into a logical query statement that can be analyzed by the query optimizer in the subsequent query optimization layer, and creates a query graph model of the query process based on the logical query statement. For another example, after the syntax analysis is completed, the compiler will perform semantic checks based on the query graph model, such as checking which data types in the statement are consistent with which data types in the database table columns.
[0082] Next is the query optimization layer, in which the database optimizes the SQL statements entered by the user or tenant into more efficient SQL statements through the query optimizer, and generates an execution plan corresponding to the more efficient SQL statement. The execution plan is the specific execution process of the SQL statement. This optimization can be to determine the most efficient execution plan under the current situation according to certain judgment principles, that is, to obtain the best execution plan corresponding to the SQL statement. The execution effect of the best execution plan is equivalent to the execution plan corresponding to the SQL statement entered by the user or tenant, and the performance is more efficient. According to the judgment principle, the query optimization method can be based on the optimization rules or the cost of the execution plan. For example, the query optimization method based on the optimization rules can be to use the built-in rules of the query optimizer as the judgment criteria, and rewrite the SQL statement entered by the user or tenant into the SQL statement contained in the built-in rules, such as the logical transformation based on relational algebra. For another example, the query optimization method based on the cost of the execution plan can be to generate multiple execution plans according to the SQL statement entered by the user or tenant, and estimate the cost of each execution plan, and finally select an execution plan with the lowest cost or the lowest cost.
[0083] The last layer is the query execution layer, where the database executes the best execution plan generated by the query optimizer in the query optimization layer.
[0084] It is worth noting that Figure 2This is only a schematic diagram of a query optimization architecture provided by an embodiment of the present application. The modules shown in the figure do not constitute any limitation. Figure 2 The system architecture may also include a storage layer or a transaction layer. The storage layer is used to provide storage and access to execution plans or table data, and the transaction layer is used to ensure multi-version isolation capabilities between concurrently processed transactions.
[0085] Most of the current query optimization methods focus on the connection operations between different tables, such as nested connection elimination and outer connection elimination. For example, since the connection process of multiple tables may be nested, for non-nested multi-table connections, the connection order between tables can be exchanged, and then the optimal connection order can be found according to the cost of table connection methods in different orders. Nested connection elimination eliminates nested connections by modifying the execution order from left to right in the original SQL statement. For another example, during the outer connection operation, there are restrictions on exchanging the connection order between the outer connection and other connections, so the query optimizer can convert the outer connection into an inner connection.
[0086] However, the above query optimization methods are not applicable to the self-join operation of the table, because the tables used in the self-join operation are the same tables, and even if the join order of these same tables is changed, the output results are the same. Secondly, the above query optimization methods mostly focus on optimizing the execution efficiency of the join process, and cannot solve the problem of duplicate and redundant data mentioned above, and duplicate and redundant data will also indirectly affect the query performance of the database.
[0087] In order to solve the above problems, the present application proposes a method 300 for optimizing table self-join operations, which can achieve query optimization of table self-join operations, reduce redundant data in the table output by the self-join operation, reduce database performance overhead and improve database query efficiency. Figure 3 A schematic block diagram of method 300 is shown, wherein method 300 includes steps 310 to 330. The method can be applied in a cloud environment, for example, a tenant inputs a self-connection-related SQL statement through a client of a cloud management platform, and a cloud database deployed in a cloud server can implement method 300 through a query optimizer, thereby rewriting the SQL statement related to the self-connection operation input by the tenant, and generating an execution plan with higher execution performance.
[0088] Step 310: Obtain a first SQL statement corresponding to a first execution plan, where the first execution plan is used to execute a self-join operation of at least two first tables, and the first SQL statement is used to implement the self-join operation.
[0089] It should be understood that the execution process corresponding to the first SQL statement is the first execution plan. The query optimizer in the database implements the query optimization process by obtaining the first SQL statement entered by the user or tenant on the client. The content of the first SQL statement describes the self-join operation of at least two first tables, and what is presented in the first execution plan is the join operation of at least two identical tables. The content of the presentation of the first execution plan and the first SQL statement will be introduced with examples below, and will not be repeated here.
[0090] Optionally, the scenario of the self-join operation can be to find locally inconsistent data rows through equality comparison of target columns and non-equality comparison of non-target columns as mentioned above, to achieve permutation and combination of data rows through cross joins, to delete duplicate data rows through equality comparison of target columns, or to sort the data rows by size.
[0091] Step 320: rewrite the first SQL statement to generate a second execution plan, where the second execution plan is used to perform a connection operation between a first table and at least one second table, where the second table is determined by screening the data in the first table.
[0092] It should be understood that the query optimizer rewrites the first SQL statement into a second SQL statement, and the execution process corresponding to the second SQL statement is the second execution plan. Presented in the second execution plan is a first table and at least one second table for a join operation, the second table is generated after a data screening operation is performed on the first table, and the second table is different from the first table. In this way, a self-join operation can be converted into a join operation of different tables. The second table, the presentation content of the second execution plan, and the first SQL statement are introduced as examples below, and no further description is given here.
[0093] Optionally, the filter operation can be an aggregation operation in a table join operation, for example, the aggregation operation clause is implemented by Groupby, followed by the aggregation grouping column. The aggregation function can be a count() function for counting within a group, a sum() function for calculating the sum of a column or expression within a group, or a max() function for calculating the maximum value of a column or expression within a group.
[0094] Optionally, the filtering operation can also be a data sorting operation, such as using an Orderby clause to sort the data in the target column to display the result. The sorting function can be row_number(), rank(), dense_rank(), ntile() and other functions.
[0095] Step 330: Execute the second execution plan.
[0096] It should be understood that in step 330, the database executes the second execution plan generated by the query optimizer at the query execution layer. For example, the database generates execution code at the query execution layer according to the final selected second execution plan, and obtains the final result set by executing the generated execution code.
[0097] According to the above method 300, the original self-join operation of multiple identical first tables is converted into a join operation of a first table and one or more second tables with a smaller data volume than the first table, thereby eliminating duplicate and redundant values in the output table, reducing the performance overhead of the database join operation, and improving the query efficiency of the database.
[0098] The implementation process of method 300 will be specifically introduced below according to an embodiment. Figure 4 , Figure 5 and Figure 6 Schematic diagrams are respectively shown before and after the execution plan is rewritten in multiple embodiments given in the present application.
[0099] The application scenarios of self-join may include permutation and combination, deletion of duplicate rows, finding locally inconsistent columns, sorting, etc. For example, in the embodiment of the present application, the query optimization process is first specifically described by taking the content shown in Table 5 as an example.
[0100] The application scenario of the self-join corresponding to Table 5 is to find partially inconsistent columns, where the method of finding partially inconsistent columns in Table 5 is the equality comparison of the target column and the non-equality comparison of the non-target column, that is, the equality comparison of the family number and the non-equality comparison of the home address. If the user only pays attention to the information of the family number, so as to directly modify the values of the home addresses corresponding to different family numbers in a unified manner, the first SQL statement of the comparison process example can be as follows:
[0101]
[0102] Among them, "table5 table5_1, table5_2" means that the two tables used for connection are both table 5, but they are named table 5_1 and table 5_2 for distinction; "select family_number from table5" means that the family number is the data column included in the output result as the family number; "table5_1.family_number=table5_2.family_numberand table5_1.home<>table5_2.home" means the equivalence comparison of family number and the non-equivalence comparison of home address. The table output by the above SQL statement is shown in Table 7. In fact, the output results of Table 7 and Table 6 are the same, but because only the "family number" column is displayed in the first SQL statement, the other two columns are not displayed.
[0103] Optionally, the number of non-target columns may be one as shown in Tables 5 and 6, or may be more than one. For example, in the example shown in Table 5, the non-target columns may also be “object” and “home address”.
[0104] As mentioned above, although Table 7 only shows the "family number" column that users are concerned about, it contains duplicate and redundant data. If there are more values of the home address corresponding to each family number, the number of data rows in Table 7 will also increase, which will affect the execution efficiency of the self-join operation. Moreover, the execution process of the first SQL statement is to compare each row of data in Table 5 with all the data in another Table 5, which has low execution efficiency and long execution time.
[0105] Table 7
[0106] Family Number 1 1 3 3 3
[0107] The execution plan corresponding to the first SQL statement above is as follows Figure 4 As shown in (a), the execution plan indicates that when the database executes the first SQL statement, it first connects the two identical tables 5 to generate Table 7 in the order from right to left and from bottom to top, that is, all data values in Table 5 are compared for equality or non-equality, and then the data in the original Table 5 is filtered through the comparison result of Table 7, that is, "select * from table5" in the first SQL statement.
[0108] However, due to the data duplication in Table 7 and the cumbersome execution process mentioned above, the first SQL statement corresponds to Figure 4 The execution plan (a) is not the best execution plan, so the query optimizer of the database needs to rewrite the first SQL statement.
[0109] Optionally, the rewriting method can be to filter the data of the original table 5 by the method of aggregation operation to generate a table with less data. According to the logical principle of the target column's equivalence comparison and the non-equivalence comparison of the non-target column, the target column's equivalence comparison and the non-equivalence comparison of the non-target column can be regarded as the comparison of the number of non-repeating data values of the non-target column corresponding to each data value of the target column. If the number of values of the non-target column corresponding to a certain value of the target column is greater than 1, it means that the non-target column corresponding to the value has non-equivalence. For example, in Table 5, there are non-equivalence situations in which the data values of the home addresses corresponding to the family numbers 1 and 3 are non-equivalent. This situation can be regarded as the number of data values of the home addresses corresponding to the family numbers 1 and 3 is greater than 1, and the number of data values of the home addresses corresponding to the family number 2 is equal to 1, and it can be concluded that the data of the home addresses corresponding to the family numbers 1 and 3 are non-equivalent.
[0110] The embodiment of the present application shows a rewritten second SQL statement. The principle of the second SQL statement is to regard each data value of the target column as a group, that is, to regard the family numbers 1 to 3 as three groups, each of which includes the data value of the family address corresponding to each family number. The embodiment of the present application shows an example of the second SQL statement:
[0111]
[0112] Among them, the difference between the first SQL statement and the second SQL statement is "group by a having count (distinct home)>1" in the second SQL statement. "Group by a having count (distinct home)>1" means calculating the number of data values of home addresses in the three groups with home numbers 1 to 3 in Table 5 through the counting operation or aggregation operation of the count function. "Distinct" is used to eliminate duplicate values. When the number of data values of the home address in a group is greater than 1, it means that there are different home addresses in the family number corresponding to the group, that is, the home address data has non-equal values, and the database will directly output the family number corresponding to the group. Then the second SQL statement can output the data in Table 8. Compared with Table 7, Table 8 eliminates duplicate and redundant data, saving the number of output rows of the table and the storage space of the database.
[0113] Table 8
[0114] Family Number 1 3
[0115] The execution plan corresponding to the second SQL statement is as follows Figure 4 As shown in (b) in the figure, by analyzing from right to left and from bottom to top, when the database executes the second SQL statement, it first performs the above count function aggregation operation on Table 5, and then filters the original Table 5 according to the result of the focus operation, or in other words, it performs a join operation with the original Table 5 based on the Table 8 generated by the aggregation operation to achieve filtering, and the final output result is shown in Table 8. In the above scenario, the self-join operation is eliminated, and is replaced by an aggregation operation of a single table, and the number of tables in the execution plan is also reduced by one.
[0116] Optionally, "group by a having count(distinct home)>1" in the second SQL statement may also be "group by a having count(distinct home)>=2". In this case, the target number threshold for the number of home address data values in the comparison group changes from "1" to "2".
[0117] Optionally, the rewriting method may also be to convert the sub-link "where family_number, home IN ..." in the first SQL statement into "where exists ...". The example after replacement is as follows:
[0118]
[0119]
[0120] In the scenario of "exist" child link, "select * from table5 table5_1" means that table 5_1 is regarded as the main table, and "select family_number from table5 table5_2" means that table 5_2 is regarded as the child table. The execution plan is as follows Figure 5 As shown in (a), there is only a self-join operation between the main table 5_1 and the sub-table 5_2, thereby reducing the number of tables used in the join operation.
[0121] Optionally, if the original first SQL statement is the SQL statement of the exist sub-link, the query optimizer may modify the first SQL statement in the exist sub-link scenario to the second SQL statement shown below based on the same method as above:
[0122]
[0123] The execution plan corresponding to the modified second SQL statement in the exist sub-link scenario is as follows Figure 5 As shown in (b) of Figure 4 The execution plans of (b) are basically the same, both of which filter the original table 5 through the result obtained by the aggregation operation of the original table 5. In other words, the table 8 obtained by the aggregation operation is connected with the table 5 to achieve filtering, and then the final output result is obtained.
[0124] By modifying the above SQL statements, the amount of data in the sub-table 5_2 is reduced after the aggregation operation. Compared with the original execution plan, the new execution plan generated after the rewrite improves the execution efficiency.
[0125] Optionally, in some embodiments of the present application, the self-connection scenario may also be as follows: Figure 6 The execution plan shown in (a) is shown in Figure 6 As shown in (a), the connection operation 1 and the connection operation 2 are exactly the same self-connection operation, and further, the connection operation 3 is also a self-connection operation. Therefore, Figure 6 The execution plan shown in (a) in the example requires multiple tedious self-join operations, but this application can Figure 6The execution plan shown in (a) is optimized as follows Figure 6 The execution plan shown in (b) in the figure shows that the query optimizer can generate an execution plan with nested conditions. Figure 6 In the execution plan shown in (b), multiple aggregation operations are performed to reduce the amount of table data in each of the multiple connection operations, thereby improving the execution efficiency.
[0126] Through the above query optimization method, the query optimizer of the database can modify the first SQL statement corresponding to the original execution plan into a second SQL statement, and then generate a new execution plan with higher execution efficiency. The execution effect of the new execution plan is equivalent to the execution effect of the original execution plan, and is better than the original execution plan in terms of execution plan latency, execution times, and number of connected tables.
[0127] Combined with the following Figure 7 The database of the embodiment of the present application is introduced. It should be noted that: Figure 7 The database shown can be executed Figure 3 It should be understood that the database described below can execute the method of the aforementioned embodiment of the present application, and in order to avoid unnecessary repetition, repeated descriptions are appropriately omitted when introducing the database of the embodiment of the present application.
[0128] Figure 7 is a schematic diagram of a database in an embodiment of the present application, Figure 7 The database 700 shown includes: an acquisition module 710, a rewriting module 720, and an execution module 730. Optionally, the database 700 may be a cloud database in a cloud environment.
[0129] Specifically, the acquisition module 710 is used to: obtain a first structured query language SQL statement corresponding to a first execution plan, the first execution plan is used to perform a self-join operation of at least two first tables to obtain a target data table for business processing, and the first SQL statement is used to describe the execution process of the self-join operation.
[0130] Specifically, the rewriting module 720 is used to rewrite the first SQL statement to generate a second execution plan, where the second execution plan is used to execute a connection operation between a first table and at least one second table, where the second table is determined by screening the data of the first table.
[0131] Specifically, the execution module 730 is used to: execute the second execution plan to obtain the target data table for business processing.
[0132] The specific functions and beneficial effects of the acquisition module 710, the rewriting module 720 and the execution module 730 are described in the above embodiments, and will not be repeated here for the sake of brevity.
[0133] The above modules can be implemented by software or hardware. For example, the implementation of the rewriting module 720 is described below by taking the rewriting module 720 as an example. Similarly, the implementation of the acquisition module 710 and the execution module 730 can refer to the implementation of the rewriting module 720.
[0134] As an example of a software functional unit, the rewrite module 720 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the rewrite module 720 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with close geographical locations. Among them, usually a region may include multiple AZs.
[0135] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0136] As an example of a hardware functional unit, the rewrite module 720 may include at least one computing device, such as a server, etc. Alternatively, the rewrite module 720 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0137] The multiple computing devices included in the rewrite module 720 can be distributed in the same region or in different regions. The multiple computing devices included in the rewrite module 720 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the rewrite module 720 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices included in the rewrite module 720 can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0138] The present application also provides a computing device 800. Figure 8 As shown, the computing device 800 includes: a bus 802, a processor 804, a memory 806, and a communication interface 808. The processor 804, the memory 806, and the communication interface 808 communicate through the bus 802. The computing device 800 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 800.
[0139] The bus 802 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus 802 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 802 may include a path for transmitting information between various components of the computing device 800 (eg, the memory 806, the processor 804, and the communication interface 808).
[0140] The processor 804 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0141] The memory 806 may include a volatile memory, such as a random access memory (RAM). The processor 904 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0142] The memory 806 stores executable program codes, and the processor 804 executes the executable program codes to respectively implement the functions of the acquisition module 710, the rewriting module 720 and the execution module 730, thereby implementing the above method. That is, the memory 806 stores instructions for executing the above table self-join optimization method.
[0143] The communication interface 808 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 800 and other devices or communication networks.
[0144] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least two computing devices. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0145] like Fig. 9 As shown, the computing device cluster includes at least two computing devices 800. The memory 806 in the multiple computing devices 800 in the computing device cluster may store the same instructions for executing the above table self-join optimization method.
[0146] In some possible implementations, the memory 806 of the plurality of computing devices 800 in the computing device cluster may also respectively store partial instructions for executing the above table self-join optimization method. In other words, a combination of one or more computing devices 800 may jointly execute instructions for executing the above table self-join optimization method.
[0147] It should be noted that the memory 806 in different computing devices 800 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the above database. That is, the instructions stored in the memory 806 in different computing devices 800 can implement the functions of one or more modules among the acquisition module, the rewriting module and the execution module.
[0148] In some possible implementations, multiple computing devices in a computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.10 A possible implementation is shown. Fig.10 As shown, two computing devices 800A and 800B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 806 in the computing device 800A stores instructions for the functions of the acquisition module. At the same time, the memory 806 in the computing device 800B stores instructions for executing the functions of the rewriting module and the execution module.
[0149] It should be understood that Fig.10 The functions of the computing device 800A shown in FIG. 8 may also be completed by multiple computing devices 800. Similarly, the functions of the computing device 800B may also be completed by multiple computing devices 800.
[0150] An embodiment of the present application also provides a chip, which includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface to execute the above-mentioned table self-connection optimization method.
[0151] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the above table self-join optimization method.
[0152] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned table self-connection optimization method.
[0153] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0154] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.
[0155] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0156] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0157] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0158] In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0159] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0160] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for optimizing table self-join, characterized in that: The method is applied to a database, comprising: The database obtains a first structured query language SQL statement corresponding to a first execution plan, wherein the first execution plan is used to perform a self-join operation of at least two first tables to obtain a target data table for business processing, and the first SQL statement is used to describe an execution process of the self-join operation; The database rewrites the first SQL statement to generate a second execution plan, where the second execution plan is used to execute a connection operation between the first table and at least one second table, where the second table is determined by screening data in the first table; The database executes the second execution plan to obtain the target data table for business processing.
2. The method according to claim 1, characterized in that The self-join operation includes performing an equality comparison on the data of the target columns of the at least two first tables and a non-equality comparison on the data of the non-target columns, wherein the target column is one or more data columns in the first table to which the target data table belongs, and the non-target column is one or more data columns in the first table except the target column.
3. The method according to claim 1 or 2, characterized in that: The second table is determined after performing an aggregation operation on the first table, where the aggregation operation is used to sort and filter the data of the target column in the first table by using an aggregation function.
4. The method according to claim 3, characterized in that The aggregation operation includes using the aggregation function to count the number of non-repeating data values in the non-target column corresponding to each data value in the target column, and filtering out the target data value in the target column, wherein the number of non-repeating data values in the non-target column corresponding to the target data value is greater than or equal to a target number threshold.
5. The method according to any one of claims 1 to 4, characterized in that: The database rewrites the first SQL statement to generate a second execution plan, including: The database rewrites the first SQL statement into a second SQL statement, where the second SQL statement is used to describe the execution process of the connection operation between the first table and at least one second table; The database generates the second execution plan according to the second SQL statement.
6. A database, characterized in that: include: an acquisition module, configured to acquire a first structured query language SQL statement corresponding to a first execution plan, wherein the first execution plan is used to perform a self-join operation of at least two first tables to obtain a target data table for business processing, and the first SQL statement is used to describe an execution process of the self-join operation; a rewriting module, used for rewriting the first SQL statement to generate a second execution plan, wherein the second execution plan is used for executing a connection operation between the first table and at least one second table, wherein the second table is determined by screening the data of the first table; An execution module is used to execute the second execution plan and obtain the target data table for business processing.
7. The database according to claim 6, characterized in that The self-join operation includes performing an equality comparison on the data of the target columns of the at least two first tables and a non-equality comparison on the data of the non-target columns, wherein the target column is one or more data columns in the first table to which the target data table belongs, and the non-target column is one or more data columns in the first table except the target column.
8. The database according to claim 6 or 7, characterized in that: The second table is determined after performing an aggregation operation on the first table, where the aggregation operation is used to sort and filter the data of the target column in the first table by using an aggregation function.
9. The database according to claim 8, characterized in that The aggregation operation includes using the aggregation function to count the number of non-repeating data values in the non-target column corresponding to each data value in the target column, and filtering out the target data value in the target column, wherein the number of non-repeating data values in the non-target column corresponding to the target data value is greater than or equal to a target number threshold.
10. The database according to any one of claims 6 to 9, characterized in that: The rewriting module is specifically used to rewrite the first SQL statement into a second SQL statement, where the second SQL statement is used to describe the execution process of the connection operation of the first table and at least one second table, and generate the second execution plan according to the second SQL statement.
11. A computing device, characterized in that: The computer comprises a processor and a memory, wherein the processor is configured to execute instructions stored in the memory so that the computing device executes the method according to any one of claims 1 to 5.
12. A computing device cluster, characterized in that: include: at least two computing devices, each computing device comprising a processor and a memory; The processors of the at least two computing devices are configured to execute instructions stored in the memories of the at least two computing devices, so that the computing device cluster executes the method according to any one of claims 1 to 5.
13. A computer program product comprising instructions, characterized in that When the instruction is executed by a computing device, the computing device executes the method according to any one of claims 1 to 5; Alternatively, when the instruction is executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 5.
14. A computer readable medium, characterized in that comprising a computer program which, when executed on a computing device, causes the computer to perform the method as claimed in any one of claims 1 to 5; Alternatively, when the computer program is executed on a computing device cluster, the computer is enabled to execute the method as claimed in any one of claims 1 to 5.
