Complexity analysis method and device, equipment, storage medium and program product
By analyzing the static and dynamic complexity of structured query statements in the target business application, the problem of inaccurate cloud database selection was solved, and accurate cloud database selection was achieved, ensuring the normal operation of business applications after migration to the cloud.
Patent Information
- Application Number
- CN202511667584.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-14
- Publication Date
- 2026-01-23
AI Technical Summary
During the cloud migration process, how to select a suitable cloud database to ensure the normal operation of business applications is a challenge. Existing technologies lack effective methods to determine the complexity of structured query statements, leading to inaccurate cloud database selection.
By obtaining the syntax parse tree and execution plan of the structured query statements in the target business application, and combining them with the business table metadata, the static and dynamic complexity of each statement is determined, and then the complexity results are analyzed to select a suitable cloud database.
This improves the accuracy of cloud database selection and ensures the normal operation of business applications after migration to the cloud.
Smart Images

Figure CN121387690A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a complexity analysis method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] Application migration to the cloud refers to the process by which users migrate their business applications to a cloud service environment. Since business applications rely on databases to run, their original databases also need to be migrated to the cloud databases provided by the cloud service provider to ensure the normal operation of the business after the migration.
[0003] However, selecting a suitable cloud database depends on the complexity of the structured query statements of the business application. Therefore, there is an urgent need for a method to determine the complexity of the structured query statements of the business application in order to improve the accuracy of the selected cloud database. Summary of the Invention
[0004] Therefore, it is necessary to provide a complexity analysis method, apparatus, computer device, computer-readable storage medium, and computer program product that can determine the complexity of structured query statements in business applications, addressing the aforementioned technical problems.
[0005] Firstly, this application provides a complexity analysis method, including:
[0006] Obtain each structured query statement in the target business application, and determine the syntax parse tree and execution plan of each structured query statement;
[0007] The static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, and the dynamic complexity of each structured query statement is determined based on the execution plan.
[0008] The complexity analysis results for each structured query statement are determined based on its static and dynamic complexity.
[0009] In one embodiment, the static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, including: determining the target fields and target tables associated with each structured query statement based on the syntax parse tree; and determining the static complexity of each structured query statement based on the target fields and target tables based on the business table metadata.
[0010] In one embodiment, the static complexity of each structured query statement is determined based on the business table metadata, the target field, and the target table. This includes: determining the field type of the target field based on the business table metadata, and determining the field complexity of the target field based on the field type; determining the complexity of the fields included in the target table based on the business table metadata, and determining the table complexity of the target table based on the complexity of the fields included in the target table; and determining the static complexity of each structured query statement based on the field complexity and the table complexity.
[0011] In one embodiment, determining the static complexity of each structured query statement based on field complexity and table complexity includes: obtaining the complexity of the special statement in any structured query statement when there is a special statement in any structured query statement; and determining the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0012] In one embodiment, determining the dynamic complexity of each structured query statement based on the execution plan includes: determining the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution based on the execution plan; and determining the dynamic complexity of each structured query statement based on the amount of execution data and CPU consumption.
[0013] In one embodiment, the method further includes: sorting the complexity analysis results of each structured query statement in the target business application to obtain a sorting result; determining the type of cloud database of the target business application based on the sorting result; and using the cloud database to replace the original database of the target business application after the target business application is migrated to a cloud service environment.
[0014] Secondly, this application also provides a complexity analysis apparatus, comprising:
[0015] The acquisition module is used to acquire each structured query statement in the target business application and determine the syntax parse tree and execution plan of each structured query statement.
[0016] The first determination module is used to determine the static complexity of each structured query statement based on the syntax parse tree and the business table metadata of the target business application, and to determine the dynamic complexity of each structured query statement based on the execution plan.
[0017] The second determining module is used to determine the complexity analysis results of each structured query statement based on the static complexity and dynamic complexity of each structured query statement.
[0018] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in any of the embodiments of the first aspect above.
[0019] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any of the embodiments of the first aspect above.
[0020] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in any of the embodiments of the first aspect above.
[0021] The aforementioned complexity analysis methods, apparatus, computer equipment, computer-readable storage media, and computer program products first acquire each structured query statement in the target business application and determine the syntax parse tree and execution plan of each structured query statement. Then, based on the syntax parse tree and the business table metadata of the target business application, they determine the static complexity of each structured query statement and, based on the execution plan, determine the dynamic complexity of each structured query statement. Finally, they determine the complexity analysis result of each structured query statement based on its static and dynamic complexity. The complexity analysis method provided in this application determines the static and dynamic complexity of each structured query statement based on its syntax parse tree and execution plan in the target business application, and then determines the complexity analysis result based on these two factors. Since a suitable cloud database can be selected based on the complexity analysis results of each structured query statement, the accuracy of the selected cloud database is improved. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart illustrating a complexity analysis method in one embodiment;
[0024] Figure 2 This is a schematic diagram illustrating the structure of a query statement in one embodiment;
[0025] Figure 3 This is a schematic diagram of a syntax parse tree in one embodiment;
[0026] Figure 4 This is a flowchart illustrating a method for determining the static complexity of each structured query statement in one embodiment.
[0027] Figure 5 This is a flowchart illustrating a method for determining the static complexity of each structured query statement in another embodiment.
[0028] Figure 6 This is a flowchart illustrating a method for determining the static complexity of each structured query statement based on field complexity and table complexity in one embodiment.
[0029] Figure 7 This is a schematic diagram of a syntax parse tree in another embodiment;
[0030] Figure 8 This is a schematic diagram illustrating the calculation of static complexity in one embodiment;
[0031] Figure 9 This is a schematic diagram illustrating the calculation of static complexity in another embodiment;
[0032] Figure 10 This is a flowchart illustrating a method for determining the dynamic complexity of each structured query statement based on an execution plan in one embodiment.
[0033] Figure 11 This is a schematic diagram of the execution plan in one embodiment;
[0034] Figure 12 This is a flowchart illustrating a method for determining the type of cloud database for a target business application in one embodiment.
[0035] Figure 13 This is a flowchart illustrating the complexity analysis method in another embodiment;
[0036] Figure 14 This is a structural block diagram of a complexity analysis device in one embodiment;
[0037] Figure 15 This is an internal structural diagram of a computer device in one embodiment;
[0038] Figure 16 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0040] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0041] Application migration to the cloud refers to the process by which users migrate their business applications to a cloud service environment. Since business applications rely on databases to run, their original databases also need to be migrated to the cloud databases provided by the cloud service provider to ensure the normal operation of the business after the migration.
[0042] However, selecting a suitable cloud database depends on the complexity of the structured query statements of the business application. Therefore, there is an urgent need for a method to determine the complexity of the structured query statements of the business application in order to improve the accuracy of the selected cloud database.
[0043] In view of this, this application provides a complexity analysis method. Based on the syntax parsing tree and execution plan of each structured query statement in the target business application, the static and dynamic complexity of each structured query statement are determined. Then, the complexity analysis result of each structured query statement is determined based on the static and dynamic complexity of each structured query statement. Since a suitable cloud database can be selected based on the complexity analysis result of each structured query statement, the accuracy of the selected cloud database is improved.
[0044] The complexity analysis method provided in this application can be executed by a computer device, which can be a terminal or a server.
[0045] In one exemplary embodiment, such as Figure 1 As shown, a complexity analysis method is provided, which includes the following steps:
[0046] Step 101: Obtain each structured query statement in the target business application and determine the syntax parse tree and execution plan of each structured query statement.
[0047] Optionally, business applications refer to the software systems used to conduct business. Examples include e-commerce order systems, bank accounting systems, and hospital registration systems. The target business application is the one that requires determining the complexity analysis results of structured query statements.
[0048] Structured Query Language (SQL) is a standardized programming language used to manage relational databases and serves as the core medium for interaction between business applications and the database. For example, the various structured query statements in a target business application refer to the structured query statements executed by the target business application.
[0049] A parse tree is a structured representation of a structured query statement after syntactic analysis. For example, a parse tree breaks down a structured query statement into syntactic units according to SQL syntax rules, such as the keyword SELECT, table names, field names, and conditional expressions. It then displays the hierarchical relationships between these units in a tree structure; for example, a "query statement" contains child nodes such as "query fields," "query table," and "query conditions."
[0050] An execution plan is essentially an execution specification for a structured query statement. For example, an execution plan can be used to indicate how much data a structured query statement needs to scan, such as whether it is a full table scan or an index scan; the join order when multiple tables are joined; which indexes are used; whether there are sorting / aggregation operations; the estimated execution time; and the CPU / memory resources consumed.
[0051] In some exemplary embodiments, the computer device may first obtain various structured query statements from the target business application.
[0052] Specifically, taking Oracle as an example, computer devices can connect to the database using a connector implemented with the JDBC specification, and then query the structured query statements executed by the business application in the Oracle system table Global Dynamic Performance View (GV$SQL).
[0053] Computer devices can also obtain various structured query statements in the target business application based on application programming interfaces or database connection middleware. For example, if the target business application interacts with the database through a unified middleware or a custom data access layer API, the computer device can deploy log interception or data forwarding mechanisms in the middleware or API layer to capture all structured query statements passing through that layer in real time.
[0054] Computer devices can also obtain various structured query statements in target business applications based on the database's native audit log function. For example, by configuring the database's audit log, all SQL operations that the target business application interacts with the database can be recorded. The computer device can periodically read the log file or subscribe to the log stream in real time to extract the structured query statements.
[0055] Furthermore, after acquiring the various structured query statements in the target business application, the computer device can determine the syntax parse tree of each structured query statement.
[0056] Specifically, computer devices can use the open-source tool antlr4 to parse structured query statements and generate syntax trees. For example, ... Figure 2 and Figure 3 As shown, Figure 2 An example structured query statement is shown. Figure 3 It shows Figure 2 The syntax parse tree of the structured query statement in the database.
[0057] Furthermore, after obtaining the various structured query statements in the target business application, the computer device can also determine the execution plan for each structured query statement.
[0058] Specifically, the computer equipment can execute `explain plan for` on each structured query statement in Oracle at the source end to obtain the execution plan for each structured query statement. `explain plan for` is a special Oracle command that can simulate the execution of structured queries and generate an execution plan, but it does not actually execute the structured queries.
[0059] Step 102: Determine the static complexity of each structured query statement based on the syntax parse tree and the business table metadata of the target business application, and determine the dynamic complexity of each structured query statement based on the execution plan.
[0060] Business table metadata for a target business application refers to the structured descriptive information of database tables within that application. Business table metadata can include table structure and table data volume.
[0061] Static complexity can be used to reflect the syntactic complexity of a structured query statement itself. It is independent of the amount of data and the execution environment, and is determined solely by the design of the structured query statement and the table structure.
[0062] Dynamic complexity can be used to reflect the resource consumption and execution difficulty during the execution of a structured query statement.
[0063] In some exemplary embodiments, after determining the syntax parse tree and execution plan of each structured query statement, the computer device can determine the static complexity of each structured query statement based on the syntax parse tree and the business table metadata of the target business application.
[0064] Specifically, computer devices can input the syntax parse tree and the business table metadata of the target business application into a pre-trained static complexity determination model to obtain the static complexity of each structured query statement output by the static complexity determination model.
[0065] Furthermore, computer equipment can also determine the dynamic complexity of each structured query statement based on the execution plan.
[0066] Specifically, the computer device inputs the execution plan into a pre-trained dynamic complexity determination model to obtain the dynamic complexity of each structured query statement output by the dynamic complexity determination model.
[0067] Step 103: Determine the complexity analysis results of each structured query statement based on its static complexity and dynamic complexity.
[0068] Complexity analysis results can be used to indicate the overall complexity of a structured query statement.
[0069] In some exemplary embodiments, after determining the static complexity and dynamic complexity of each structured query statement, the computer device can determine the complexity analysis result of each structured query statement based on the static complexity and dynamic complexity of each structured query statement.
[0070] Specifically, computer equipment can sum the static complexity and dynamic complexity of each structured query statement to determine the complexity analysis results of each structured query statement.
[0071] The aforementioned complexity analysis method first obtains each structured query statement in the target business application and determines the syntax parse tree and execution plan of each structured query statement. Then, based on the syntax parse tree and the business table metadata of the target business application, it determines the static complexity of each structured query statement and the dynamic complexity of each structured query statement based on the execution plan. Finally, it determines the complexity analysis result of each structured query statement based on its static and dynamic complexity. The complexity analysis method provided in this application determines the static and dynamic complexity of each structured query statement based on its syntax parse tree and execution plan in the target business application, and then determines the complexity analysis result based on these two factors. Since a suitable cloud database can be selected based on the complexity analysis results of each structured query statement, the accuracy of the selected cloud database is improved.
[0072] In one exemplary embodiment, such as Figure 4 As shown, the static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, including the following steps:
[0073] Step 401: Determine the target fields and target tables associated with each structured query statement based on the syntax parse tree.
[0074] In some exemplary embodiments, a computer device can determine the fields and tables involved in each structured query statement based on the syntax parsing tree of each structured query statement, and determine these fields and tables as target fields and target tables, respectively.
[0075] For example, if the structured query is `select cola, colb from tab_t where colc=2`, then the target fields of this structured query are `cola` and `colb`, and the target table is `tab_t`.
[0076] Step 402: Based on the business table metadata, determine the static complexity of each structured query statement according to the target fields and the target table.
[0077] In some exemplary embodiments, after determining the target fields and target tables associated with each structured query statement based on the syntax parse tree, the computer device can determine the static complexity of each structured query statement based on the business table metadata, according to the target fields and target tables.
[0078] Specifically, computer equipment can input business table metadata, target fields, and target tables into a pre-trained static complexity determination model to obtain the static complexity of each structured query statement output by the static complexity determination model.
[0079] In one exemplary embodiment, such as Figure 5 As shown, based on the business table metadata, the static complexity of each structured query statement is determined according to the target fields and the target table, including the following steps:
[0080] Step 501: Determine the field type of the target field based on the business table metadata, and determine the field complexity of the target field based on the field type.
[0081] In some exemplary embodiments, a computer device may determine the field type of a target field based on business table metadata, and determine the field complexity of the target field based on the field type.
[0082] Specifically, the computer can determine the field type corresponding to the target field in the business table metadata, and use the data type-complexity mapping relationship list to determine the field complexity of the target field based on the field type. The data type-complexity mapping relationship list is shown in Table 1.
[0083] Table 1
[0084]
[0085] Step 502: Determine the complexity of the fields included in the target table based on the business table metadata, and determine the table complexity of the target table based on the complexity of the fields included in the target table.
[0086] In some exemplary embodiments, a computer device may determine the complexity of the fields included in a target table based on business table metadata.
[0087] Specifically, computer equipment can determine the field types corresponding to the fields included in the target table from the business table metadata, and then determine the complexity of the fields included in the target table based on the field types.
[0088] Furthermore, after determining the field complexity of the fields included in the target table based on the business table metadata, the computer equipment can determine the table complexity of the target table based on the field complexity of the fields included in the target table.
[0089] Specifically, computer equipment can sum the field complexities of the fields included in the target table to determine the table complexity. For example, the table complexity of the target table can be expressed as... Where N is the total number of fields in the target table, and c is the field complexity of each field in the target table.
[0090] Step 503: Determine the static complexity of each structured query statement based on field complexity and table complexity.
[0091] In some exemplary embodiments, after determining the field type of the target field based on the business table metadata, and determining the field complexity of the target field based on the field type, determining the complexity of the fields included in the target table based on the business table metadata, and determining the table complexity of the target table based on the complexity of the fields included in the target table, the computer device can determine the static complexity of each structured query statement based on the field complexity and the table complexity.
[0092] Specifically, computer equipment can sum the field complexity and table complexity of each structured query statement to determine the static complexity of each structured query statement.
[0093] In one exemplary embodiment, such as Figure 6 As shown, determining the static complexity of each structured query statement based on field complexity and table complexity includes the following steps:
[0094] Step 601: If any structured query statement in each structured query statement contains a special statement, obtain the complexity of the special statement in the structured query statement.
[0095] Optionally, this special statement can be a conditional statement. For example, in the structured query statement `select cola, colb from tab_t where colc=2`, the special statement is `where colc=2`.
[0096] In some exemplary embodiments, after determining the field complexity and table complexity of each structured query statement, the computer device can determine whether there are special statements in the structured query statement, and if so, determine the complexity of the special statements in the structured query statement.
[0097] Specifically, the complexity of a special statement is the sum of the complexities of its included AND or OR conditions, that is... , where Expr is the complexity of each AND or OR condition.
[0098] The complexity of AND or OR conditions, Expr, is equal to the complexity of the left expression plus the complexity of the operator plus the complexity of the right expression.
[0099] The operator complexity can be determined using an operator-complexity mapping list, which is shown in Table 2.
[0100] Table 2
[0101]
[0102] Furthermore, since most special statements contain constants of various data types, the complexity of these constants can be determined using a data type constant-complexity mapping list, as shown in Table 3.
[0103] Table 3
[0104]
[0105] Step 602: Determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0106] In some exemplary embodiments, after determining the complexity of the special statements in a structured query statement, the computer device can determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0107] Specifically, computer equipment can sum the field complexity, table complexity, and special statement complexity of a structured query statement to determine the static complexity of the structured query statement.
[0108] For example, the syntax parse tree of the structured query statement `select cola, colb from tab_t where colc=2` can be shown as follows: Figure 7 As shown, assuming the cola, colb, and colc fields of the tab_t table are of type varchar2, SMALLINT, and CLOB respectively, the static complexity of this structured query statement is field complexity (32G+2G) + table complexity (32G+2G+64G) + complexity of special statements (64G+1G+1G) = 198G.
[0109] In an optional embodiment of this application, the static complexity of determining a structured query statement will be explained below using the structured query statement select cola, colb from tab_t, (select col1, col2 from tab_g where col3=5 and col1 in (2.1, 3.2, 4.4)) t1 where colc=2 as an example.
[0110] Assume the table `tab_t` has four fields: `cola`, `colb`, `colc`, and `cold`, with types `varchar2`, `SMALLINT`, `INTEGER`, and `CLOB` respectively. The table `tab_g` has five fields: `col1`, `col2`, `col3`, `col4`, and `col5`, with types `REAL`, `DATE`, `INTEGER`, `TIMESTAMP`, and `BLOB` respectively. Since this is a depth-wise recursive traversal of the parse tree, we first calculate the complexity of `(select col1, col2 from tab_g where col3=5 and col1 in (2.1, 3.2, 4.4)) t1`, which can be seen as follows: Figure 8 As shown. Then, the recursion returns to the previous level to calculate the outer complexity and determine the static complexity of the structured query statement, as shown below. Figure 9 As shown.
[0111] In one exemplary embodiment, such as Figure 10 As shown, determining the dynamic complexity of each structured query statement based on the execution plan includes the following steps:
[0112] Step 1001: Based on the execution plan, determine the amount of execution data and CPU consumption involved in the table operations of each structured query statement during the execution process.
[0113] Optionally, table operations can include join queries, aggregate queries, and other operations that require database computing resources during execution. For example, join queries can be JOIN and UNION; aggregate queries can be SUM, MIN, MAX, and AVG; and other operations can be GROUP BY, CONT BY, and ORDER BY.
[0114] In some exemplary embodiments, the computer device can determine the amount of execution data and CPU consumption involved in the execution of table operations for each structured query statement based on the execution plan.
[0115] Specifically, computer devices can directly obtain the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution from the execution plan.
[0116] For example, the structured query statement is `select ta.id, ta.name, tb.job from tab_a ta jointab_b tb on ta.id=tb.id order by tb.id desc`. Assume that the table structure and metadata information of the two tables tab_a and tab_b are shown in Table 4 and Table 5, respectively. Table 4 corresponds to tab_a and Table 5 corresponds to tab_b. Tab_a has 60 million rows of data, and tab_b has 1 million rows of data.
[0117] Table 4
[0118]
[0119] Table 5
[0120]
[0121] Define the complexity involved in 1 million rows of data as 1G. Since joining the two tables tab_a and tab_b is a Cartesian product calculation, M×N=60 million×1 million=600,000, then the dynamic complexity =600,000 / 1 million = 6,000G.
[0122] Furthermore, the `ORDER BY` clause sorts the entire `tab_b` table by the `id` field, involving 1 million records. Therefore, the dynamic complexity is 1 million / 1 million = 1GB. Additionally, since the executed SQL consumes CPU, this information can be obtained from the execution plan, which can be viewed as follows: Figure 11 As shown.
[0123] Step 1002: Determine the dynamic complexity of each structured query statement based on the amount of data executed and the CPU consumption.
[0124] In some exemplary embodiments, after determining the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution based on the execution plan, the computer device can determine the dynamic complexity of each structured query statement based on the amount of execution data and CPU consumption.
[0125] Specifically, computer equipment can sum the amount of data executed and the CPU consumption of each structured query statement to obtain the dynamic complexity of the structured query statement.
[0126] In one exemplary embodiment, such as Figure 12 As shown, after determining the complexity analysis results of each structured query statement in the target business application, the method further includes the following steps:
[0127] Step 1201: Sort the complexity analysis results of each structured query statement in the target business application to obtain the sorting results.
[0128] In some exemplary embodiments, after determining the complexity analysis results of each structured query statement in the target business application, the computer device can sort the complexity analysis results of each structured query statement in the target business application to obtain a sorting result.
[0129] Specifically, the computer equipment can determine the complexity of each structured query statement based on the complexity analysis results of each structured query statement in the target business application, and then sort the structured query statements in descending order of complexity to obtain the sorting results.
[0130] Step 1202: Determine the type of cloud database for the target business application based on the sorting results.
[0131] Among them, the cloud database is used to replace the original database of the target business application after the target business application is migrated to the cloud service environment.
[0132] In some exemplary embodiments, a computer device may determine the type of cloud database for a target business application based on the sorting results.
[0133] Specifically, if the computer equipment determines, based on the sorting results, that the target business application contains a large number of highly complex structured query statements, then the cloud database type of the target business application can be determined to be OLAP; if the sorting results determine, based on the sorting results, that the target business application contains a small number of highly complex structured query statements, then the cloud database type of the target business application can be determined to be OLTP.
[0134] In one exemplary embodiment, such as Figure 13 As shown, another complexity analysis method is provided, which includes the following steps:
[0135] Step 1301: Obtain each structured query statement in the target business application, and determine the syntax parse tree and execution plan of each structured query statement; determine the target fields and target tables related to each structured query statement based on the syntax parse tree;
[0136] Step 1302: Determine the field type of the target field based on the business table metadata, and determine the field complexity of the target field based on the field type; determine the complexity of the fields included in the target table based on the business table metadata, and determine the table complexity of the target table based on the complexity of the fields included in the target table.
[0137] Step 1303: If any structured query statement in each structured query statement contains a special statement, obtain the complexity of the special statement in the structured query statement; determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0138] Step 1304: Based on the execution plan, determine the amount of data and CPU consumption involved in the table operations of each structured query statement during execution; determine the dynamic complexity of each structured query statement based on the amount of data and CPU consumption.
[0139] Step 1305: Determine the complexity analysis results of each structured query statement based on its static complexity and dynamic complexity; sort the complexity analysis results of each structured query statement in the target business application to obtain the sorting results.
[0140] Step 1306: Determine the type of cloud database for the target business application based on the sorting results; the cloud database is used to replace the original database of the target business application after it is migrated to the cloud service environment.
[0141] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0142] Based on the same inventive concept, this application also provides a complexity analysis apparatus for implementing the complexity analysis method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more complexity analysis apparatus embodiments provided below can be found in the limitations of the complexity analysis method described above, and will not be repeated here.
[0143] In one exemplary embodiment, such as Figure 14 As shown, a complexity analysis device 1400 is provided, including: an acquisition module 1401, a first determination module 1401, and a second determination module 1402, wherein:
[0144] The acquisition module 1401 is used to acquire each structured query statement in the target business application and determine the syntax parse tree and execution plan of each structured query statement.
[0145] The first determining module 1402 is used to determine the static complexity of each structured query statement based on the syntax parsing tree and the business table metadata of the target business application, and to determine the dynamic complexity of each structured query statement based on the execution plan.
[0146] The second determining module 1403 is used to determine the complexity analysis results of each structured query statement based on the static complexity and dynamic complexity of each structured query statement.
[0147] In one embodiment, the first determining module 1402 is specifically used to determine the target fields and target tables associated with each structured query statement based on the syntax parse tree; and to determine the static complexity of each structured query statement based on the business table metadata, according to the target fields and target tables.
[0148] In one embodiment, the first determining module 1402 is specifically used to determine the field type of the target field based on the business table metadata, and determine the field complexity of the target field based on the field type; determine the complexity of the fields included in the target table based on the business table metadata, and determine the table complexity of the target table based on the complexity of the fields included in the target table; and determine the static complexity of each structured query statement based on the field complexity and the table complexity.
[0149] In one embodiment, the first determining module 1402 is specifically used to obtain the complexity of the special statement in any structured query statement when there is a special statement in any structured query statement; and to determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0150] In one embodiment, the first determining module 1402 is specifically used to determine, based on the execution plan, the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution; and to determine the dynamic complexity of each structured query statement based on the amount of execution data and CPU consumption.
[0151] In one embodiment, the second determining module 1403 is further configured to sort the complexity analysis results of each structured query statement in the target business application to obtain a sorting result; determine the type of cloud database of the target business application based on the sorting result; the cloud database is used to replace the original database of the target business application after the target business application is migrated to the cloud service environment.
[0152] Each module in the aforementioned complexity analysis device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0153] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 15As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a complexity analysis method.
[0154] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 16 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a complexity analysis method.
[0155] Those skilled in the art will understand that Figure 15 and 16 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0156] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0157] Obtain each structured query statement in the target business application, and determine the syntax parse tree and execution plan of each structured query statement;
[0158] The static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, and the dynamic complexity of each structured query statement is determined based on the execution plan.
[0159] The complexity analysis results for each structured query statement are determined based on its static and dynamic complexity.
[0160] In one embodiment, when the processor executes the computer program, it also performs the following steps: determining the target fields and target tables associated with each structured query statement based on the syntax parse tree; and determining the static complexity of each structured query statement based on the target fields and target tables according to the business table metadata.
[0161] In one embodiment, when the processor executes the computer program, it further performs the following steps: determining the field type of the target field based on the business table metadata, and determining the field complexity of the target field based on the field type; determining the complexity of the fields included in the target table based on the business table metadata, and determining the table complexity of the target table based on the complexity of the fields included in the target table; and determining the static complexity of each structured query statement based on the field complexity and the table complexity.
[0162] In one embodiment, when the processor executes the computer program, it further performs the following steps: if any structured query statement in each structured query statement has a special statement, obtain the complexity of the special statement of the structured query statement; determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0163] In one embodiment, when the processor executes the computer program, it further performs the following steps: based on the execution plan, determining the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution; and determining the dynamic complexity of each structured query statement based on the amount of execution data and CPU consumption.
[0164] In one embodiment, when the processor executes the computer program, it further performs the following steps: sorting the complexity analysis results of each structured query statement in the target business application to obtain a sorting result; determining the type of cloud database for the target business application based on the sorting result; and using the cloud database to replace the original database of the target business application after the target business application is migrated to a cloud service environment.
[0165] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0166] Obtain each structured query statement in the target business application, and determine the syntax parse tree and execution plan of each structured query statement;
[0167] The static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, and the dynamic complexity of each structured query statement is determined based on the execution plan.
[0168] The complexity analysis results for each structured query statement are determined based on its static and dynamic complexity.
[0169] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the target fields and target tables associated with each structured query statement based on the syntax parse tree; and determining the static complexity of each structured query statement based on the target fields and target tables according to the business table metadata.
[0170] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the field type of the target field based on the business table metadata, and determining the field complexity of the target field based on the field type; determining the complexity of the fields included in the target table based on the business table metadata, and determining the table complexity of the target table based on the complexity of the fields included in the target table; and determining the static complexity of each structured query statement based on the field complexity and the table complexity.
[0171] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: if any structured query statement in each structured query statement has a special statement, obtain the complexity of the special statement of the structured query statement; determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0172] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: based on the execution plan, determining the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution; and determining the dynamic complexity of each structured query statement based on the amount of execution data and CPU consumption.
[0173] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: sorting the complexity analysis results of each structured query statement in the target business application to obtain a sorting result; determining the type of cloud database for the target business application based on the sorting result; and using the cloud database to replace the original database of the target business application after the target business application is migrated to a cloud service environment.
[0174] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0175] Obtain each structured query statement in the target business application, and determine the syntax parse tree and execution plan of each structured query statement;
[0176] The static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, and the dynamic complexity of each structured query statement is determined based on the execution plan.
[0177] The complexity analysis results for each structured query statement are determined based on its static and dynamic complexity.
[0178] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the target fields and target tables associated with each structured query statement based on the syntax parse tree; and determining the static complexity of each structured query statement based on the target fields and target tables according to the business table metadata.
[0179] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the field type of the target field based on the business table metadata, and determining the field complexity of the target field based on the field type; determining the complexity of the fields included in the target table based on the business table metadata, and determining the table complexity of the target table based on the complexity of the fields included in the target table; and determining the static complexity of each structured query statement based on the field complexity and the table complexity.
[0180] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: if any structured query statement in each structured query statement has a special statement, obtain the complexity of the special statement of the structured query statement; determine the static complexity of the structured query statement based on the field complexity, table complexity, and special statement complexity of the structured query statement.
[0181] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: based on the execution plan, determining the amount of execution data and CPU consumption involved in the table operations of each structured query statement during execution; and determining the dynamic complexity of each structured query statement based on the amount of execution data and CPU consumption.
[0182] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: sorting the complexity analysis results of each structured query statement in the target business application to obtain a sorting result; determining the type of cloud database for the target business application based on the sorting result; and using the cloud database to replace the original database of the target business application after the target business application is migrated to a cloud service environment.
[0183] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0184] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 application.
[0185] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A complexity analysis method, characterized in that, The method includes: Obtain each structured query statement in the target business application, and determine the syntax parse tree and execution plan of each structured query statement; The static complexity of each structured query statement is determined based on the syntax parse tree and the business table metadata of the target business application, and the dynamic complexity of each structured query statement is determined based on the execution plan. The complexity analysis results of each structured query statement are determined based on the static complexity and dynamic complexity of each structured query statement.
2. The method according to claim 1, characterized in that, The determination of the static complexity of each structured query statement based on the syntax parse tree and the business table metadata of the target business application includes: The target fields and target tables associated with each of the structured query statements are determined based on the syntax parse tree. Based on the business table metadata, the static complexity of each structured query statement is determined according to the target field and the target table.
3. The method according to claim 2, characterized in that, The step of determining the static complexity of each structured query statement based on the business table metadata, the target field, and the target table includes: The field type of the target field is determined based on the business table metadata, and the field complexity of the target field is determined based on the field type; The complexity of the fields included in the target table is determined based on the metadata of the business table, and the table complexity of the target table is determined based on the complexity of the fields included in the target table. The static complexity of each structured query statement is determined based on the field complexity and the table complexity.
4. The method according to claim 3, characterized in that, Determining the static complexity of each structured query statement based on the field complexity and the table complexity includes: If any of the structured query statements contains a special statement, obtain the complexity of the special statement in the structured query statement. The static complexity of the structured query statement is determined based on the field complexity, table complexity, and special statement complexity of the structured query statement.
5. The method according to any one of claims 1 to 4, characterized in that, The determination of the dynamic complexity of each structured query statement based on the execution plan includes: Based on the execution plan, determine the amount of execution data and CPU consumption involved in the table operations of each structured query statement during the execution process; The dynamic complexity of each structured query statement is determined based on the amount of data executed and the CPU consumption.
6. The method according to claim 1, characterized in that, The method further includes: The complexity analysis results of each structured query statement in the target business application are sorted to obtain a sorting result; The type of cloud database for the target business application is determined based on the sorting results; the cloud database is used to replace the original database of the target business application after it is migrated to a cloud service environment.
7. A complexity analysis device, characterized in that, The device includes: The acquisition module is used to acquire each structured query statement in the target business application and determine the syntax parse tree and execution plan of each structured query statement. The first determining module is used to determine the static complexity of each structured query statement based on the syntax parse tree and the business table metadata of the target business application, and to determine the dynamic complexity of each structured query statement based on the execution plan. The second determining module is used to determine the complexity analysis result of each structured query statement based on the static complexity and the dynamic complexity of each structured query statement.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.