SQL auditing method and system based on intelligent analysis and clustering
By introducing intelligent analysis and clustering technology into the SQL audit system to predict and group SQL performance, it solves the problem that traditional SQL audit systems are difficult to cope with complex business scenarios, and achieves a more efficient and secure database audit process.
Patent Information
- Application Number
- CN202411471839.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-14
AI Technical Summary
Traditional SQL auditing systems are difficult to deal with complex and changeable business scenarios, and the rules are set up rely on manual labor, which is prone to omissions and errors, and cannot effectively ensure the performance and security of the database.
The SQL audit method based on intelligent analysis and clustering is adopted to predict SQL performance through machine learning algorithms, and the SQL statements are grouped using clustering algorithms to reduce the workload of manual audits and improve audit efficiency.
Through intelligent analysis and clustering technology, SQL statements can be audited more precisely, improve audit efficiency, reduce manual errors, and enhance database performance and security.
Smart Images

Figure CN119441253A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an SQL audit method and system based on intelligent analysis and clustering, and belongs to the field of databases. Background Art
[0002] With the rapid development of information technology, a large amount of data has been accumulated in various industries and enterprises. So far, databases, especially relational databases, are still the core of data storage and processing, and they occupy a very high position in the business processing process.
[0003] SQL statements are the standard language for database operations. Designing an efficient and accurate SQL statement is crucial to ensuring database performance and data security. However, in actual applications, due to the complexity of business scenarios and the uneven business levels of database operators, the quality of SQL statement writing is often unsatisfactory. Common situations include but are not limited to low performance and high security risks. Therefore, in order to ensure the security of the database system, a fully functional SQL audit system is very necessary during the use of the database.
[0004] The main function of the SQL audit system is to audit the quality of SQL statements, promptly identify and correct problems, and the ultimate goal is to ensure that the database runs healthily, stably, and efficiently. A SQL audit system can not only identify performance problems in SQL statements, such as missing indexes, unreasonable query logic, etc., provide optimization suggestions, improve query efficiency, and reduce database load, but also detect potential injection risks in SQL statements, prevent unauthorized access and modification, ensure that applications are protected from malicious attacks, and protect the security and integrity of data.
[0005] Traditional SQL audit systems are often implemented based on fixed audit rules. The advantage of this approach is that it is simple to implement, but the disadvantage is that it is difficult to cope with complex and changing business scenarios. In addition, the setting of rules often relies on manual work, which is prone to omissions and errors. The above situation shows that the traditional SQL audit system only provides the basic functions of the SQL audit system, and the work in terms of intelligence still needs to be further strengthened. BRIEF DESCRIPTION OF THE DRAWINGS
[0006] Figure 1 It is a system structure diagram of the present invention.
[0007] Figure 2 It is a flow chart of the present invention. Summary of the invention
[0008] In order to solve the problems existing in the traditional SQL audit system, the present invention proposes a SQL audit method based on intelligent analysis and clustering, and the specific steps are as follows:
[0009] (1) User submits SQL: The user submits SQL statements through the user interface module.
[0010] (2) SQL reception and analysis: Receive SQL statements and parse them. If the analysis fails, an error is returned to the user. If successful, SQL clustering and SQL performance prediction are performed first, and then step (3) is performed.
[0011] (3) SQL audit: Audit SQL statements according to the rules in the audit rule base;
[0012] (4) System management: including data storage and management, system management and monitoring.
[0013] Furthermore, in step (2), a clustering algorithm is used to group SQL statements, and the clustering algorithm includes the following steps:
[0014] 1) Data preprocessing;
[0015] 2) Initialization: set the number of clusters c, fuzzy parameter m, parameter λ, maximum number of iterations T, and convergence threshold ε; Initialize the membership matrix U: randomly initialize an n×c membership matrix, where n is the number of SQL statements and the sum of each row is 1; Initialize the cluster center C: randomly select the feature vectors of c SQL statements as the initial cluster center;
[0016] 3) Calculation Among them, d(E i ,c j ) is the SQL statement E i The eigenvector and cluster center c j The Euclidean distance between i is the ith SQL statement, c j and c k are the jth and kth cluster centers respectively, 1≤i≤n, 1≤j≤c, j+1≤k≤c, d(c j ,c k ) is the distance between two cluster centers;
[0017] 4) For each iteration t=1,2,…,T, calculate each SQL statement E i And each cluster center c j The Euclidean distance d(E i ,c j );According to the distance and fuzzy parameter m, update the membership matrix Where s is the variable in the summation process, 1≤s≤c; update the cluster center Let c be the value of the tth iteration and the t+1th iteration. k The jth cluster center cj They are and Calculate the total change of cluster centers between iteration t and iteration t+1 If r<ε or the number of iterations is greater than T, stop the iteration; otherwise, continue to the next iteration.
[0018] 5) According to the final membership matrix U, each SQL statement is assigned to the group with the highest membership, and the number of SQL statements in each group is counted.
[0019] Based on the above method, the present invention further proposes a SQL audit system based on intelligent analysis and clustering, the system comprising:
[0020] (1) User interface module: This module provides a user interface for interaction with users and allows users to submit SQL statements.
[0021] (2) SQL receiving and parsing module: This module receives SQL statements submitted by users and performs lexical analysis and grammatical analysis on the SQL statements.
[0022] (3) SQL Audit Module: This module audits SQL statements based on the rules in the audit rule base.
[0023] (4) System management module: This module includes the data storage and management submodule and the system management and monitoring submodule. The data storage and management submodule stores historical SQL statements and audit results, and provides data backup, recovery, and security management functions; the system management and monitoring submodule manages system configuration, user permissions, log records, and monitors system performance, resource consumption, and potential security threats.
[0024] (5) Audit result output module: This module presents the audit results to the user in a visual manner.
[0025] Furthermore, in the SQL receiving and parsing module, a machine learning algorithm is used to predict the performance of SQL statements, and a clustering algorithm is used to group SQL statements. Specifically, the clustering algorithm includes the following steps:
[0026] 1) Data preprocessing;
[0027] 2) Initialization: set the number of clusters c, fuzzy parameter m, parameter λ, maximum number of iterations T, and convergence threshold ε; Initialize the membership matrix U: randomly initialize an n×c membership matrix, where n is the number of SQL statements and the sum of each row is 1; Initialize the cluster center C: randomly select the feature vectors of c SQL statements as the initial cluster center;
[0028] 3) Calculation Among them, d(E i ,cj ) is the SQL statement E i The eigenvector and cluster center c j The Euclidean distance between i is the ith SQL statement, c j and c k are the jth and kth cluster centers respectively, 1≤i≤n, 1≤j≤c, j+1≤k≤c, d(c j ,c k ) is the distance between two cluster centers;
[0029] 4) For each iteration t=1,2,…,T, calculate each SQL statement E i And each cluster center c j The Euclidean distance d(E i ,c j );According to the distance and fuzzy parameter m, update the membership matrix Where s is the variable in the summation process, 1≤s≤c; update the cluster center Let c be the value of the tth iteration and the t+1th iteration. k The jth cluster center c j They are and Calculate the total change of cluster centers between iteration t and iteration t+1 If r<ε or the number of iterations is greater than T, stop the iteration; otherwise, continue to the next iteration.
[0030] 5) According to the final membership matrix U, each SQL statement is assigned to the group with the highest membership, and the number of SQL statements in each group is counted.
[0031] Based on the basic functions of the traditional SQL audit system, the present invention introduces the SQL performance prediction function and the SQL clustering function. The former uses machine learning algorithms to predict the performance of SQL statements and provide support for performance optimization. This function replaces the traditional approach, which relies heavily on expert experience and is difficult to accurately evaluate the performance of complex queries; the latter uses a clustering algorithm to group similar SQL statements, so that users can focus on detailed audits of different groups, avoiding the duplication of auditing each SQL statement independently, thereby greatly improving the audit efficiency. DETAILED DESCRIPTION
[0032] The present invention proposes a SQL audit method based on intelligent analysis and clustering, and its system structure diagram is as follows: Figure 1 As shown. The system mainly includes the following modules:
[0033] (1) User interface module: This module provides a user interface for user interaction, mainly for users to submit SQL statements. The user interface includes a Web interface, an API interface, etc.
[0034] (2) SQL receiving and parsing module: The main function of this module is to receive SQL statements submitted by users and perform lexical analysis and syntax analysis on SQL statements to ensure that they comply with SQL writing specifications. In this module, SQL performance prediction function and SQL clustering function are added. The SQL performance prediction function mainly uses machine learning algorithms to predict the performance of SQL statements; the SQL clustering function uses clustering algorithms to group SQL statements.
[0035] (3) SQL audit module: This module audits SQL statements based on the rules in the audit rule base, which stores predefined SQL audit rules that cover performance issues, security risks, code quality, etc. In this module, SQL performance prediction and clustering results can help improve the efficiency of auditing.
[0036] (4) System management module: This module provides system management functions, including data storage and management, and system management and monitoring. The data storage and management part stores historical SQL statements, audit results, etc., and provides data backup, recovery and security management functions; the system management and monitoring part manages system configuration, user permissions, log records, etc., and can monitor system performance, resource consumption and potential security threats.
[0037] (5) Audit result output module: This module presents the audit results to the user in a visual manner. The audit results include performance scores, risk levels, optimization suggestions, etc.
[0038] The flowchart of the present invention is shown in Figure 2 Specifically, the entire processing flow of the SQL audit system proposed in the present invention from the user submitting SQL to the completion of SQL audit is as follows:
[0039] (1) User submits SQL: The user submits SQL statements through the user interface module.
[0040] (2) SQL reception and analysis: This step receives SQL statements and parses them. If the analysis fails, an error is returned to the user. If successful, the next step is entered. This step also includes two functions: SQL clustering and SQL performance prediction.
[0041] The SQL clustering function uses a clustering algorithm to group SQL statements. The grouping results are used for subsequent review and recommendation. The SQL clustering algorithm includes the following steps:
[0042] 1) Data preprocessing, this step mainly includes:
[0043] a) Collect SQL statements: Collect SQL statements from databases, log files or other sources.
[0044] b) Feature extraction: The following features are mainly selected in the algorithm:
[0045] Query type: SELECT, UPDATE, INSERT, DELETE, etc.
[0046] Number of tables involved: The number of tables involved in the SQL statement.
[0047] Number of columns: The number of columns involved in the SQL statement.
[0048] Aggregate function usage: whether aggregate functions such as COUNT, SUM, AVG, etc. are used.
[0049] Conditional Clause Complexity: Assessed based on the number of conditions, operator types, and nesting levels in the WHERE clause.
[0050] Sorting and grouping usage: whether the ORDER BY and GROUP BY clauses are used.
[0051] Subquery usage: whether a subquery exists.
[0052] JOIN operation type and number: the type and number of INNER JOIN, LEFT JOIN and other operations.
[0053] Function and stored procedure calls: Whether a function or stored procedure was called.
[0054] SQL query execution time.
[0055] c) Feature encoding:
[0056] The above feature list contains categorical features and numerical features. The categorical features are converted into binary vectors using one-hot encoding, and the numerical features are normalized using the linear function normalization method to ensure that all numerical features are on the same scale.
[0057] 2) Initialization
[0058] a) Set clustering parameters: number of clusters c, fuzzy parameter m, parameter λ, maximum number of iterations T, and convergence threshold ε.
[0059] b) Initialize the membership matrix U: Randomly initialize an n×c membership matrix, where n is the number of SQL statements, and ensure that the sum of each row is 1 during initialization.
[0060] c) Initialize cluster center C: Randomly select feature vectors of c SQL statements as initial cluster centers.
[0061] 3) Objective function
[0062] The objective function of the clustering algorithm is:
[0063]
[0064] Among them, d(E i ,c j ) is the SQL statement E i The eigenvector and cluster center c j The Euclidean distance between i Indicates the i-th SQL statement, c j and c k denote the jth and kth cluster centers respectively, 1≤i≤n, 1≤j≤c, j+1≤k≤c, d(c j ,c k ) is the distance between two cluster centers. The second term in the objective function is a spatial constraint term used to encourage dispersion between cluster centers.
[0065] 4) Iterative Optimization
[0066] For each iteration t=1,2,…,T:
[0067] a) Calculate the distance: For each SQL statement E i And each cluster center c j , calculate the Euclidean distance d(E i ,c j ).
[0068] b) Update the membership matrix U: According to the distance and fuzzy parameter m, the membership matrix is updated using the following formula:
[0069] Where s is the variable in the summation process, 1≤s≤c;
[0070] c) Update the cluster center C: Use the following formula to update the cluster center:
[0071]
[0072] d) Check convergence: First calculate the change of cluster center, set c at iteration t and iteration t+1 kThe jth cluster center c j Respectively expressed as and The total change of cluster centers between the tth iteration and the t+1th iteration is expressed as If r<ε, or the number of iterations is greater than T, stop the iteration; otherwise, jump to step a) of step 4) iterative optimization to continue the next iteration.
[0073] 5) Result output
[0074] According to the final membership matrix U, each SQL statement is assigned to the group with the highest membership, and the number of SQL statements in each group is counted.
[0075] In addition to the SQL clustering function, the SQL receiving and parsing step also includes a SQL performance prediction function, which mainly predicts the execution time of SQL statements based on the results of the SQL clustering function. The steps of the SQL statement execution time prediction algorithm are:
[0076] 1) For the SQL statement to be predicted, extract and encode its other features except the SQL query execution time feature, and determine the cluster group to which the SQL statement belongs.
[0077] 2) In the selected cluster grouping, calculate the cosine similarity between the SQL statement to be predicted and each data point, and select the K data points with the highest similarity as the nearest neighbors.
[0078] 3) Calculate weighted prediction time: For each nearest neighbor, use its cosine similarity with the SQL statement to be predicted as the weight to calculate the weighted prediction time, that is, multiply the SQL execution time of each nearest neighbor by its corresponding weight, and then calculate the weighted sum, and then divide the weighted sum by the sum of the weights to get the final prediction time.
[0079] (3) SQL Audit: Audit SQL statements according to the rules in the audit rule library. During the audit process, a more detailed audit can be conducted in combination with performance prediction and clustering results. After the audit, the audit results are generated, including performance scores, risk levels, optimization suggestions, etc.
[0080] (4) System management: It includes data storage and management, and system management and monitoring. The data storage and management module stores historical SQL statements, audit results, model parameters, etc. for subsequent analysis and system optimization. The system management and monitoring module monitors system status, performance, and security, and provides necessary system configuration, user management, and logging functions.
[0081] The following is a description of the entire processing flow of the SQL audit system from user submission of SQL to SQL auditing in conjunction with specific examples:
[0082] (1) User submits SQL: The user submits a SQL statement through the user interface module:
[0083] SELECT COUNT(*)FROM orders WHERE order_date>'2022-01-01'AND status='shipped';
[0084] (2) SQL reception and analysis: Receive the above SQL statements and parse them. The following describes the specific processes of the two functions of SQL clustering and SQL performance prediction.
[0085] The SQL clustering function includes the following steps:
[0086] 1) Data preprocessing, this step mainly includes:
[0087] a) Collect SQL statements: Collect a large number of historical SQL statements from databases, log files or other sources, such as UPDATE customers SET email = 'newemail@example.com' WHERE customer_id = 123;
[0088] b) Feature extraction: After feature extraction, the above SQL example is expressed as:
[0089] Query type: UPDATE
[0090] Number of tables involved: 1
[0091] Number of columns: 1 (update email field)
[0092] Aggregate function usage: No
[0093] Conditional Clause Complexity: Low (single condition)
[0094] Sorting and grouping use: No
[0095] Subquery usage: No
[0096] JOIN operation type and number: None
[0097] Function and stored procedure calls: None
[0098] SQL query execution time: (need to be obtained by actual execution)
[0099] c) Feature encoding:
[0100] Categorical features (such as query type) are one-hot encoded, and numerical features (such as the number of tables involved) are normalized. For simplicity, only the one-hot encoding of query types (SELECT, UPDATE, INSERT, DELETE) is shown, and the encoding of each type is assumed to be [1,0,0,0] for SELECT, [0,1,0,0] for UPDATE, [0,0,1,0] for INSERT, and [0,0,0,1] for DELETE.
[0101] Therefore, the query type of the example SQL is encoded as [0,1,0,0], plus the one-hot encoding of other categorical features and other normalized numerical feature vectors, forming a complete feature vector of the example SQL.
[0102] 2) Initialization
[0103] a) Set clustering parameters: number of clusters c = 5, fuzzy parameter m = 2, parameter λ = 1, maximum number of iterations T = 100, and convergence threshold ε = 0.001.
[0104] b) Initialize the membership matrix U: Assuming there are 100 SQL statements in total, randomly initialize a 100×5 membership matrix, where n is the number of SQL statements, and ensure that the sum of each row is 1 during initialization.
[0105] c) Initialize cluster center C: Randomly select the feature vectors of 5 SQL statements as the initial cluster center.
[0106] 3) Iterative Optimization
[0107] a) Iteration 1:
[0108] Calculate the distance between each SQL statement and the cluster center.
[0109] Update the membership matrix U.
[0110] Update cluster center C.
[0111] Check convergence: Calculate the total change r of the cluster center. If r>=ε and the maximum number of iterations T has not been reached, continue iterating.
[0112] b) Second and subsequent iterations:
[0113] Repeat the steps of the first iteration until the convergence condition (r<ε) is met or the maximum number of iterations T is reached.
[0114] 5) Result output
[0115] According to the final membership matrix U, each SQL statement is assigned to the cluster center with the highest membership. The number of SQL statements in each cluster grouping is counted, and the clustering results are output.
[0116] In addition to the SQL clustering function, the SQL receiving and parsing step also includes a SQL performance prediction function, which mainly predicts the execution time of SQL statements based on the results of the SQL clustering function. The steps of the SQL statement execution time prediction algorithm are:
[0117] 1) For SQL statements to be predicted, such as SQL statements submitted by users:
[0118] SELECT COUNT(*)FROM orders WHERE order_date>'2022-01-01'AND status='shipped';
[0119] Extract and encode other features except the SQL query execution time feature. The features of this SQL statement are:
[0120] Query type: SELECT
[0121] Number of tables involved: 1
[0122] Number of columns: 1 (although only the results of COUNT(*) are selected, we can treat it as one column here)
[0123] Aggregate function used: Yes (COUNT)
[0124] Conditional Clause Complexity: Low (simple comparison and single operator)
[0125] Sorting and grouping use: No
[0126] Subquery usage: No
[0127] JOIN operation type and number: None
[0128] Function and stored procedure calls: None
[0129] The encoding rules consistent with the above method are used to construct the feature vector corresponding to the SQL statement, and the cluster group to which the SQL statement belongs is determined accordingly.
[0130] 2) In the selected cluster grouping, calculate the cosine similarity between the SQL statement to be predicted and each data point, and select the 5 data points with the highest similarity as the nearest neighbors. Assume that the information of these 5 data points, i.e. 5 SQL statements, is shown in Table 1.
[0131] Table 1 SQL information table
[0132] Serial number SQL Execution time / ms Similarity 1 SELECT * FROM users… 3.2 0.9 2 SELECT name FROM users… 2.5 0.8 3 INSERT INTO orders(id,… 2.9 0.7 4 UPDATE users SET name… 1.8 0.6 5 DELETE FROM users WHERE… 1.2 0.5
[0133] 3) Calculate weighted prediction time: For each nearest neighbor, use its cosine similarity with the SQL statement to be predicted as the weight to calculate the weighted prediction time, that is, multiply the SQL execution time of each nearest neighbor by its corresponding weight, and then calculate the weighted sum, and then divide the weighted sum by the sum of the weights to get the final prediction time.
[0134] Combining the above example, the final prediction time can be calculated as: ((3.2×0.9)+(2.5×0.8)+(2.9×0.7)+(1.8×0.6)+(1.2×0.5)) / (0.9+0.8+0.7+0.6+0.5)≈2.45ms
[0135] Combined with the calculation results, it is illustrated that the technical advantages of the present invention over the prior art are demonstrated.
[0136] In the SQL audit process, the workload of manual audit is large because of the large number of SQL statements. After the above function is added, it is equivalent to estimating the status of SQL statements before the user audits, including performance prediction and clustering results, etc. Therefore, it can greatly facilitate the process of SQL audit for users and improve the efficiency of SQL audit for users accordingly. Moreover, this method is not limited to fixed rules, and can also handle complex SQL statements, and its application scope is wider.
[0137] (3) SQL audit: SQL statements are audited according to the rules in the audit rule library. During the audit process, performance prediction and clustering results can be combined for a more detailed audit. After the audit, audit results are generated, including performance scores, risk levels, optimization suggestions, etc. SQL prediction time can help users improve audit efficiency.
[0138] (4) System management: It includes data storage and management, and system management and monitoring. The data storage and management module stores historical SQL statements, audit results, model parameters, etc. for subsequent analysis and system optimization. The above SQL statements submitted by users and their audit results will be stored in the system accordingly. The system management and monitoring module monitors the system status, performance, and security, and provides necessary system configuration, user management, and logging functions.
Claims
1. A SQL audit method based on intelligent analysis and clustering, characterized by: The specific steps include: (1) User submits SQL: The user submits SQL statements through the user interface module. (2) SQL reception and analysis: Receive SQL statements and parse them. If the analysis fails, an error is returned to the user. If successful, SQL clustering and SQL performance prediction are performed first, and then step (3) is performed. (3) SQL audit: Audit SQL statements according to the rules in the audit rule base; (4) System management: including data storage and management, system management and monitoring.
2. The SQL audit method based on intelligent analysis and clustering as claimed in claim 1, characterized in that: In step (2), a clustering algorithm is used to group SQL statements. The clustering algorithm includes the following steps: 1) Data preprocessing; 2) Initialization: set the number of clusters c, fuzzy parameter m, parameter λ, maximum number of iterations T, and convergence threshold ε; Initialize the membership matrix U: randomly initialize an n×c membership matrix, where n is the number of SQL statements and the sum of each row is 1; Initialize the cluster center C: randomly select the feature vectors of c SQL statements as the initial cluster center; 3) Calculation Among them, d(E i ,c j ) is the SQL statement E i The eigenvector and cluster center c j The Euclidean distance between i is the ith SQL statement, c j and c k are the jth and kth cluster centers respectively, 1≤i≤n, 1≤j≤c, j+1≤k≤c, d(c j ,c k ) is the distance between two cluster centers; 4) For each iteration t=1,2,…,T, calculate each SQL statement E i And each cluster center c j The Euclidean distance d(E i ,c j );According to the distance and fuzzy parameter m, update the membership matrix Where s is the variable in the summation process, 1≤s≤c; update the cluster center Let c be the value of the tth iteration and the t+1th iteration. k The jth cluster center c j They are and Calculate the total change of cluster centers between iteration t and iteration t+1 If r<ε or the number of iterations is greater than T, stop the iteration; otherwise, continue to the next iteration. 5) According to the final membership matrix U, each SQL statement is assigned to the group with the highest membership, and the number of SQL statements in each group is counted.
3. Propose a SQL audit system based on intelligent analysis and clustering, which is characterized by: The system includes: (1) User interface module: This module provides a user interface for interaction with users and allows users to submit SQL statements. (2) SQL receiving and parsing module: This module receives SQL statements submitted by users and performs lexical analysis and grammatical analysis on the SQL statements. (3) SQL Audit Module: This module audits SQL statements based on the rules in the audit rule base. (4) System management module: This module includes the data storage and management submodule and the system management and monitoring submodule. The data storage and management submodule stores historical SQL statements and audit results, and provides data backup, recovery, and security management functions; the system management and monitoring submodule manages system configuration, user permissions, log records, and monitors system performance, resource consumption, and potential security threats. (5) Audit result output module: This module presents the audit results to the user in a visual manner.
4. The SQL audit system based on intelligent analysis and clustering as claimed in claim 3, characterized in that: In the SQL receiving and parsing module, a machine learning algorithm is used to predict the performance of SQL statements, and a clustering algorithm is used to group SQL statements. Specifically, the clustering algorithm includes the following steps: 1) Data preprocessing; 2) Initialization: set the number of clusters c, fuzzy parameter m, parameter λ, maximum number of iterations T, and convergence threshold ε; Initialize the membership matrix U: randomly initialize an n×c membership matrix, where n is the number of SQL statements and the sum of each row is 1; Initialize the cluster center C: randomly select the feature vectors of c SQL statements as the initial cluster center; 3) Calculation Among them, d(E i ,c j ) is the SQL statement E i The eigenvector and cluster center c j The Euclidean distance between i is the ith SQL statement, c j and c k are the jth and kth cluster centers respectively, 1≤i≤n, 1≤j≤c, j+1≤k≤c, d(c j ,c k ) is the distance between two cluster centers; 4) For each iteration t=1,2,…,T, calculate each SQL statement E i And each cluster center c j The Euclidean distance d(E i ,c j );According to the distance and fuzzy parameter m, update the membership matrix Where s is the variable in the summation process, 1≤s≤c; update the cluster center Let c be the value of the tth iteration and the t+1th iteration. k The jth cluster center c j They are and Calculate the total change of cluster centers between iteration t and iteration t+1 If r<ε or the number of iterations is greater than T, stop the iteration; otherwise, continue to the next iteration. 5) According to the final membership matrix U, each SQL statement is assigned to the group with the highest membership, and the number of SQL statements in each group is counted.
Citation Information
Patent Citations
Clustering database queries for runtime prediction
CN105740312A
SQL statement optimization method and device
CN116266182A
SQL (Structured Query Language) time consumption analysis method combining supervised and unsupervised machine learning
CN118427239A
Automatic index creation for relational database systems
US20230376482A1