Database performance optimization method and device

By optimizing indexes, query statements and table structures, combined with server parameter adjustments, the performance problems of the database under high load are solved, response speed and processing efficiency are improved, system efficiency and user experience are improved, and costs are reduced.

CN118535546APending Publication Date: 2024-08-23INDUSTRIAL AND COMMERCIAL BANK OF CHINA

Patent Information

Application Number
CN202410581466.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-11
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

When existing databases face an increase in data volume and query request complexity, the original structure and configuration cannot meet performance requirements, resulting in an increase in response time and affecting system operating efficiency.

Method used

Improve database response speed and processing efficiency by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, including obtaining hardware resource configuration information, analyzing slow queries, creating indexes, optimizing query statements and table structures, and adjusting server parameters. .

Benefits of technology

It significantly improves the response speed and processing efficiency of the database, improves the operating efficiency and user experience of the system, helps enterprises save costs, and enhances the scalability and maintainability of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535546A
    Figure CN118535546A
Patent Text Reader

Abstract

The embodiment of the invention provides a database performance optimization method and device, relates to the field of big data and can also be applied to the financial field, and the method comprises the steps that hardware resource configuration information of a database server is acquired, and whether hardware resources meet current service requirements or not is determined; positioning a data query statement exceeding a preset time threshold based on the slow query; optimizing the data query statement under the condition that the positioned data query statement has the problem of long execution time or waiting time; according to the method, the response speed and the processing efficiency of the database can be remarkably improved through the measures of optimizing the index, adjusting the query statement, improving the table structure design, finely regulating and controlling the server parameters and the like, so that the operation efficiency of the system and the user experience are directly improved. In addition, the method can help enterprises to save cost and enhance the expandability and maintainability of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data and can also be applied to the financial field, and specifically to a database performance optimization method and device. Background Art

[0002] In the era of rapid development of informatization, database technology has become an indispensable infrastructure for various Internet applications and enterprise systems. The performance of the database is directly related to the response speed and processing efficiency of the application system, which in turn affects the user experience and the efficiency of enterprise operations.

[0003] For example, MySQL, as a widely used relational database management system (RDBMS), is widely adopted by many enterprises due to its open source, cost-effectiveness, high performance and reliability. As a relational database, MySQL supports the storage and complex query of structured data and is the preferred database system for many dynamic websites and business applications.

[0004] However, despite MySQL's good performance, it may still face many performance issues in actual applications, such as hardware limitations, unreasonable configuration, improper database design, or low query efficiency. With the increase in data volume and the complexity of query requests, the original database structure and configuration may not meet performance requirements, resulting in increased response time and affecting the operating efficiency of the entire system. How to effectively diagnose problems and implement appropriate optimization strategies has become the key to improving database performance today. Summary of the invention

[0005] In view of the problems in the prior art, this application provides a database performance optimization method and device, which can significantly improve the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database.

[0006] In order to solve at least one of the above problems, the present application provides the following technical solutions:

[0007] According to a first aspect of an embodiment of the present application, the present application provides a database performance optimization method, comprising:

[0008] Obtaining hardware resource configuration information of the database server, and determining whether the hardware resources meet current business requirements based on the configuration information;

[0009] In response to the hardware resources meeting the current business requirements, locating data query statements that exceed a preset time threshold based on slow queries, and analyzing the execution cost, execution plan, and performance issues of each located data query statement;

[0010] When the located data query statement has a long execution time problem, optimizing the data query statement based on indexes, statement structures, and table design structures;

[0011] In the case where the located data query statement has a long waiting time problem, the data query statement is optimized based on the parameters of the database server.

[0012] According to any implementation manner of the present application, the acquiring of hardware resource configuration information of the database server and determining whether the hardware resources meet current business requirements according to the configuration information includes:

[0013] Determine whether the hardware resource configuration information of the CPU and memory of the database server meets the requirements of the number of transactions that can be processed and the number of query requests that can be processed for the current business;

[0014] In response to the hardware resource configuration information of the CPU and memory satisfying the processable transaction quantity requirement and processable query request quantity requirement of the current business currently or after the hardware resources are increased, it is determined that the hardware resources meet the current business requirements.

[0015] According to any implementation manner of the present application, the respectively analyzing the execution cost of each located data query statement includes:

[0016] Enable the inspection analysis function and obtain all the performance analysis data recorded in the current database session;

[0017] The performance overhead of each located data query statement during execution is determined according to the performance analysis data.

[0018] According to any implementation of the present application, the execution plan includes:

[0019] The query identifier, query type, used tables, matching partition information, access type, potential indexes, actual used indexes and their lengths, index matching objects, estimated number of records to read, percentage of records after filtering, and additional execution information.

[0020] According to any implementation manner of the present application, the step of respectively analyzing the performance problem of each located data query statement includes:

[0021] According to the system architecture diagram of the database server, engine performance information, input and output information, memory usage information, table statistics information, index information and statement information of the database are determined respectively.

[0022] According to any implementation manner of the present application, the optimizing the data query statement based on the index includes:

[0023] Creating an index for the field of the query condition whose usage frequency exceeds the first threshold;

[0024] Creating an index for the columns used for sorting and grouping whose usage frequency exceeds a second threshold;

[0025] Create indexes for conditional columns in data modification and data removal operations;

[0026] Create an index for a field that returns unique values.

[0027] When multiple fields are involved, create a joint index and place the most frequently used column at the leftmost side of the joint index.

[0028] According to any implementation manner of the present application, the optimizing the data query statement based on the statement structure includes:

[0029] Use join operations or split the subquery into multiple queries;

[0030] Use indexes to perform sorting and grouping operations;

[0031] Place the filter condition in the query clause instead of the filter clause.

[0032] According to any implementation manner of the present application, the optimizing the data query statement based on the table design structure includes:

[0033] The number of control connection tables shall not exceed three;

[0034] Create indexes for the fields involved in the join operation and ensure that the data types of the fields in different tables are consistent;

[0035] In the inner join operation, select the table with the small result set as the driving table;

[0036] In a left join operation, the smaller table is selected as the driving table and the larger table as the driven table.

[0037] According to any implementation manner of the present application, the optimizing the data query statement based on the parameters of the database server includes:

[0038] Set the buffer pool size parameter to the system memory to the first preset range to speed up the query while avoiding excessive use of operating system resources;

[0039] Adjust the storage engine thread concurrency parameter to a second preset range to limit the number of threads that can run simultaneously;

[0040] Setting the current maximum connection parameter to a third preset range according to the maximum number of connection errors in history to increase the maximum number of connections and avoid connection failures due to reaching the connection limit;

[0041] Set the number of open file handles parameter to the fourth preset range to limit the number of open file handles to ensure smooth database file operations.

[0042] According to any embodiment of the present application, it also includes:

[0043] In response to being unable to continue optimizing the data query statement, the data is divided into multiple copies to different database servers through read-write separation or library and table sharding to reduce access pressure on a single database server.

[0044] According to a second aspect of an embodiment of the present application, the present application provides a database performance optimization device, including:

[0045] The hardware detection module is used to obtain the hardware resource configuration information of the database server and determine whether the hardware resources meet the current business requirements according to the configuration information;

[0046] The query optimization module is used to: in response to the hardware resources meeting the current business needs, locate the data query statements that exceed the preset time threshold based on the slow query, and analyze the execution cost, execution plan and performance problem of each located data query statement respectively;

[0047] An execution optimization module is used to: optimize the data query statement based on the index, statement structure and table design structure when the located data query statement has a problem of long execution time;

[0048] The waiting optimization module is used to optimize the data query statement based on the parameters of the database server when the located data query statement has a long waiting time problem.

[0049] According to any implementation of the present application, the hardware detection module includes:

[0050] A resource query unit, used to determine whether the hardware resource configuration information of the CPU and memory of the database server meets the requirements of the number of processable transactions and the number of processable query requests of the current business;

[0051] The resource matching unit is used to: determine that the hardware resources meet the current business needs in response to the hardware resource configuration information of the CPU and memory that currently or after the hardware resources are increased, the hardware resources meet the current business needs for the number of processable transactions and the number of processable query requests.

[0052] According to any implementation of the present application, the query optimization module includes:

[0053] The analysis start unit is used to start the inspection analysis function and obtain all the performance analysis data recorded in the current database session;

[0054] The cost determination unit is used to determine the performance cost of each located data query statement during execution according to the performance analysis data.

[0055] According to any embodiment of the present application, the execution plan includes: the query identifier, the query type, the table used, the matching partition information, the access type, the potential index, the actually used index and its length, the index matching object, the estimated number of read records, the filtered record ratio and additional execution information.

[0056] According to any implementation manner of the present application, the query optimization module analyzes the performance problem of each located data query statement respectively, specifically for:

[0057] According to the system architecture diagram of the database server, engine performance information, input and output information, memory usage information, table statistics information, index information and statement information of the database are determined respectively.

[0058] According to any implementation manner of the present application, when the execution optimization module optimizes the data query statement based on the index, it is specifically used to:

[0059] Creating an index for the field of the query condition whose usage frequency exceeds the first threshold;

[0060] Creating an index for the columns used for sorting and grouping whose usage frequency exceeds a second threshold;

[0061] Create indexes for conditional columns in data modification and data removal operations;

[0062] Create an index for a field that returns unique values.

[0063] When multiple fields are involved, create a joint index and place the most frequently used column at the leftmost side of the joint index.

[0064] According to any implementation manner of the present application, when the execution optimization module optimizes the data query statement based on the statement structure, it is specifically used to:

[0065] Use join operations or split the subquery into multiple queries;

[0066] Use indexes to perform sorting and grouping operations;

[0067] Place the filter condition in the query clause instead of the filter clause.

[0068] According to any implementation manner of the present application, when the execution optimization module optimizes the data query statement based on the table design structure, it is specifically used to:

[0069] The number of control connection tables shall not exceed three;

[0070] Create indexes for the fields involved in the join operation and ensure that the data types of the fields in different tables are consistent;

[0071] In the inner join operation, select the table with the small result set as the driving table;

[0072] In a left join operation, the smaller table is selected as the driving table and the larger table as the driven table.

[0073] According to any implementation manner of the present application, when the waiting optimization module optimizes the data query statement based on the parameters of the database server, it is specifically used to:

[0074] Set the buffer pool size parameter to the system memory to the first preset range to speed up the query while avoiding excessive use of operating system resources;

[0075] Adjust the storage engine thread concurrency parameter to a second preset range to limit the number of threads that can run simultaneously;

[0076] Setting the current maximum connection parameter to a third preset range according to the maximum number of connection errors in history to increase the maximum number of connections and avoid connection failures due to reaching the connection limit;

[0077] Set the number of open file handles parameter to the fourth preset range to limit the number of open file handles to ensure smooth database file operations.

[0078] According to any embodiment of the present application, it also includes an optimization deepening module, which is used to:

[0079] In response to being unable to continue optimizing the data query statement, the data is divided into multiple copies to different database servers through read-write separation or library and table sharding to reduce access pressure on a single database server.

[0080] According to a third aspect of an embodiment of the present application, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the database performance optimization method when executing the program.

[0081] According to a fourth aspect of an embodiment of the present application, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the database performance optimization method when executed by a processor.

[0082] According to a fifth aspect of the embodiments of the present application, the present application provides a computer program product, including a computer program / instruction, which implements the steps of the database performance optimization method when executed by a processor.

[0083] It can be seen from the above technical solution that the present application provides a database performance optimization method and device, which obtains the hardware resource configuration information of the database server to determine whether the hardware resources meet the current business needs; locates the data query statement that exceeds the preset time threshold based on the slow query; optimizes the data query statement when the located data query statement has a long execution time problem or a long waiting time problem; can significantly improve the response speed and processing efficiency of the database through multiple measures such as optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the system's operating efficiency and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of databases. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the drawings without paying creative work.

[0085] Figure 1 This is one of the flow charts of the database performance optimization method in the embodiment of the present application;

[0086] Figure 2 This is the second flow chart of the database performance optimization method in the embodiment of the present application;

[0087] Figure 3 The third flowchart of the database performance optimization method in the embodiment of the present application;

[0088] Figure 4 This is a fourth flow chart of the database performance optimization method in an embodiment of the present application;

[0089] Figure 5 This is a fifth flow chart of the database performance optimization method in the embodiment of the present application;

[0090] Figure 6 This is the sixth flow chart of the database performance optimization method in the embodiment of the present application;

[0091] Figure 7 This is the seventh flow chart of the database performance optimization method in the embodiment of the present application;

[0092] Figure 8 It is a structural diagram of a database performance optimization device in an embodiment of the present application;

[0093] Fig. 9 A complete flowchart of database performance optimization in an embodiment of the present application;

[0094] Fig.10 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0095] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0096] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0097] The information collected in the technical solution of this application is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0098] Considering that with the increase of data volume and the complexity of query requests, the original database structure and configuration may not meet the performance requirements, resulting in an increase in response time, affecting the operating efficiency of the entire system, this application provides a database performance optimization method and device, which significantly improves the response speed and processing efficiency of the database through multiple measures such as optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database.

[0099] In order to significantly improve the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database. This application provides an embodiment of a database performance optimization method, see Figure 1 , the database performance optimization method specifically includes the following contents:

[0100] Step S101: Acquire hardware resource configuration information of a database server, and determine whether the hardware resources meet current business requirements based on the configuration information.

[0101] First, collect and evaluate the database server's hardware resources, including CPU, memory, storage space, and network bandwidth. By comparing the hardware resources with the current business requirements (such as the number of concurrent users, data processing volume, and response time), you can determine whether the existing hardware configuration is sufficient. If the hardware resources are insufficient to support current business needs, it may cause the database to respond slowly and affect the overall application performance. By systematically evaluating the hardware resources, administrators can make decisions to upgrade the hardware or adjust resource allocation to ensure that the database can run efficiently and support the needs of business operations.

[0102] Step S102: In response to the hardware resources meeting the current business requirements, data query statements exceeding a preset time threshold are located based on slow queries, and the execution cost, execution plan, and performance issues of each located data query statement are analyzed respectively.

[0103] After confirming that the hardware resources are sufficient to support the current business, use monitoring tools to identify and locate slow query statements whose execution time exceeds the predetermined threshold. Analyze the query results, including viewing its execution plan (through SQL commands such as EXPLAIN), evaluating the execution cost, and determining the specific cause of the performance problem. Factors such as complex query logic, large data volume, and improper use of indexes may be involved. Through in-depth analysis of slow queries, key problem points that affect performance can be accurately diagnosed.

[0104] Step S103: When the located data query statement has a long execution time problem, the data query statement is optimized based on indexes, statement structures, and table design structures.

[0105] After the analysis is completed, optimize those queries that take too long to execute. This includes but is not limited to adjusting the structure of query statements, optimizing or adding necessary indexes, and improving table design. For example, redesign query statements to reduce unnecessary table joins, introduce more effective index strategies to speed up data retrieval, or adjust table structures to reduce data redundancy and improve data access efficiency. Ensure that queries can return results in the shortest time, thereby improving the response speed and overall performance of the database.

[0106] Step S104: When the located data query statement has a long waiting time problem, the data query statement is optimized based on the parameters of the database server.

[0107] For queries that take too long to wait, in addition to optimizing the query itself, you also need to optimize the server configuration parameters. This involves adjusting database server parameters such as memory allocation, connection pool size, buffer size, etc. By fine-tuning these parameters, you can better manage database resources and optimize the query execution environment, thereby reducing query wait time and increasing the database's ability to handle concurrent requests. This step is a key component of performance optimization and is directly related to the performance and stability of the database under high load environments.

[0108] From the above description, it can be seen that the database performance optimization method provided by the embodiment of the present application can significantly improve the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database.

[0109] In one embodiment of the database performance optimization method of the present application, see Figure 2, the obtaining of the hardware resource configuration information of the database server and determining whether the hardware resources meet the current business requirements according to the configuration information may also specifically include the following contents:

[0110] Step S101A: Determine whether the hardware resource configuration information of the CPU and memory of the database server meets the requirements of the number of processable transactions and the number of processable query requests of the current business;

[0111] Step S101B: In response to the hardware resource configuration information of the CPU and memory satisfying the processable transaction quantity requirement and processable query request quantity requirement of the current business currently or after the hardware resources are increased, it is determined that the hardware resources meet the current business requirements.

[0112] By observing the server status and checking the server's CPU, memory and other hardware resource configurations, we evaluate whether the business scenario TPS and QPS are consistent with the server configuration. TPS represents the number of transactions that the system can process per second, and QPS represents the number of query requests that the system can process per second.

[0113] A reference table provided in this application for evaluating whether the TPS and QPS of a business scenario are consistent with the server configuration is shown in Table 1:

[0114] Table 1

[0115] CPU Memory Single database TPS Single database QPS 4core 16G 250 5000 8core 32G 750 15000 12core 48G 1250 25000 16core 64G 2000 40000 16core 128G 2500 50000

[0116] If not, you can increase the hardware resources to see if the performance problem can be solved. If increasing the hardware resources still cannot solve the problem or the hardware resources meet the requirements, enable slow query and collect SQL statements that exceed the scheduled time threshold.

[0117] In one embodiment of the database performance optimization method of the present application, see Figure 3 The analysis of the execution cost of each located data query statement may further specifically include the following contents:

[0118] Step S102A: Enable the inspection analysis function and obtain all the performance analysis data recorded in the current database session;

[0119] Step S102B: determining the performance overhead of each located data query statement during execution according to the performance analysis data.

[0120] For example, before starting the analysis, you first need to confirm whether the SHOW PROFILE function has been activated on the database server. This can be done by executing the SQL command SHOW VARIABLES LIKE 'profiling'. This command will return the current status of the performance variable (profiling). If the status is OFF, you need to turn on this function for further performance analysis.

[0121] If SHOW PROFILE is not enabled, you can enable it by executing the command SET profiling = ON so that the database starts recording performance analysis data for each query.

[0122] When profiling is enabled, each SQL query executed will be tracked and detailed performance data will be recorded.

[0123] Once the SHOW PROFILE feature is enabled, you can view the performance analysis records of all SQL queries in the current database session through the command SHOW PROFILES;. This command returns a list showing the query number, query time, and a brief query summary for each query, based on which you can quickly browse and select specific queries for in-depth analysis. You can display the performance analysis of a specific query based on the command (SHOW PROFILE FOR QUERY n;), where n is the number of the corresponding query in the SHOWPROFILES; command output. This command shows in detail the time consumed in each stage of the query execution process, such as parsing the query, executing, retrieving data, etc., which provides key information for identifying query performance bottlenecks, such as whether there is excessive CPU consumption or I / O waits.

[0124] Through the above steps of the present application, the system can automatically identify and analyze the specific reasons leading to poor query performance, and provide data support for further optimizing queries or adjusting database configuration.

[0125] In an optional embodiment, the execution plan includes:

[0126] The query identifier, query type, used tables, matching partition information, access type, potential indexes, actual used indexes and their lengths, index matching objects, estimated number of records to read, percentage of records after filtering, and additional execution information.

[0127] Exemplarily, the present application can view the SQL execution plan through the EXPLAIN command.

[0128] The functions of the columns output by the EXPLAIN statement provided in this application are as follows:

[0129] id-Unique ID, showing the unique identifier for each SELECT keyword in the query. When it contains subqueries or compound queries, the id helps to distinguish different parts of the query. Each different SELECT component will have a different id, and the higher number indicates the part that is executed first in the query.

[0130] select_type-query type, indicating the type of query, including simple query (SIMPLE), joint query (UNION), subquery that depends on the result of external query (DEPENDENT SUBQUERY), etc. The field helps to understand the complexity and dependency of the query.

[0131] table - table name, showing the table name involved in the query. This helps identify which tables are involved in the query in complex query environments such as financial institutions.

[0132] partitions-matched partition information, showing the table partitions that the query may involve, and whether the query effectively utilizes the table partitions.

[0133] type-access type, which shows how MySQL accesses the table, for example, full table scan (ALL), index scan (index), range scan (range), etc.

[0134] possible_keys - Possible indexes that can be used. This lists the possible indexes that the MySQL query optimizer evaluates to be used for this query.

[0135] key-actually used index, which shows the index actually used by the query.

[0136] key_len - the length of the index used, which helps to understand whether the use of the index is optimal. Long indexes usually mean better screening effects.

[0137] ref-index column equality match object information, showing the columns or constants used for equality comparison. Usually displayed together with the key column, indicating how MySQL uses the index.

[0138] rows - estimated number of rows to read, giving an estimate of the number of rows that MySQL must examine to resolve the query.

[0139] filtered - The percentage of records after the search conditions are filtered. According to the search conditions of the table, there is still a percentage of records that need further inspection.

[0140] Extra-additional information provides more information about query execution, such as whether a temporary table is used (Using temporary) and whether sorting is required (Using filesort), which is crucial for further performance tuning.

[0141] In an optional embodiment, the step of analyzing the performance problem of each located data query statement includes:

[0142] According to the system architecture diagram of the database server, engine performance information, input and output information, memory usage information, table statistics information, index information and statement information of the database are determined respectively.

[0143] In this application, the MySQL Sys schema function can be used to analyze and identify performance issues that may exist in the database. Sys schema provides a series of predefined views, which are summarized as follows:

[0144] a. Related to innodb, detailed information about the storage engine (InnoDB), including the usage of the storage engine buffer (innodbbuffer) and the transaction waiting for locks. Through the above view, the system can observe the utilization of the buffer pool and the lock waiting problem that may cause performance bottlenecks. For example, if the hit rate of the buffer pool is low, the buffer size may need to be increased; if the lock waiting time is too long, the transaction logic may need to be optimized or the lock strategy may need to be adjusted.

[0145] bI / O related, focusing on input / output operations, summarizes the I / O wait time and I / O usage in database operations. I / O performance is one of the key factors in database performance. By monitoring I / O related data, you can identify whether there is an I / O bottleneck, such as high disk I / O latency. You may need to consider using a faster storage solution or optimizing queries to reduce I / O requirements.

[0146] c. Memory usage: This view shows the memory usage of the database server from multiple perspectives, including memory data at the host level, thread level, and event level. Effective memory management is critical to database performance. By analyzing the above view, you can detect insufficient memory or memory leaks, and adjust memory configuration or optimize memory usage strategies in a timely manner.

[0147] d. Table related, providing statistical information of each data table, such as table size, number of rows, and table structure. The information helps to identify whether there are problems in table design, such as a table that is too large and may need to be partitioned, or some tables with low query efficiency due to unreasonable structure.

[0148] e. Index information, which contains detailed information about the indexes in the database, especially redundant indexes and unused indexes. Through the view, you can find unnecessary indexes to reduce maintenance costs, or add missing indexes to improve query speed.

[0149] f. Statement related, including information about the executed SQL statements, such as full table scans, use of temporary tables, and sort operations, etc. Helps analyze SQL statements that may cause performance problems, such as frequent full table scans and excessive use of temporary tables.

[0150] In one embodiment of the database performance optimization method of the present application, see Figure 4 , the optimizing the data query statement based on the index may also specifically include the following contents:

[0151] Step S103A: creating an index for the fields of the query condition whose usage frequency exceeds the first threshold;

[0152] Step S103B: creating an index for the columns used for sorting and grouping whose usage frequency exceeds the second threshold;

[0153] Step S103C: creating an index for the conditional column in the data modification and data removal operations;

[0154] Step S103D: Create an index for the field that returns unique values;

[0155] Step S103E: When multiple fields are involved, a joint index is created, and the most frequently used column is set to the leftmost side of the joint index.

[0156] For example, if the SQL execution time is long, optimization from three aspects, namely index, SQL statement and table structure design, is a key step.

[0157] For indexes, specific optimization can be performed through the following methods:

[0158] Fields that are frequently used as query conditions (WHERE): Creating indexes for fields that frequently appear in the WHERE clause can speed up the query condition matching process.

[0159] Columns that are frequently used in ORDER BY and GROUP BY clauses: Creating indexes for these columns can optimize the efficiency of sorting and grouping operations and reduce the amount of data that needs to be sorted.

[0160] WHERE condition columns for update operations (UPDATE) and delete operations (DELETE): Indexing these columns can quickly locate the affected rows and improve the efficiency of modification and deletion operations.

[0161] DISTINCT fields: Creating indexes for fields that need to be deduplicated can speed up the execution of DISTINCT operations.

[0162] Multi-field index: When multiple fields need to be indexed, a joint index is better than a single-value index because it can solve the query requirements of multiple conditions in one operation.

[0163] Index column order: In a joint index, you should place the most frequently used columns on the left because MySQL matches columns from left to right during index lookups.

[0164] In one embodiment of the database performance optimization method of the present application, see Figure 5 , the optimizing the data query statement based on the statement structure may also specifically include the following contents:

[0165] Step S103F: Use a join operation or split the subquery into multiple queries;

[0166] Step S103G: Use the index to complete the sorting and grouping operations;

[0167] Step S103H: Place the filter condition in the query clause instead of the filter clause.

[0168] Exemplarily, optimizing the sorting and grouping of SQL statements may include:

[0169] Use indexes in WHERE to avoid full table scans, and in ORDER BY to avoid using file sorting (FileSort).

[0170] Try to use indexes to complete ORDER BY sorting. If the columns after WHERE and ORDER BY are the same, use a single index column. If they are different, use a joint index.

[0171] The principle of using indexes in GROUP BY is almost the same as that in ORDER BY.

[0172] The WHERE clause is more efficient than the filtering clause (HAVING). Conditions that can be included in the WHERE clause should not be included in the HAVING clause.

[0173] In relational databases, the basic principle of data table design is called normal form. It can be understood as the standard level that a table structure needs to meet. Generally speaking, in relational database design, it is sufficient to follow the third normal form. Preferably, sometimes in order to improve certain query performance, it is necessary to break the normal form rules, that is, denormalization.

[0174] In one embodiment of the database performance optimization method of the present application, see Figure 6, the optimizing the data query statement based on the table design structure may also specifically include the following contents:

[0175] Step S103I: controlling the number of connection tables to be no more than three;

[0176] Step S103J: create indexes for the fields involved in the connection operation, and ensure that the data types of the fields in different tables are consistent;

[0177] Step S103K: In the inner join operation, select the table with the small result set as the driving table;

[0178] Step S103L: In the left join operation, the smaller table is selected as the driving table and the larger table is selected as the driven table.

[0179] Exemplarily, the optimization of SQL statement-related queries may include:

[0180] Limit the number of joined tables: Try to keep the number of joined tables to no more than three, as increasing the number of tables will cause performance to degrade exponentially.

[0181] Index JOIN fields: Ensure that the fields involved in the JOIN operation have been indexed to speed up the connection operation.

[0182] Data type consistency: The fields that perform JOIN operations should maintain consistent data types to avoid performance losses caused by type conversion.

[0183] Optimize JOIN selection: For inner joins (INNER JOIN) and left joins (LEFT JOIN), a small table should be selected as the driving table. In INNER JOIN, MySQL will automatically select the table with the small result set as the driving table. In LEFT JOIN, a small table is selected as the driving table and a large table as the driven table to reduce the number of outer loops.

[0184] When executing a subquery, MySQL creates a temporary table for the results of the inner query, and then the outer query queries records from the temporary table. After the query is completed, the temporary table is deleted. This avoids consuming too much CPU and IO resources and generating a large number of slow queries.

[0185] Temporary tables that store subquery result sets, whether in memory or on disk, will not have indexes to avoid certain impacts on query performance.

[0186] Split the subquery SQL into multiple queries, or use JOIN instead of subquery. JOIN does not require the creation of a temporary table and is faster than subquery. If indexes are used in the query, performance can be improved.

[0187] Through the above optimization measures, the execution efficiency of SQL queries can be significantly improved, the execution time can be reduced, and the overall database performance can be improved.

[0188] In one embodiment of the database performance optimization method of the present application, see Figure 7 , the optimizing the data query statement based on the parameters of the database server may also specifically include the following contents:

[0189] Step S104A: setting the buffer pool size parameter to the system memory to a first preset range to speed up the query while avoiding excessive occupation of operating system resources;

[0190] Step S104B: adjusting the storage engine thread concurrency parameter to a second preset range to limit the number of threads that can run simultaneously;

[0191] Step S104C: setting the current maximum connection parameter to a third preset range according to the maximum number of connection errors in history, so as to increase the maximum number of connections and avoid connection failure due to reaching the connection upper limit;

[0192] Step S104D: Setting the parameter of the number of open file handles to a fourth preset range to limit the number of open file handles to ensure smooth database file operations.

[0193] If the SQL wait time is high, it usually means that the database server is not configured well enough to handle the current load efficiently.

[0194] You can improve performance and response speed by optimizing database server parameters. The following are specific configuration adjustment suggestions to optimize the performance of the InnoDB storage engine and the overall database concurrent processing capabilities:

[0195] 1. Configure the memory usage storage engine buffer pool size (innodb_buffer_pool_size): This parameter defines the memory pool size used by the InnoDB engine to cache table data and indexes.

[0196] By increasing innodb_buffer_pool_size, you can significantly increase the speed of database operations because more data can be accessed directly from memory, reducing the need to access the disk. It is recommended to set it to 50%-75% of system memory. This ratio ensures that the database has enough memory to cache data while avoiding consuming too much memory and affecting the performance of the operating system and other applications.

[0197] 2. Configure the MySQL storage engine thread concurrency (innodb_thread_concurrency). This parameter sets the maximum number of threads available when InnoDB processes requests. By controlling the number of threads, you can avoid system overload and ensure effective scheduling between threads.

[0198] The recommended setting is 4 times the number of CPU cores. This setting is based on the system's processing power and aims to maximize the use of CPU resources without causing excessive contention.

[0199] 3. Safely set the maximum number of connections (max_connections): defines the maximum number of clients that can connect to the database at the same time. By increasing this parameter appropriately, more concurrent connections can be allowed, which is suitable for high-concurrency application scenarios.

[0200] It is recommended to set it to 64 times the number of CPU cores. You can also adjust it according to the actual application load to ensure that the database can handle connection requests during peak periods, and monitor the maximum number of connection errors (connection_errors_max_connections) status variable to avoid new connection failures due to too many connections.

[0201] 4. Configure I / O behavior open file limit (open_files_limit): This parameter limits the number of file handles that the database server process can open. By increasing this parameter, you can avoid errors in database operations due to reaching the file open limit.

[0202] The recommended setting is 65535, which is sufficient to support most database operations and avoid system errors caused by insufficient file handles, such as too many open files.

[0203] By adjusting the above configurations, the response time and processing capacity of the database can be significantly improved. Reasonable configuration of database parameters can not only improve operational efficiency, but also help ensure the stable operation of the database, thereby supporting complex queries and high-concurrency application requirements.

[0204] In one embodiment of the database performance optimization method of the present application, the following contents may also be specifically included:

[0205] In response to being unable to continue optimizing the data query statement, the data is divided into multiple copies to different database servers through read-write separation or library and table sharding to reduce access pressure on a single database server.

[0206] If the database performance still reaches a bottleneck after taking the above performance optimization measures (such as index optimization, SQL tuning, parameter configuration adjustment, etc.), you can optimize the database deployment structure. This usually involves changing the way data is stored and accessed to improve the scalability and processing capabilities of the database and reduce the load on a single server.

[0207] First, database performance can be optimized by processing read and write requests separately through read-write separation, so that all write operations (INSERT, UPDATE, DELETE) are processed by the master database, while read operations (SELECT) can be processed by one or more slave databases to effectively balance the load.

[0208] For example, you can configure a master database and multiple slave databases. The master database is responsible for handling all write operations and transactional reads, and syncing data changes to the slave databases. The application or database middleware needs to intelligently distribute query requests to the appropriate database. Write requests are routed to the master database, and read requests are distributed to one or more slave databases based on the load.

[0209] In addition, data can be split vertically or horizontally into multiple databases or tables by sharding. Large tables or high-traffic tables can be distributed to different servers to reduce the pressure on a single point and improve query efficiency and data insertion speed.

[0210] For example, the rows in a table can be distributed into multiple tables according to a certain attribute (such as time, region, user ID range), each table has the same structure but stores data in different ranges. And the columns in the table can be divided into different tables according to function, for example, separating frequently accessed columns from infrequently accessed columns.

[0211] Based on business lines or service requirements, data is distributed to different database instances, and each database can be independently deployed on different servers.

[0212] By dispersing data and requests, this application can not only improve the data processing speed, but also enhance the high availability and fault tolerance of the system.

[0213] In order to significantly improve the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database. This application provides an embodiment of a database performance optimization device for implementing all or part of the content of the database performance optimization method, see Figure 8 , the database performance optimization device specifically includes the following contents:

[0214] The hardware detection module 1101 is used to obtain the hardware resource configuration information of the database server and determine whether the hardware resources meet the current business requirements according to the configuration information;

[0215] The query optimization module 1102 is used to: in response to the hardware resources meeting the current business requirements, locate the data query statements exceeding the preset time threshold based on the slow query, and analyze the execution cost, execution plan and performance problem of each located data query statement respectively;

[0216] An execution optimization module 1103 is used to optimize the data query statement based on indexes, statement structures, and table design structures when the located data query statement has a long execution time problem;

[0217] The waiting optimization module 1104 is used to optimize the data query statement based on the parameters of the database server when the located data query statement has a long waiting time problem.

[0218] According to any implementation of the present application, the hardware detection module includes:

[0219] A resource query unit, used to determine whether the hardware resource configuration information of the CPU and memory of the database server meets the requirements of the number of processable transactions and the number of processable query requests of the current business;

[0220] The resource matching unit is used to: determine that the hardware resources meet the current business needs in response to the hardware resource configuration information of the CPU and memory that currently or after the hardware resources are increased, the hardware resources meet the current business needs for the number of processable transactions and the number of processable query requests.

[0221] According to any implementation of the present application, the query optimization module includes:

[0222] The analysis start unit is used to start the inspection analysis function and obtain all the performance analysis data recorded in the current database session;

[0223] The cost determination unit is used to determine the performance cost of each located data query statement during execution according to the performance analysis data.

[0224] According to any embodiment of the present application, the execution plan includes: the query identifier, the query type, the table used, the matching partition information, the access type, the potential index, the actually used index and its length, the index matching object, the estimated number of read records, the filtered record ratio and additional execution information.

[0225] According to any implementation manner of the present application, the query optimization module analyzes the performance problem of each located data query statement respectively, specifically for:

[0226] According to the system architecture diagram of the database server, engine performance information, input and output information, memory usage information, table statistics information, index information and statement information of the database are determined respectively.

[0227] According to any implementation manner of the present application, when the execution optimization module optimizes the data query statement based on the index, it is specifically used to:

[0228] Creating an index for the field of the query condition whose usage frequency exceeds the first threshold;

[0229] Creating an index for the columns used for sorting and grouping whose usage frequency exceeds a second threshold;

[0230] Create indexes for conditional columns in data modification and data removal operations;

[0231] Create an index for a field that returns unique values.

[0232] When multiple fields are involved, create a joint index and place the most frequently used column at the leftmost side of the joint index.

[0233] According to any implementation manner of the present application, when the execution optimization module optimizes the data query statement based on the statement structure, it is specifically used to:

[0234] Use join operations or split the subquery into multiple queries;

[0235] Use indexes to perform sorting and grouping operations;

[0236] Place the filter condition in the query clause instead of the filter clause.

[0237] According to any implementation manner of the present application, when the execution optimization module optimizes the data query statement based on the table design structure, it is specifically used to:

[0238] The number of control connection tables shall not exceed three;

[0239] Create indexes for the fields involved in the join operation and ensure that the data types of the fields in different tables are consistent;

[0240] In the inner join operation, select the table with the small result set as the driving table;

[0241] In a left join operation, the smaller table is selected as the driving table and the larger table as the driven table.

[0242] According to any implementation manner of the present application, when the waiting optimization module optimizes the data query statement based on the parameters of the database server, it is specifically used to:

[0243] Set the buffer pool size parameter to the system memory to the first preset range to speed up the query while avoiding excessive use of operating system resources;

[0244] Adjust the storage engine thread concurrency parameter to a second preset range to limit the number of threads that can run simultaneously;

[0245] Setting the current maximum connection parameter to a third preset range according to the maximum number of connection errors in history to increase the maximum number of connections and avoid connection failures due to reaching the connection limit;

[0246] Set the number of open file handles parameter to the fourth preset range to limit the number of open file handles to ensure smooth database file operations.

[0247] According to any embodiment of the present application, it also includes an optimization deepening module, which is used to:

[0248] In response to being unable to continue optimizing the data query statement, the data is divided into multiple copies to different database servers through read-write separation or library and table sharding to reduce access pressure on a single database server.

[0249] In order to further illustrate the present solution, the present application also provides a specific application example of using the above-mentioned database performance optimization device to implement the database performance optimization method, see Fig. 9 , specifically including the following contents:

[0250] First, observe the server status to make sure that the server's hardware resources can meet the business scenario requirements. If not, increase the hardware resources to see if the performance problem can be solved. If increasing the hardware resources does not solve the problem or the hardware resources meet the requirements, enable slow query and collect SQL statements that exceed the scheduled time threshold.

[0251] After locating the slow SQL, analyze the cost of SQL execution through the show profile command, view the SQL execution plan through the EXPLAIN command, and analyze whether there are other performance issues through the Sys schema. If the SQL execution time is long, optimize from the three aspects of index, SQL statement and table structure design. If the SQL waiting time is long, tune the server parameters. If the analysis finds that the optimization has reached a bottleneck, it is necessary to optimize the deployment structure of the database, split the data into multiple copies through read-write separation or sharding, and put them on different database servers to reduce the access pressure on a single database server.

[0252] It should be noted that the virtual reality-based bank training system and training method thereof provided in the embodiment of the present invention can be used in the financial field, and can also be used in any technical field other than the financial field. The embodiment of the present invention does not limit the application field of the virtual reality-based bank training system and training method thereof.

[0253] From the hardware level, in order to significantly improve the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, the operating efficiency of the system and user experience are directly improved. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database. This application provides an embodiment of an electronic device for implementing all or part of the content of the database performance optimization method, and the electronic device specifically includes the following content:

[0254] Processor, memory, communication interface and bus; wherein the processor, memory and communication interface communicate with each other through the bus; the communication interface is used to realize information transmission between the database performance optimization device and the core business system, user terminal and related database and other related devices; the logic controller can be a desktop computer, a tablet computer and a mobile terminal, etc., but the present embodiment is not limited thereto. In the present embodiment, the logic controller can be implemented with reference to the embodiment of the database performance optimization method and the embodiment of the database performance optimization device in the embodiment, and the contents thereof are incorporated herein, and the repeated parts are not repeated.

[0255] It is understandable that the user terminal may include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Among them, the smart wearable device may include smart glasses, a smart watch, a smart bracelet, etc.

[0256] In practical applications, part of the database performance optimization method can be executed on the electronic device side as described above, or all operations can be completed in the client device. The selection can be made based on the processing capability of the client device and the limitations of the user's usage scenario. This application does not limit this. If all operations are completed in the client device, the client device may also include a processor.

[0257] The client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and other implementation scenarios may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster consisting of multiple servers, or a server structure of a distributed device.

[0258] Fig.10 FIG. 9 is a schematic block diagram of the system structure of the electronic device 9600 according to an embodiment of the present application. Fig.10 As shown, the electronic device 9600 may include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. It is worth noting that Fig.10 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.

[0259] In one embodiment, the database performance optimization method function may be integrated into the central processing unit 9100. The central processing unit 9100 may be configured to perform the following control:

[0260] Step S101: Acquire hardware resource configuration information of a database server, and determine whether the hardware resources meet current business requirements based on the configuration information.

[0261] Step S102: In response to the hardware resources meeting the current business requirements, data query statements exceeding a preset time threshold are located based on slow queries, and the execution cost, execution plan, and performance issues of each located data query statement are analyzed respectively.

[0262] Step S103: When the located data query statement has a long execution time problem, the data query statement is optimized based on indexes, statement structures, and table design structures.

[0263] Step S104: When the located data query statement has a long waiting time problem, the data query statement is optimized based on the parameters of the database server.

[0264] From the above description, it can be seen that the electronic device provided in the embodiment of the present application significantly improves the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database.

[0265] In another embodiment, the database performance optimization device may be configured separately from the central processing unit 9100. For example, the database performance optimization device may be configured as a chip connected to the central processing unit 9100, and the function of the database performance optimization method may be implemented through the control of the central processing unit.

[0266] like Fig.10 As shown, the electronic device 9600 may also include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily have to include Fig.10 In addition, the electronic device 9600 may also include Fig.10 For components not shown, reference may be made to the prior art.

[0267] like Fig.10 As shown, the central processing unit 9100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor device and / or logic device. The central processing unit 9100 receives input and controls the operation of various components of the electronic device 9600.

[0268] The memory 9140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 9100 may execute the program stored in the memory 9140 to implement information storage or processing, etc.

[0269] The input unit 9120 provides input to the central processing unit 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used to display display objects such as images and texts. The display may be, for example, an LCD display, but is not limited thereto.

[0270] The memory 9140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 9140 may also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 9600 through the central processor 9100.

[0271] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).

[0272] The communication module 9110 is a transmitter / receiver 9110 that sends and receives signals via an antenna 9111. The communication module (transmitter / receiver) 9110 is coupled to the central processor 9100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.

[0273] Based on different communication technologies, multiple communication modules 9110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless LAN module, etc. The communication module (transmitter / receiver) 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide an audio output via the speaker 9131 and receive an audio input from the microphone 9132, thereby realizing a common telecommunication function. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 9130 is also coupled to the central processor 9100, so that recording can be performed on the local machine through the microphone 9132, and the sound stored on the local machine can be played through the speaker 9131.

[0274] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the database performance optimization method in the above embodiments, where the execution subject is a server or a client. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, all the steps of the database performance optimization method in the above embodiments are implemented, where the execution subject is a server or a client. For example, when the processor executes the computer program, the following steps are implemented:

[0275] Step S101: Acquire hardware resource configuration information of a database server, and determine whether the hardware resources meet current business requirements based on the configuration information.

[0276] Step S102: In response to the hardware resources meeting the current business requirements, data query statements exceeding a preset time threshold are located based on slow queries, and the execution cost, execution plan, and performance issues of each located data query statement are analyzed respectively.

[0277] Step S103: When the located data query statement has a long execution time problem, the data query statement is optimized based on indexes, statement structures, and table design structures.

[0278] Step S104: When the located data query statement has a long waiting time problem, the data query statement is optimized based on the parameters of the database server.

[0279] From the above description, it can be seen that the computer-readable storage medium provided in the embodiment of the present application significantly improves the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database.

[0280] The embodiments of the present application also provide a computer program product capable of implementing all the steps of the database performance optimization method in the above embodiments, where the execution subject is a server or a client. When the computer program / instruction is executed by a processor, the steps of the database performance optimization method are implemented. For example, the computer program / instruction implements the following steps:

[0281] Step S101: Acquire hardware resource configuration information of a database server, and determine whether the hardware resources meet current business requirements based on the configuration information.

[0282] Step S102: In response to the hardware resources meeting the current business requirements, data query statements exceeding a preset time threshold are located based on slow queries, and the execution cost, execution plan, and performance issues of each located data query statement are analyzed respectively.

[0283] Step S103: When the located data query statement has a long execution time problem, the data query statement is optimized based on indexes, statement structures, and table design structures.

[0284] Step S104: When the located data query statement has a long waiting time problem, the data query statement is optimized based on the parameters of the database server.

[0285] From the above description, it can be seen that the computer program product provided in the embodiment of the present application significantly improves the response speed and processing efficiency of the database by optimizing indexes, adjusting query statements, improving table structure design, and fine-tuning server parameters, thereby directly improving the operating efficiency of the system and user experience. In addition, it can also help enterprises save costs and enhance the scalability and maintainability of the database.

[0286] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0287] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (apparatus), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. The computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0288] The computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0289] The computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0290] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A database performance optimization method, characterized in that: The method comprises: Obtaining hardware resource configuration information of the database server, and determining whether the hardware resources meet current business requirements based on the configuration information; In response to the hardware resources meeting the current business needs, locating data query statements that exceed a preset time threshold based on slow queries, and analyzing the execution cost, execution plan, and performance issues of each located data query statement; When the located data query statement has a long execution time problem, optimizing the data query statement based on indexes, statement structures, and table design structures; In the case where the located data query statement has a long waiting time problem, the data query statement is optimized based on the parameters of the database server.

2. The database performance optimization method according to claim 1, characterized in that: The obtaining of hardware resource configuration information of the database server and determining whether the hardware resources meet current business requirements according to the configuration information include: Determine whether the hardware resource configuration information of the CPU and memory of the database server meets the requirements of the number of transactions that can be processed and the number of query requests that can be processed for the current business; In response to the hardware resource configuration information of the CPU and memory satisfying the processable transaction quantity requirement and processable query request quantity requirement of the current business currently or after the hardware resources are increased, it is determined that the hardware resources meet the current business requirements.

3. The database performance optimization method according to claim 1, characterized in that: The step of analyzing the execution cost of each located data query statement includes: Enable the inspection analysis function and obtain all the performance analysis data recorded in the current database session; The performance overhead of each located data query statement during execution is determined according to the performance analysis data.

4. The database performance optimization method according to claim 1, characterized in that: The execution plan includes: The query identifier, query type, used tables, matching partition information, access type, potential indexes, actual used indexes and their lengths, index matching objects, estimated number of records to read, percentage of records after filtering, and additional execution information.

5. The database performance optimization method according to claim 1, characterized in that: The performance problem of each located data query statement is analyzed separately, including: According to the system architecture diagram of the database server, engine performance information, input and output information, memory usage information, table statistics information, index information and statement information of the database are determined respectively.

6. The database performance optimization method according to claim 1, characterized in that: The optimizing the data query statement based on the index includes: Creating an index for the field of the query condition whose usage frequency exceeds the first threshold; Creating an index for the columns used for sorting and grouping whose usage frequency exceeds a second threshold; Create indexes for conditional columns in data modification and data removal operations; Create an index for a field that returns unique values. When multiple fields are involved, create a joint index and place the most frequently used column at the leftmost side of the joint index.

7. The database performance optimization method according to claim 1, characterized in that: The optimizing the data query statement based on the statement structure includes: Use join operations or split the subquery into multiple queries; Use indexes to perform sorting and grouping operations; Place the filter condition in the query clause instead of the filter clause.

8. The database performance optimization method according to claim 1, characterized in that: The optimizing the data query statement based on the table design structure includes: The number of control connection tables shall not exceed three; Create indexes for the fields involved in the join operation and ensure that the data types of the fields in different tables are consistent; In the inner join operation, select the table with the small result set as the driving table; In a left join operation, the smaller table is selected as the driving table and the larger table as the driven table.

9. The database performance optimization method according to claim 1, characterized in that: The optimizing the data query statement based on the parameters of the database server includes: Set the buffer pool size parameter to the system memory to the first preset range to speed up the query while avoiding excessive use of operating system resources; Adjust the storage engine thread concurrency parameter to a second preset range to limit the number of threads that can run simultaneously; Setting the current maximum connection parameter to a third preset range according to the maximum number of connection errors in history to increase the maximum number of connections and avoid connection failures due to reaching the connection limit; Set the number of open file handles parameter to the fourth preset range to limit the number of open file handles to ensure smooth database file operations.

10. The database performance optimization method according to claim 1, characterized in that: Also includes: In response to being unable to continue optimizing the data query statement, the data is divided into multiple copies to different database servers through read-write separation or library and table sharding to reduce access pressure on a single database server.

11. A database performance optimization device, characterized in that: The device comprises: The hardware detection module is used to obtain the hardware resource configuration information of the database server and determine whether the hardware resources meet the current business requirements according to the configuration information; The query optimization module is used to: in response to the hardware resources meeting the current business needs, locate the data query statements that exceed the preset time threshold based on the slow query, and analyze the execution cost, execution plan and performance problem of each located data query statement respectively; An execution optimization module is used to: optimize the data query statement based on the index, statement structure and table design structure when the located data query statement has a problem of long execution time; The waiting optimization module is used to optimize the data query statement based on the parameters of the database server when the located data query statement has a long waiting time problem.

12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the database performance optimization method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the database performance optimization method described in any one of claims 1 to 10 are implemented.

14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the database performance optimization method described in any one of claims 1 to 10 are implemented.

Citation Information

Patent Citations

  • MySQL database tuning device and method, terminal and storage medium

    CN115048360A

  • Optimization processing method and device for SQL database, intelligent terminal and medium

    CN115237947A

  • Database optimization based on forecasting hardware statistics using data mining techniques

    US20180218038A1

Cited By

  • Index warehouse segmentation strategy-based query method, device and medium

    CN118760703A

  • Database optimization method and device, equipment and storage medium

    CN119003492A

  • Database response time testing method and device, equipment and medium

    CN119473827A

  • SQL statement optimization method and system, electronic equipment and storage equipment

    CN119719132A

  • A method and system for optimizing SQL statements, an electronic device, and a storage device.

    CN119719132B