Database read-write performance optimization method and device, equipment and storage medium
By identifying abnormal objects in the database for optimization based on statistical dimensions and read and write performance indicators, the problem of insufficient accuracy and reliability of database read and write performance optimization in the existing technology is solved, and the optimization efficiency and stability of database performance are significantly improved. .
Patent Information
- Application Number
- CN202410627370.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-08-27
AI Technical Summary
The accuracy and limited reliability of database read and write performance optimization in the existing technology are mainly due to the reliance on manual observation and empirical judgment, resulting in insufficient accuracy in identifying the causes of abnormal read and write performance.
By collecting read and write data during database operation based on predetermined statistical dimensions, the read and write performance indicators of each statistical dimension are determined, and abnormal objects are identified from database objects based on these indicators for optimization processing to refine the database read and write performance. Analyze granularity to improve the accuracy and reliability of optimization.
It significantly improves the accuracy and efficiency of database read and write performance optimization, and can accurately identify the specific objects that cause abnormal read and write performance, so as to carry out targeted optimization and improve the overall performance of the database.
Smart Images

Figure CN118550893A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of database management, and in particular to a method, device, equipment and storage medium for optimizing database read and write performance. Background Art
[0002] In the database, instructions and data are frequently read and written. Therefore, the performance of the database server in executing read and write operations is extremely critical to the overall performance of the database server. When the read and write performance of the database server is insufficient, targeted optimization processing is required.
[0003] In the related art, the method for optimizing the read and write performance of the database server is mainly to use the read and write statistics tool provided by the operating system to count the read and write information of the disk or the process in the disk, and then manually observe the read and write performance, which is insufficient in accuracy and limited in reliability. Summary of the invention
[0004] The present disclosure provides a database read-write performance optimization method, device, equipment and storage medium to solve the problems of insufficient accuracy and limited reliability of database read-write performance optimization processing in related technologies.
[0005] In a first aspect, the present disclosure provides a method for optimizing database read and write performance, the method comprising:
[0006] Based on the predetermined statistical dimensions, the read and write data generated during the operation of the target database are collected, and the target database includes database objects;
[0007] Based on the read and write data, determine the read and write performance indicators of the target database server for each statistical dimension;
[0008] Based on the read and write performance indicators, target objects with abnormalities are determined from database objects, and the target objects are optimized to optimize the read and write performance of the target database.
[0009] Optionally, the statistical dimension includes a subject dimension and an object dimension. Based on the predetermined statistical dimension, the read and write data generated during the operation of the target database is collected, including: combining all subject dimensions and all object dimensions as the primary key of the read and write data, wherein the subject dimension is used to represent the dimension corresponding to the database object that initiates the read and write operation, and the object dimension is used to represent the dimension corresponding to the database object that performs the read and write operation; based on the primary key, the read and write data is collected.
[0010] Optionally, the subject dimension includes: database process name, database module name, database application name, execution statement identifier; the object dimension includes: database name, table space name, relationship table name, file name and file type; the read and write performance indicators include: number of read and write bytes, number of read and write times, read time, and write time.
[0011] Optionally, the read and write performance indicators include indicator values and indicator percentage values. Based on the read and write data, the read and write performance indicators of the target database server in each statistical dimension are determined, including: based on the statistical dimension, determining the indicator values in the read and write performance indicators corresponding to the database object; based on all indicator values corresponding to the read and write performance indicators under the same statistical dimension, determining the indicator percentage value corresponding to each database object.
[0012] Optionally, based on the read-write performance indicators, target objects with abnormalities are determined from database objects, and the target objects are optimized to optimize the read-write performance of the target database, including: based on set time indicator thresholds and read time and write time in the read-write performance indicators, determining that the read-write performance of the target database is in an abnormal state; based on the read-write performance indicators of the database objects, determining target objects with abnormalities; and optimizing the target objects to optimize the read-write performance of the target database.
[0013] Optionally, based on a set time indicator threshold and the reading time and writing time in the read-write performance indicators, it is determined that the read-write performance of the target database is in an abnormal state, including: determining the sum of all reading times and writing times in the read-write performance indicators in the read-write data as the read-write time corresponding to the target database; determining the sum of the processing time of all execution statements in the target database as the running time of the target database; if the ratio of the read-write time to the running time is greater than the set time indicator threshold, it is determined that the read-write performance of the target database is in an abnormal state.
[0014] Optionally, the database object includes a subject object and an object object, and based on the read and write performance indicators of the database object, determining the target object with an abnormality includes: based on the read and write performance indicators of the database object, determining the subject object whose indicator percentage value in the read and write performance indicators exceeds a first set indicator threshold as an abnormal subject object; based on the read and write performance indicators of the database object, determining the object object whose indicator percentage value in the read and write performance indicators exceeds a second set indicator threshold as an abnormal object object; combining the first statistical dimension to which the abnormal subject object belongs and the second statistical dimension to which the abnormal object object belongs as the target statistical dimension; based on the target statistical dimension, determining at least one database object with the highest indicator percentage value in the read and write performance indicators as the target object.
[0015] In a second aspect, the present disclosure provides a database read-write performance optimization device, the database read-write performance optimization device comprising:
[0016] A collection module, used to collect read and write data generated during the operation of a target database based on a predetermined statistical dimension, where the target database includes database objects;
[0017] A processing module, configured to determine the read and write performance index of the target database server in each statistical dimension based on the read and write data;
[0018] The optimization module is used to determine the target object with abnormality from the database objects based on the read-write performance index, and optimize the target object to optimize the read-write performance of the target database.
[0019] Optionally, the collection module is specifically used to, if the statistical dimension includes a subject dimension and an object dimension, combine all the subject dimensions and all the object dimensions as the primary key of the read and write data, wherein the subject dimension is used to represent the dimension corresponding to the database object that initiates the read and write operation, and the object dimension is used to represent the dimension corresponding to the database object that performs the read and write operation; based on the primary key, collect the read and write data.
[0020] Optionally, the acquisition module specifically includes: subject dimensions include: database process name, database module name, database application name, execution statement identifier; object dimensions include: database name, table space name, relationship table name, file name and file type; read and write performance indicators include: number of read and write bytes, number of read and write times, read time, and write time.
[0021] Optionally, the processing module is specifically used to, if the read-write performance indicator includes an indicator value and an indicator percentage value, determine the indicator value in the read-write performance indicator corresponding to the database object based on the statistical dimension; and determine the indicator percentage value corresponding to each database object based on all indicator values corresponding to the read-write performance indicator under the same statistical dimension.
[0022] Optionally, the optimization module is specifically used to determine that the read and write performance of the target database is in an abnormal state based on the set time indicator threshold and the reading time and writing time in the read and write performance indicators; determine the target object with abnormalities based on the read and write performance indicators of the database object; and optimize the target object to optimize the read and write performance of the target database.
[0023] Optionally, the optimization module is specifically used to determine the sum of all read times and write times in the read and write performance indicators in the read and write data as the read and write time corresponding to the target database; determine the sum of the processing time of all execution statements in the target database as the running time of the target database; if the ratio of the read and write time to the running time is greater than the set time indicator threshold, it is determined that the read and write performance of the target database is in an abnormal state.
[0024] Optionally, the optimization module is specifically used to, if the database object includes a subject object and an object object, based on the read and write performance indicators of the database object, determine the subject object whose indicator percentage value in the read and write performance indicators exceeds a first set indicator threshold as an abnormal subject object; based on the read and write performance indicators of the database object, determine the object object whose indicator percentage value in the read and write performance indicators exceeds a second set indicator threshold as an abnormal object object; combine the first statistical dimension to which the abnormal subject object belongs and the second statistical dimension to which the abnormal object object belongs as the target statistical dimension; based on the target statistical dimension, determine at least one database object with the highest indicator percentage value in the read and write performance indicators as the target object.
[0025] In a third aspect, the present disclosure further provides a control device, the control device comprising:
[0026] at least one processor;
[0027] and a memory communicatively coupled to the at least one processor;
[0028] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor to enable the control device to execute a database read and write performance optimization method corresponding to any embodiment in the first aspect of the present disclosure.
[0029] In a fourth aspect, the present disclosure further provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement any database read and write performance optimization method as described in the first aspect of the present disclosure.
[0030] In a fifth aspect, the present disclosure further provides a computer program product, which includes computer execution instructions, which, when executed by a processor, are used to implement any database read and write performance optimization method as described in the first aspect of the present disclosure.
[0031] The database read-write performance optimization method, device, equipment and storage medium provided by the present disclosure collects the read-write data generated during the operation of the target database based on a predetermined statistical dimension, then determines the read-write performance index of the target database server of each statistical dimension based on the read-write data, and then determines the target object with abnormalities from the database objects based on the read-write performance index, and optimizes the target object to optimize the read-write performance of the target database. Thus, the optimization of the database read-write performance can be refined to the level of specific dimensions and specific database objects, and through the combination of statistical dimensions and read-write performance indicators, it is convenient to find out the specific database objects that cause abnormal read-write performance, thereby facilitating performance tuning, and improving the efficiency of database performance optimization, thereby improving database performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0033] Figure 1 An application scenario diagram of the database read and write performance optimization method provided in the embodiment of the present disclosure;
[0034] Figure 2 A flowchart of a method for optimizing database read and write performance provided by an embodiment of the present disclosure;
[0035] Figure 3a A flowchart of a method for optimizing database read and write performance provided by another embodiment of the present disclosure;
[0036] Figure 3b for Figure 3a A flow chart of a method for determining that the read and write performance of a target database is in an abnormal state provided by the illustrated embodiment;
[0037] Figure 3c for Figure 3a A flow chart of a method for determining a target object provided by the illustrated embodiment;
[0038] Figure 4 A schematic diagram of the structure of a database read and write performance optimization device provided by another embodiment of the present disclosure;
[0039] Figure 5 A schematic diagram of the structure of a control device provided in yet another embodiment of the present disclosure.
[0040] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0041] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0042] The technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.
[0043] In the database, instructions and data are frequently read and written, such as writing form data to the database or reading data from a form in the database. Therefore, the performance of the database server in executing read and write operations is extremely critical to the overall performance of the database server. When the read and write performance of the database server is insufficient, such as the time spent processing write commands or read commands is too long, it is necessary to optimize the read and write performance in a targeted manner.
[0044] In the related art, the method for optimizing the read and write performance of a database server is mainly to obtain information such as the number of read and write times and the overall time consumption of the disk or the process in the disk through the read and write statistics tools provided by the operating system. This information is then manually observed, and based on experience, it is determined whether the read and write performance is abnormal. The accuracy of the analysis of the causes of abnormal read and write performance is insufficient, which in turn limits the reliability of optimizing the read and write performance.
[0045] In order to solve the above problems, the embodiments of the present disclosure provide a method for optimizing database read and write performance, which refines the granularity of database read and write performance analysis according to set statistical dimensions and read and write performance indicators, accurately determines objects with abnormalities, and optimizes them in a targeted manner. Thus, the accuracy of database read and write performance optimization is significantly improved, thereby effectively improving the overall performance of the database.
[0046] The application scenarios of the embodiments of the present disclosure are explained below:
[0047] Figure 1 This is an application scenario diagram of the database read and write performance optimization method provided by the embodiment of the present disclosure. Figure 1 As shown, in the process of optimizing database read and write performance, the database server 100 collects read and write data 110 related to read and write operations, analyzes the causes of abnormal read and write performance, and performs optimization processing, thereby completing the read and write performance optimization.
[0048] It should be noted that Figure 1 In the scenario shown, only one database server and one read-write data are used as an example for illustration, but the present disclosure is not limited thereto, that is, the number of database servers and read-write data can be arbitrary.
[0049] The following describes in detail the database read and write performance optimization method provided by the present disclosure through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0050] Figure 2 This is a flowchart of a method for optimizing database read and write performance provided by an embodiment of the present disclosure. Figure 2 As shown, the following steps are included:
[0051] Step S201: Based on a predetermined statistical dimension, the read and write data generated during the operation of the target database is collected.
[0052] The target database includes database objects.
[0053] Specifically, different statistical dimensions are determined in advance so as to reflect the characteristics of each database object in the target database related to the read and write operations from each dimension. Database objects include data forms, cells in forms, databases, form rows, and the like.
[0054] In order to ensure the granularity of the acquired read and write data, you can usually select multiple statistical dimensions to be combined as the primary key for collecting read and write data. For example, dimensions such as the account that initiated the read and write operation, the file type corresponding to the read and write operation, the corresponding database name, and the corresponding form name are included. Then, based on the primary key, the read and write data generated during the operation of the target database are collected in real time.
[0055] Compared with the related art that only counts the number of read and write times and time-consuming information without considering the statistical dimension issue, by combining multiple statistical dimensions, the granularity of the acquired read and write data can be significantly refined to accurately analyze the causes of abnormal read and write performance.
[0056] Step S202: Based on the read and write data, determine the read and write performance indicators of the target database server in each statistical dimension.
[0057] Specifically, the read and write performance indicators include the number of read and write operations, the time taken for the read and write operations, and other indicators.
[0058] By counting the read and write data corresponding to the primary key, the corresponding read and write performance indicators (that is, the read and write performance indicators corresponding to each primary key, such as) can be calculated according to the primary key. Based on the calculated read and write performance indicators, the read and write performance indicators corresponding to each statistical dimension can be further determined.
[0059] For example, for the read and write data whose primary key is initiating account + database name + form name, the read and write performance indicators corresponding to the same "initiating account + database name + form name" can be calculated, and then the read and write performance indicators can be merged according to the "database name" dimension through filtering (that is, the read and write performance indicators with the same "database name" are merged) to determine the read and write performance indicators corresponding to the "database name" dimension.
[0060] Step S203: Based on the read-write performance index, determine the target object with abnormality from the database objects, and optimize the target object to optimize the read-write performance of the target database.
[0061] Specifically, through the read and write performance indicators of various statistical dimensions, we can identify abnormal database objects. For example, if the reading and writing time of a form is long, we can use it as a target object for optimization. By combining the read and write performance indicators of multiple statistical dimensions, we can maximize the accuracy and reliability of abnormal database object detection, ensure that we find the target object that causes abnormal database read and write performance, and significantly improve the efficiency and accuracy of database read and write performance fault detection.
[0062] The database read-write performance optimization method provided by the embodiment of the present disclosure collects the read-write data generated during the operation of the target database based on a predetermined statistical dimension, then determines the read-write performance index of the target database server of each statistical dimension based on the read-write data, and then determines the target object with abnormalities from the database objects based on the read-write performance index, and optimizes the target object to optimize the read-write performance of the target database. Thus, the optimization of the database read-write performance can be refined to the level of specific dimensions and specific database objects, and through the combination of statistical dimensions and read-write performance indicators, it is convenient to find out the database objects that specifically cause abnormal read-write performance, thereby facilitating performance tuning, and improving the efficiency of database performance optimization, thereby improving database performance.
[0063] Figure 3a The following is a flowchart of a method for optimizing database read and write performance provided by the present disclosure. Figure 3a As shown, the database read and write performance optimization method provided in this embodiment includes the following steps:
[0064] Step S301: Combine all subject dimensions and all object dimensions as the primary key for reading and writing data.
[0065] Among them, the subject dimension is used to represent the dimension corresponding to the database object that initiates the read and write operations, and the object dimension is used to represent the dimension corresponding to the database object that performs the read and write operations.
[0066] Specifically, when collecting read and write data of a database, it is necessary to first determine the collected primary key so as to record the collected read and write data based on the primary key.
[0067] The primary key is determined according to the required statistical dimensions. The statistical dimensions include subject dimension and object dimension. The subject refers to who (database object) initiates the read and write operation (that is, the request subject), such as database process, database module, database application, SQL statement, etc. Therefore, the corresponding subject dimension can be database process name, database module name, database application name, SQL statement identifier, etc.; the object refers to which database objects the read and write operations occur on (that is, the occurrence object), such as database, table space, relational table, file, therefore, the corresponding object dimension can be database name, table space name, relational table name, file name and file type.
[0068] The combination of the above statistical dimensions can be used as the primary key for read and write data to ensure the granularity of collection and the comprehensiveness of analysis based on the collected read and write data.
[0069] Step S302: Collect read and write data based on the primary key.
[0070] Specifically, based on the determined primary key, read and write data can be collected.
[0071] When a read or write operation is performed in the database, a cumulative statistical method is used to obtain the read or write data based on the number of read or write operations corresponding to the primary key record, the amount of data involved in the read or write operation, the time when the read or write operation occurs, and the duration of the read or write operation. Cumulative statistics means that each time a new read or write operation is received, the primary keys corresponding to the read or write operations are compared to see if they are the same. If they are the same (for example, both are write operations of the data written by the A database application to the same column in the B table, then the primary keys will be the same), then the statistical values are accumulated, otherwise new statistical items are added to the statistical table.
[0072] Step S303: Based on the statistical dimension, determine the indicator value in the read and write performance indicator corresponding to the database object.
[0073] Specifically, to facilitate reading and analysis, corresponding read-write performance indicator data will be extracted based on the read-write data, so as to analyze the read-write performance of database objects in each statistical dimension in a targeted manner based on the aforementioned statistical dimensions (the difference between read-write data and read-write performance indicator data is that read-write data includes the primary key and the corresponding collected data, such as the occurrence time of each collected read-write operation, while the read-write performance indicator is only obtained based on part of the data in the read-write data).
[0074] The read / write performance index can be configured according to the analysis requirements, such as read / write frequency, read / write times, read / write duration, etc. In this embodiment, for the convenience of description, the number of read / write bytes, read / write times, read time, and write time are used as read / write performance indicators, through which the frequency and scale of read / write operations can be known.
[0075] Step S304: Based on all indicator values corresponding to the read and write performance indicators under the same statistical dimension, determine the indicator percentage value corresponding to each database object.
[0076] Specifically, the values of the read-write performance indicators include the indicator values and the indicator percentage values. By calculating the indicator values and the corresponding percentage values respectively, it is convenient to determine abnormal read-write performance indicators (such as read-write performance indicators with extreme indicator percentage distribution relationships may be abnormal read-write performance indicators) and corresponding database objects (such as database objects with excessively high indicator percentages) based on the indicator percentage values.
[0077] In practical applications, the obtained read and write performance indicators can be visualized according to the subject dimension and the object dimension respectively (such as the percentage chart of each database object under a certain dimension indicator), so that maintenance personnel can quickly identify abnormal database objects based on these images.
[0078] Optionally, the read / write performance indicator images of various statistical dimensions and the collected read / write data may be used as a read / write performance analysis model of the target database, so as to comprehensively analyze the read / write performance of the target database through the model.
[0079] For example, each view in the read-write performance analysis model can be recorded as "sys_stat_xxx_io", where sys_stat is used to represent the data collected in the database system, io is used to represent the attempt to correspond to the read-write performance, and xxx is used to represent that a certain dimension is the primary key. The corresponding number of bytes of the read and write operations (recorded as the number of IO bytes), the number of read and write operations (recorded as the number of IO times), the read and write time (i.e., the read time and the write time, respectively recorded as the IO read time and the IO write time) and their percentages are displayed as read-write performance indicators, as shown in the following table:
[0080] Table 1 Single-dimensional read-write performance index table in the read-write performance analysis model
[0081]
[0082] The total table (also called the sys_stat_io basic table) is obtained by sorting the read and write data collected based on the primary key, and then the total number of bytes, total IO times, total read IO time, and total write time are calculated (for convenience, the total values in the above table are expressed as 1 million or 1 million, but the actual values should be calculated based on the actual situation). Then, based on the statistics of the sys_stat_io basic table, group queries are performed by dimension statistical values (such as using the group by command) to calculate the IO statistics and percentages of the statistical items of each dimension.
[0083] In this way, the total IO statistics can be displayed in statistical charts of multiple dimensions. Under each dimension, the read and write performance indicator information such as the number of IO bytes, IO times, IO read and write time and percentage of each statistical item (that is, database object) under the dimension can be known.
[0084] Step S305: Based on the set time indicator threshold and the read time and write time in the read and write performance indicators, determine that the read and write performance of the target database is in an abnormal state.
[0085] Specifically, after obtaining the read / write performance index data, it is possible to determine whether the read / write performance of the target database is abnormal as a whole. By comparing the predetermined index threshold with the corresponding read / write performance index, it is determined whether the index data in a certain dimension is abnormal.
[0086] When the overall read and write performance of the target database is abnormal, it must be that the total time to process the read and write operations is too long (that is, the read and write operations are abnormally time-consuming). Therefore, by judging the read time and write time in the read and write performance indicators and the corresponding indicators, it can be determined whether there is an abnormal read and write operation time consumption.
[0087] Furthermore, if Figure 3b As shown, it is a flow chart of a method for determining that the read and write performance of a target database is in an abnormal state, which specifically includes the following steps:
[0088] Step S3051: The sum of all read times and write times in the read / write performance indicators in the read / write data is determined as the read / write time corresponding to the target database.
[0089] Specifically, by reading and writing data, the total read and write time can be calculated, that is, based on the statistical primary key, all read times and write times are added together to obtain the read and write time corresponding to the target database.
[0090] Step S3052: The sum of the processing time of all executed statements in the target database is determined as the running time of the target database.
[0091] Specifically, the running time of the target database, also known as database time, is the total time consumed by the database server (or database client) session process to execute SQL tasks. The database time can be obtained by accumulating the time of all client session processes to execute SQL statements (that is, execute statements). Related database systems all provide query functions for querying the running time or the total time consumed by executing statements.
[0092] Step S3053: If the ratio of the read / write time to the running time is greater than the set time indicator threshold, it is determined that the read / write performance of the target database is in an abnormal state.
[0093] Specifically, by dividing the read and write time by the database time (that is, the running time), a percentage value is obtained, which can be used for comparison with a relevant threshold (that is, a set time indicator threshold, which can be configured in the database configuration parameter file, such as 5%), and it is considered that the target database has a read and write performance problem and needs further analysis. Otherwise, it can be considered that there is no problem.
[0094] Step S306: Determine the target object with abnormality based on the read and write performance indicators of the database object.
[0095] Specifically, after determining that the target database has a read / write performance problem, the target object with the abnormality can be further determined based on the read / write performance indicators.
[0096] Furthermore, if Figure 3c As shown, it is a flow chart of a method for determining a target object, which specifically includes the following steps:
[0097] Step S3061: Based on the read and write performance indicators of the database object, a subject object whose indicator percentage value in the read and write performance indicator exceeds a first set indicator threshold is determined as an abnormal subject object.
[0098] Specifically, according to the different subject dimensions and object dimensions of the statistical dimensions, the database objects in the corresponding statistical data are subject objects and object objects respectively. Therefore, the analysis can be performed based on the subject dimension and the object dimension respectively.
[0099] For the subject dimension, the read and write performance indicator data corresponding to each subject dimension can be traversed in turn (if done manually, the corresponding view can be traversed) to find the item with the highest percentage of read and write time (and can be compared with the corresponding threshold for further judgment. Depending on the indicator, the corresponding threshold is different. In this step, the various thresholds corresponding to the subject dimension are collectively referred to as the first set indicator threshold) as the abnormal subject object.
[0100] For example, the maintenance personnel can find out the items with the highest percentage of read and write performance indicators by traversing all the views of the subject dimension. For example, it is found that in the sys_stat_sql_io data table, the IO read time, IO write time and IO number percentage of the database object with the identifier e2xfef2 are all the highest, each accounting for 60.00%. It can be considered that the read and write I / O time of writing the database object consumes the most I / O time, as shown in the following Table 2:
[0101] Table 2 Read and write performance indicators for determining the subject dimension of abnormal subject objects
[0102]
[0103] Step S3062: Based on the read and write performance indicators of the database object, an object whose indicator percentage value in the read and write performance indicator exceeds a second set indicator threshold is determined as an abnormal object object.
[0104] Specifically, similarly, by traversing the read and write performance indicator data of all object dimensions (similarly, when performed manually, it can also be achieved by traversing the corresponding views), find out the item with the highest percentage of read and write time (and can be compared with the corresponding threshold for further judgment. Depending on the indicator, the corresponding threshold is different. In this step, the various thresholds corresponding to the object dimension are collectively referred to as the second set indicator threshold) as the abnormal object object.
[0105] Exemplarily, the read / write performance optimization program based on the method provided in the embodiment of the present disclosure can automatically traverse the read / write performance indicator data of all I / O object dimensions, and find out the items with the highest percentage of I / O read / write time. For example, it is found that the I / O read time and IO write time of the Temp Buffer File item in sys_stat_filetype_io (i.e., the statistical table of read / write performance indicators of the data type dimension) have the highest proportion, each accounting for 50%, as shown in the following table:
[0106] Table 3 Reading and writing performance indicators of object dimensions used to determine abnormal object objects
[0107]
[0108] Temp Buffer File is used to indicate a temporary buffer file, which is usually a temporary file used for sorting operations when the working memory (corresponding to work_mem in English) is insufficient when sorting data within an SQL execution statement.
[0109] Step S3063: Combine the first statistical dimension to which the abnormal subject object belongs and the second statistical dimension to which the abnormal object object belongs as the target statistical dimension.
[0110] Specifically, through the above two steps, the object dimension and subject dimension corresponding to the abnormal database object can be determined, but the abnormal database object itself cannot be directly determined through the above two dimensions. Therefore, it is necessary to combine the dimensions determined in the above steps (that is, combine the first statistical dimension to which the abnormal subject object belongs and the second statistical dimension to which the abnormal object object belongs, as the target statistical dimension) to determine the abnormal database object under this dimension as the target object.
[0111] Step S3064: Based on the target statistical dimension, at least one database object having the highest indicator percentage value in the read / write performance indicator is determined as the target object.
[0112] Specifically, after determining the target statistical dimension, the database object having the highest indicator percentage value in the read and write performance indicators in the target statistical dimension can be determined as the target object.
[0113] Exemplarily, through the aforementioned steps, the combination of dimensions corresponding to the two tables sys_stat_sql_io (SQL statement dimension) and sys_stat_filetype_io (file type dimension) has been determined as the target statistical dimension. At this time, the combination of sys_stat_sql_io and sys_stat_filetype_io can be realized through a joint query command (Join command in the SQL statement) to further determine the target object. The obtained read and write performance indicator data is shown in the following table:
[0114] Table 4 Reading and writing performance indicators of object dimensions used to determine abnormal object objects
[0115]
[0116] From the above table, we can further determine that the file types involved in the reading and writing processing of the SQL statement e2xfef2 are mainly Temp Buffer File (50.00%), followed by Stats File (10.00%), and then Stats File statistics file (5.00%). Obviously, the time-consuming SQL statement for Temp Buffer File is the main reason for the insufficient reading and writing performance of the database table. Therefore, it can be determined that the target object is the statement e2xfef2 for Temp Buffer File.
[0117] Furthermore, if the database object stored in the read / write data is an identification code of an actual database object (ie, the SQL ID in the above example), the corresponding database object stored in the database may be determined based on the identification code as the target object.
[0118] For example, based on the above SQL ID, the corresponding SQL statement can be determined through the dynamic performance view query function as follows:
[0119] select*from od,ct where od.o_id=ct.c_id order by ct.c_id;
[0120] The corresponding statements are pushed to maintenance personnel so that they can easily determine the cause of abnormal read and write performance of the database system and perform targeted optimization processing.
[0121] Furthermore, after determining the target object, the execution information corresponding to the target object can also be obtained, the execution information including the call information of the database element corresponding to the target object and the storage call information corresponding to the target object, so that the maintenance personnel can determine the optimization method of the target object accordingly.
[0122] For example, for the SQL statement of the target object determined in the aforementioned example, its corresponding execution information can be automatically obtained, including the number of calls of the database elements involved (the two forms od and ct) (for example, the query results are 700,000 and 341,000 respectively), and its corresponding storage information (for example, the system configured memory work_mem is the default value of 4MB, and the required storage size of the external disk sequence corresponding to the execution plan of the SQL statement is 20MB).
[0123] Therefore, the maintenance personnel can determine that the reason why the target object takes a long time is that the memory cannot meet its storage requirements, resulting in a long read and write operation and a large number of calls. Therefore, the memory allocated for the SQL statement can be directly modified to 20MB to complete the performance tuning process.
[0124] In some embodiments, if there are at least two database objects with the highest percentage values of the index in the read / write performance index in the target statistical dimension, these database objects can be determined as target objects. Because there may be more than one reason for abnormal database read / write performance, there may be multiple target objects that need to be optimized.
[0125] Step S307: Optimize the target object to optimize the read and write performance of the target database.
[0126] Specifically, based on the target object determined in the aforementioned steps and its related execution information, the target object can be conveniently optimized to optimize the read and write performance of the target database as a whole.
[0127] For example, as analyzed in the above example, there is a performance problem of high IO time consumption in Temp Buffer File in the target database. The problem is mainly caused by the SQL statement with SQL ID e2xfef2. When executing the query, it uses about 20MB of working memory, which is much higher than the 4MB set by the database.
[0128] The optimization method for this is to set work_mem to 20MB.
[0129] Furthermore, after the optimization process, the load test can be re-executed in the target database, and the read and write data can be collected to determine whether the read and write performance of the target database is in an abnormal state. If the read and write performance of the target database is not in an abnormal state, the optimization is completed. If it is still in an abnormal state, repeat the above steps to continue the targeted optimization.
[0130] Specifically, as in the previous example, after collecting read and write data again and calculating the read and write performance indicators, you can view statistics by file type. At this time, you will find that there is only read and write IO of Stats File under the target statistical dimension, and the total number of IO bytes is reduced from 1 million to 100,000, and the total IO time is reduced from 200 seconds to 20 seconds (further optimization can be performed at this time. The principle is similar to optimizing the Temp Buffer File problem and will not be repeated here).
[0131] At the same time, the ratio of read and write time to running time is less than 1%, and the read and write performance is no longer a performance bottleneck, thereby achieving the purpose of optimizing IO performance.
[0132] The database read-write performance optimization method provided by the embodiment of the present disclosure combines all subject dimensions and all object dimensions as the primary key of the read-write data, then based on the primary key, collects the read-write data, and based on the statistical dimension, determines the indicator value and indicator percentage value in the read-write performance indicator corresponding to the database object, so as to determine that the read-write performance of the target database is in an abnormal state, and then determines the target object with abnormality based on the read-write performance indicator of the database object, and optimizes the read-write performance of the target database by optimizing the target object. In this way, it is possible to realize the automatic judgment of whether the database read-write performance is abnormal, and can quickly determine the target object that causes the abnormal database read-write performance, and optimize the read-write performance of the target database by optimizing it, so as to significantly improve the fault location efficiency and optimization efficiency of the database read-write performance, thereby improving the stability and reliability of the database performance.
[0133] Figure 4 The schematic diagram of the structure of a database read and write performance optimization device provided by the present disclosure is as follows. Figure 4As shown, the database read-write performance optimization device 400 includes: a collection module 410, a processing module 420 and an optimization module 430. Among them:
[0134] The collection module 410 is used to collect the read and write data generated during the operation of the target database based on a predetermined statistical dimension, and the target database includes database objects;
[0135] A processing module 420 is used to determine the read and write performance index of the target database server in each statistical dimension based on the read and write data;
[0136] The optimization module 430 is used to determine the target object with abnormality from the database objects based on the read-write performance index, and optimize the target object to optimize the read-write performance of the target database.
[0137] Optionally, the collection module 410 is specifically used to, if the statistical dimension includes a subject dimension and an object dimension, combine all the subject dimensions and all the object dimensions as the primary key of the read and write data, wherein the subject dimension is used to represent the dimension corresponding to the database object that initiates the read and write operation, and the object dimension is used to represent the dimension corresponding to the database object that performs the read and write operation; based on the primary key, collect the read and write data.
[0138] Optionally, the acquisition module 410 specifically includes: the subject dimension includes: database process name, database module name, database application name, execution statement identifier; the object dimension includes: database name, table space name, relationship table name, file name and file type; the read and write performance indicators include: number of read and write bytes, number of read and write times, read time, and write time.
[0139] Optionally, the processing module 420 is specifically used to, if the read-write performance indicator includes an indicator value and an indicator percentage value, determine the indicator value in the read-write performance indicator corresponding to the database object based on the statistical dimension; and determine the indicator percentage value corresponding to each database object based on all indicator values corresponding to the read-write performance indicator under the same statistical dimension.
[0140] Optionally, the optimization module 430 is specifically used to determine that the read and write performance of the target database is in an abnormal state based on the set time indicator threshold and the reading time and writing time in the read and write performance indicators; determine the target object with abnormalities based on the read and write performance indicators of the database object; and optimize the target object to optimize the read and write performance of the target database.
[0141] Optionally, the optimization module 430 is specifically used to determine the sum of all read times and write times in the read and write performance indicators in the read and write data as the read and write time corresponding to the target database; determine the sum of the processing time of all execution statements in the target database as the running time of the target database; if the ratio of the read and write time to the running time is greater than the set time indicator threshold, it is determined that the read and write performance of the target database is in an abnormal state.
[0142] Optionally, the optimization module 430 is specifically used to, if the database object includes a subject object and an object object, based on the read and write performance indicators of the database object, determine the subject object whose indicator percentage value in the read and write performance indicators exceeds a first set indicator threshold as an abnormal subject object; based on the read and write performance indicators of the database object, determine the object object whose indicator percentage value in the read and write performance indicators exceeds a second set indicator threshold as an abnormal object object; combine the first statistical dimension to which the abnormal subject object belongs and the second statistical dimension to which the abnormal object object belongs as the target statistical dimension; based on the target statistical dimension, determine at least one database object with the highest indicator percentage value in the read and write performance indicators as the target object.
[0143] In this embodiment, the database read and write performance optimization device can solve the problems of insufficient accuracy and limited reliability of database read and write performance optimization processing in the prior art through the combination of various modules, and facilitate the identification of specific database objects that cause abnormal read and write performance, thereby facilitating performance tuning and improving database performance optimization efficiency, thereby improving database performance.
[0144] Figure 5 A schematic diagram of a control device provided by the present disclosure, such as Figure 5 As shown, the control device 500 includes: a memory 510 and a processor 520 .
[0145] The memory 510 stores a computer program that can be executed by at least one processor 520. The computer program is executed by at least one processor 520 to enable the control device to implement the database read and write performance optimization method provided in any of the above embodiments.
[0146] The memory 510 and the processor 520 may be connected via a bus 530 .
[0147] The relevant instructions can be understood by referring to the relevant descriptions and effects corresponding to the method embodiments, which will not be repeated here.
[0148] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the following Figures 2 to 3c A corresponding method for optimizing database read and write performance according to any embodiment.
[0149] Among them, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0150] An embodiment of the present disclosure provides a computer program product, which includes computer-executable instructions. When the computer-executable instructions are executed by a processor, the computer-executable instructions are used to implement the following Figures 2 to 3c A corresponding method for optimizing database read and write performance according to any embodiment.
[0151] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0152] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0153] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for optimizing database read and write performance, characterized in that: The method comprises: Based on the predetermined statistical dimensions, the read and write data generated during the operation of the target database are collected, and the target database includes database objects; Based on the read and write data, determining the read and write performance index of the target database server in each statistical dimension; Based on the read / write performance index, a target object with an abnormality is determined from the database objects, and the target object is optimized to optimize the read / write performance of the target database.
2. The method for optimizing database read and write performance according to claim 1, characterized in that: The statistical dimensions include subject dimension and object dimension. The collecting of read and write data generated during the operation of the target database based on a predetermined statistical dimension includes: Combine all subject dimensions and all object dimensions as the primary key of the read-write data, wherein the subject dimension is used to represent the dimension corresponding to the database object that initiates the read-write operation, and the object dimension is used to represent the dimension corresponding to the database object that performs the read-write operation; Based on the primary key, the read and write data is collected.
3. The method for optimizing database read and write performance according to claim 2, characterized in that: The subject dimensions include: database process name, database module name, database application name, and execution statement identifier; The object dimensions include: database name, table space name, relation table name, file name and file type; The read and write performance indicators include: number of read and write bytes, number of read and write times, read time, and write time.
4. The method for optimizing database read and write performance according to claim 1, characterized in that: The read / write performance index includes an index value and an index percentage value. The determining, based on the read and write data, the read and write performance index of the target database server in each statistical dimension includes: Based on the statistical dimension, determine the indicator value of the read-write performance indicator corresponding to the database object; Based on all indicator values corresponding to the read and write performance indicators under the same statistical dimension, determine the indicator percentage value corresponding to each database object.
5. The method for optimizing database read and write performance according to any one of claims 1 to 4, characterized in that: The step of determining an abnormal target object from the database objects based on the read / write performance indicator and performing optimization processing on the target object to optimize the read / write performance of the target database includes: Determining that the read / write performance of the target database is in an abnormal state based on a set time indicator threshold and the read time and the write time in the read / write performance indicator; Based on the read and write performance indicators of the database object, determining a target object with an abnormality; The target object is optimized to optimize the read and write performance of the target database.
6. The method for optimizing database read and write performance according to claim 5, characterized in that: The determining that the read / write performance of the target database is in an abnormal state based on the set time indicator threshold and the read time and the write time in the read / write performance indicator includes: Determine the sum of all read times and write times in the read / write performance indicators in the read / write data as the read / write time corresponding to the target database; The sum of the processing time of all executed statements in the target database is determined as the running time of the target database; If the ratio of the read / write time to the running time is greater than the set time indicator threshold, it is determined that the read / write performance of the target database is in an abnormal state.
7. The method for optimizing database read and write performance according to claim 5, characterized in that: The database objects include subject objects and object objects. The determining of the target object having an abnormality based on the read / write performance index of the database object includes: Based on the read and write performance indicators of the database object, determining a subject object whose indicator percentage value in the read and write performance indicator exceeds a first set indicator threshold as an abnormal subject object; Based on the read and write performance indicators of the database object, determining an object whose indicator percentage value in the read and write performance indicator exceeds a second set indicator threshold as an abnormal object object; Combining the first statistical dimension to which the abnormal subject object belongs and the second statistical dimension to which the abnormal object object belongs as the target statistical dimension; Based on the target statistical dimension, at least one database object having the highest indicator percentage value in the read / write performance indicator is determined as the target object.
8. A database read-write performance optimization device, characterized in that: include: A collection module, used to collect read and write data generated during the operation of a target database based on a predetermined statistical dimension, where the target database includes database objects; A processing module, configured to determine the read and write performance index of the target database server in each statistical dimension based on the read and write data; The optimization module is used to determine the target object with abnormality from the database objects based on the read-write performance index, and optimize the target object to optimize the read-write performance of the target database.
9. A control device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the control device executes the database read and write performance optimization method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the database read-write performance optimization method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Cited By
Abnormal detection method and device for read-write data
CN118885325A
