Information reporting method and device and storage medium
By characterizing the client database statements and generating reported information, the problem of low database performance monitoring efficiency in the existing technology is solved, and efficient and accurate performance monitoring is achieved.
Patent Information
- Application Number
- CN202411815877.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, the efficiency of monitoring client database performance is low, and a method is needed to improve monitoring efficiency.
By obtaining multiple database statements generated by the client, performing feature processing to convert them into standardized database statements, generating reporting information based on frequently occurring standardized statements and sending it to the server.
Accurate monitoring of client database performance is achieved, monitoring efficiency is improved, and dependence on manual analysis is reduced.
Smart Images

Figure CN119645798A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of database management, and in particular to an information reporting method, device and storage medium. Background Art
[0002] A large amount of data can be stored in a database. Monitoring the performance of the database helps to understand and optimize the performance of the database.
[0003] For the client, a local database of the client is usually used to store the relevant data of the client. The performance of the database of the client will affect the performance of the client during operation. In the related technology, the performance monitoring of the database of the client is realized by manually analyzing the code corresponding to the database of the client.
[0004] The above method is used to monitor the performance of the client's database, but there is a problem of low efficiency in monitoring the performance of the database. Summary of the invention
[0005] The present application provides an information reporting method, device and storage medium, which can improve the efficiency of performance monitoring of a client database. The technical solution is as follows:
[0006] According to one aspect of the present application, there is provided an information reporting method, which is applied to a client and includes:
[0007] Acquire a plurality of first database statements generated by the client, where the first database statements include operation characteristic information, and the operation characteristic information is used to reflect the operation process of the first database statements on the database of the client;
[0008] Performing characterization processing on each of the plurality of first database statements to obtain a second database statement corresponding to each of the first database statements, wherein the characterization processing is used to replace information in the first database statement except the operation characteristic information with the same information;
[0009] Generate reporting information according to at least two identical second database statements, where the number of occurrences of the at least two identical second database statements within a unit time is greater than a number threshold;
[0010] Send the reporting information to the server.
[0011] According to another aspect of the present application, there is provided an information reporting method, which is applied to a server and includes:
[0012] Receive reporting information sent by the client;
[0013] When receiving a query request from a query device, providing the reported information to the query device;
[0014] The reported information is generated based on at least two identical second database statements, the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold, the second database statement is obtained by performing characterization processing on each first database statement of multiple first database statements, the characterization processing is used to replace information other than operation characteristic information in the first database statement with the same information, the operation characteristic information is used to reflect the operation process of the first database statement on the database of the client, and the multiple first database statements are obtained by the client.
[0015] According to another aspect of the present application, there is provided an information reporting device, the device comprising:
[0016] An acquisition module, used for acquiring a plurality of first database statements generated by a client, wherein the first database statements include operation characteristic information, and the operation characteristic information is used for reflecting the operation process of the first database statements on the database of the client;
[0017] a processing module, configured to perform a characterization process on each of the plurality of first database statements to obtain a second database statement corresponding to each of the first database statements, wherein the characterization process is configured to replace information in the first database statement other than the operation characteristic information with the same information;
[0018] A generating module, configured to generate reporting information according to at least two identical second database statements, wherein the number of occurrences of the at least two identical second database statements within a unit time is greater than a number threshold;
[0019] The sending module is used to send the reporting information to the server.
[0020] In an optional design, the processing module is used to:
[0021] Replacing the information to be processed in the i-th first data statement among the multiple first database statements with a unified wildcard to obtain a second database statement corresponding to the i-th first data statement;
[0022] The information to be processed includes information in the i-th first database statement except the operation feature information, and i is a positive integer.
[0023] In an optional design, the information to be processed includes at least one of the query parameters and key-value pairs in the i-th first database statement.
[0024] In an optional design, the processing module is used to:
[0025] Parsing the i-th first database statement into an Abstract Syntax Tree (AST);
[0026] Replacing the target node in the AST with the unified wildcard to obtain a processed AST, wherein the target node is the node corresponding to the information to be processed in the AST;
[0027] The second database statement corresponding to the i-th first data statement is obtained by restoring the processed AST to a database statement.
[0028] In an optional design, the generating module is used to:
[0029] generating fingerprint information corresponding to the second database statement according to the content of the second database statement;
[0030] Classifying at least two second database statements having the same fingerprint information into the same database statement set;
[0031] When the number of occurrences of the second database statement in the database statement set within the unit time is greater than the number threshold, the reporting information is generated according to the second database statement in the database statement set.
[0032] In an optional design, the generating module is used to:
[0033] In the case where there are k consecutive second database statements in the database statement set, generating the reporting information according to the second database statements in the k consecutive second database statements, and the second database statements in the database statement set are sorted according to the execution time of the corresponding database operations;
[0034] Among them, the time difference between the database operation execution time corresponding to the first second database statement among the k consecutive second database statements and the database operation execution time corresponding to the kth second database statement is less than or equal to the unit time, and k is greater than the number threshold.
[0035] In an optional design, the acquisition module is used to:
[0036] receiving an acquisition configuration sent by the server, wherein the acquisition configuration includes an acquisition frequency and acquisition switch information, and the acquisition switch information is used to indicate whether to acquire the first database statement;
[0037] When the acquisition switch information indicates to acquire the first database statement, the first database statement is acquired according to the acquisition frequency to obtain the plurality of first database statements.
[0038] According to another aspect of the present application, there is provided an information reporting device, the device comprising:
[0039] A receiving module, used for receiving the reporting information sent by the client;
[0040] A transmission module, configured to provide the reported information to the query device when receiving a query request from the query device;
[0041] The reported information is generated based on at least two identical second database statements, the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold, the second database statement is obtained by performing characterization processing on each first database statement of multiple first database statements, the characterization processing is used to replace information other than operation characteristic information in the first database statement with the same information, the operation characteristic information is used to reflect the operation process of the first database statement on the database of the client, and the multiple first database statements are obtained by the client.
[0042] In an optional design, the reporting information includes a code stack corresponding to a target database operation, and the target database operation includes a database operation corresponding to a database statement in the same at least two second database statements; the device further includes:
[0043] A determination module, used to determine the maintenance object corresponding to the code stack according to a preset relationship;
[0044] The maintenance object is used to maintain the code stack, and the preset relationship includes a corresponding relationship between different code stacks and different maintenance objects.
[0045] In an optional design, the device further includes:
[0046] A determination module, used to determine the warning level of the database operation corresponding to the same type of reporting information according to the receiving frequency of the same type of reporting information;
[0047] The warning level is positively correlated with the receiving frequency, and the same type of reporting information includes reporting information corresponding to the same second database statement.
[0048] According to another aspect of the present application, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one program, and the at least one program is loaded and executed by the processor to implement the information reporting method as described above.
[0049] According to another aspect of the present application, a computer-readable storage medium is provided, wherein at least one program is stored in the computer-readable storage medium, and the at least one program is loaded and executed by a processor to implement the information reporting method as described above.
[0050] According to another aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the information reporting method provided in various optional implementations of the above aspects.
[0051] The beneficial effects of the technical solution provided by this application include at least:
[0052] By obtaining a first database statement for operating the client's database, and performing characterization processing on the first database statement to process the first database statement with the same operation characteristic information into the same second database statement, and then generating reporting information based on the same and frequently occurring second database statement and sending it to the server. Since the characterization processing can extract the operation information corresponding to the same type of database operations, and the reporting information is determined based on the operation information corresponding to the frequently occurring same type of database operations, the reporting information can reflect the frequently occurring same type of database operations. Frequently occurring same type of database operations are database operations that may cause performance problems in the database, so the client's database can be accurately monitored for performance through the sent reporting information. Since the performance monitoring process does not need to rely on manual analysis, the efficiency of performance monitoring of the client's database can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0054] Figure 1 is a schematic diagram of a process of performing performance monitoring on a database of a client provided by an exemplary embodiment of the present application;
[0055] Figure 2 It is a flowchart of an information reporting method provided by an exemplary embodiment of the present application;
[0056] Figure 3 It is a flowchart of an information reporting method provided by an exemplary embodiment of the present application;
[0057] Figure 4 It is a flowchart of an information reporting method provided by an exemplary embodiment of the present application;
[0058] Figure 5 is a schematic diagram of a process of performing performance monitoring on a database of a client provided by an exemplary embodiment of the present application;
[0059] Figure 6 is a system architecture diagram of a database performance monitoring system provided by an exemplary embodiment of the present application;
[0060] Figure 7 is a system architecture diagram of a database performance monitoring system provided by an exemplary embodiment of the present application;
[0061] Figure 8 It is a structural diagram of an information reporting device provided by an exemplary embodiment of the present application;
[0062] Fig. 9 It is a structural diagram of an information reporting device provided by an exemplary embodiment of the present application;
[0063] Fig.10 It is a structural diagram of an information reporting device provided by an exemplary embodiment of the present application;
[0064] Fig.11 It is a structural diagram of a computer device provided by an exemplary embodiment of the present application.
[0065] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application. DETAILED DESCRIPTION
[0066] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0067] Figure 1 FIG. 1 is a schematic diagram of a process of monitoring the performance of a client database provided by an exemplary embodiment of the present application. Figure 1As shown, in step S1, the client collects database operation information. The client obtains the first database statement generated by the database operation and obtains the database operation information. The client also obtains other relevant information of the database operation in addition to the first database statement as the database operation information. In step S2, the client characterizes and classifies the database statements. The client obtains the second database statement corresponding to the first database statement by replacing the information to be processed in the first database statement with a unified wildcard. The information to be processed includes information other than the operation feature information in the first database statement, and the operation feature information is used to reflect the operation process of the first database statement on the client's database. Optionally, the information to be processed includes at least one of the query parameters and key-value pairs in the first database statement. After that, the client generates fingerprint information for the second database statement and classifies the second database statement according to the fingerprint information. When the number of occurrences of the second database statement under a certain category in a unit time is greater than the number threshold, the client generates reporting information according to the second database statement under the category, for example, the database operation information of the database operation corresponding to the second database statement under the category is determined as the reporting information. In step S3, the client reports the database operation information to the server, that is, reports the above-mentioned reporting information.
[0068] In step S4, the server performs data aggregation on the reported information reported by the client to classify and store the reported information according to the fingerprint information corresponding to the second database statement. In step S5, the server performs data attribution on the aggregated reported information. The server determines the maintenance object corresponding to the code stack corresponding to the second database statement of the reported information based on a preset relationship. The maintenance object includes an object for maintaining the above-mentioned code stack, such as a developer of the client, and the preset relationship includes a correspondence between different code stacks and different maintenance objects. In step S6, the server issues an early warning based on the aggregated reported information. The server determines the early warning level of the reported information based on the reception frequency of the reported information corresponding to the same second database statement, and issues early warning information according to the early warning level. The early warning level is positively correlated with the above-mentioned reception frequency.
[0069] By obtaining a first database statement for operating the client's database, and performing characterization processing on the first database statement to process the first database statement with the same operation characteristic information into the same second database statement, and then generating reporting information based on the same and frequently occurring second database statement and sending it to the server. Since the characterization processing can extract the operation information corresponding to the same type of database operations, and the reporting information is determined based on the operation information corresponding to the frequently occurring same type of database operations, the reporting information can reflect the frequently occurring same type of database operations. Frequently occurring same type of database operations are database operations that may cause performance problems in the database, so the client's database can be accurately monitored for performance through the sent reporting information. Since the performance monitoring process does not need to rely on manual analysis, the efficiency of performance monitoring of the client's database can be improved.
[0070] Figure 2 FIG. 1 is a flow chart of an information reporting method provided by an exemplary embodiment of the present application. The method can be used in a computer device or a client on a computer device. Figure 2 As shown, the method includes:
[0071] Step 202: Acquire multiple first database statements generated by the client.
[0072] The first database statement is a database statement generated by a database operation, and the database operation is used to operate the database of the client. The database operation can also be called a database behavior. In some embodiments, the database operation is triggered according to a user operation in the client. Optionally, the database operation includes at least one of an add operation, a delete operation, a modify (update) operation, and a query (read) operation on the data in the database. Add operations, delete operations, modify operations, and query operations can be collectively referred to as CRUD (the first letters of Create, Read, Update, and Delete). The database of the client is a local database of the client. For example, the client is deployed in a computer device, and the database of the client is stored locally on the computer device with the client.
[0073] In some embodiments, the database of the client is SQLite. SQLite is a lightweight relational database that supports being directly embedded in the client and used as a local database. Client developers can operate the database by calling the Application Programming Interface (API) interface provided by SQLite. At the same time, SQLite also provides a rich set of Structured Query Language (SQL) statements to access and modify data in the database. The following is an exemplary introduction to the characteristics of SQLite: (1) Lightweight and embedded: SQLite is designed to be embedded and it takes up very little resources. For example, in embedded devices, only a small amount of memory is required to integrate SQLite. This makes SQLite very suitable for running in resource-constrained environments, such as mobile phones, smart watches, set-top boxes, smart TVs, etc. (2) Cross-platform: SQLite can support multiple operating systems and can be combined with many types of programming languages. (3) High performance: SQLite has a very fast processing speed. Compared with other types of open source databases, such as MySQL and PostgreSQL, SQLite has a faster processing speed. In some embodiments, the operating system supported by the client is the Android system, that is, the operating system of the computer device on which the client is deployed is the Android system.
[0074] The first database statement is used to implement corresponding operations on the database, such as adding operations, deleting operations, modifying operations, and querying operations on data in the database. The first database statement includes operation characteristic information, and the operation characteristic information is used to reflect the operation process of the first database statement on the client's database. The first database statement can also be used to create and manage objects in the database, such as tables, views, indexes, etc. In some embodiments, the first database statement is an SQL statement, which is a standard language for managing relational databases.
[0075] In some embodiments, in addition to obtaining the first database statement corresponding to the database operation, the client also obtains at least one of the database path of the database operation, the start time corresponding to the first database statement, the end time corresponding to the first database statement, the exception information corresponding to the first database statement, the execution process corresponding to the first database statement, the execution thread corresponding to the first database statement, the execution time corresponding to the first database statement, and the code stack corresponding to the first database statement. After obtaining the above information, the client determines the obtained information as the database operation information corresponding to the database operation.
[0076] The database path is used to reflect the storage location of the data operated by the database operation in the database, and the database operation is the operation corresponding to the first database statement. The start time corresponding to the first database statement is used to reflect the time when the first database statement starts to be executed, and the end time corresponding to the first database statement is used to reflect the time when the first database statement is completed. The exception information corresponding to the first database statement is used to reflect whether there is an exception in the process of executing the first database statement. The execution process corresponding to the first database statement is used to reflect the process used to execute the first database statement in the computer device, and the execution thread corresponding to the first database statement is used to reflect the thread used to execute the first database statement in the computer device. The execution time corresponding to the first database statement is used to reflect the time consumed to execute the first database statement, which can be determined according to the difference between the start time and the end time corresponding to the first database statement. The code stack corresponding to the first database statement is used to reflect the position of the code that triggers the execution of the first database statement in the code corresponding to the client.
[0077] In some embodiments, the client registers a callback function corresponding to the database, and thus obtains database operation information through the callback function when a database operation is triggered. A callback function is a function that is passed as a parameter to other functions. The callback function corresponding to the database can be understood as a mechanism that is called when the database operation is completed to pass relevant information about the database operation. For example, when the database operation is a query operation, after the query of the database is completed according to the query operation, the callback function will be called to pass the relevant information of the query operation as a parameter to the callback function, so that the client can obtain the database operation information corresponding to the query operation.
[0078] The client in the embodiments of the present application includes any one of a listening client, a song client, a singing client, a live broadcast client, a short video client, a video on demand client, a social client, an office client, a game client, a takeaway client, an online shopping client, a financial client, a life service client, a navigation client, a medical client, a learning client, and a mini program. The client is deployed in a computer device, and the computer device is used to run the client. In some embodiments, the computer device deploying the client is a terminal, and the terminal includes at least one of a mobile phone, a tablet computer, a smart watch, an e-book reader, an MP3 player, an MP4 player, a laptop computer, and a smart speaker.
[0079] Step 204: Perform characterization processing on each first database statement in the plurality of first database statements to obtain a second database statement corresponding to each first database statement.
[0080] The second database statement corresponding to the first database statement is obtained by processing the first database statement into the second database statement. The characterization process is used to replace the information other than the operation characteristic information in the first database statement with the same information, that is, for the first database statement with different contents but the same operation characteristic information, after the characterization process, a second database statement with exactly the same contents will be obtained.
[0081] In some implementations, the operation feature information includes at least one of an operation type, a keyword, and an operation object. The operation type is used to reflect the type of operation performed by the database statement on the database, the keyword is used to reflect the logical structure of the database statement, and the operation object is used to reflect the object operated by the database statement in the database. For example, for a query-type SQL statement "SELECT*FROM users WHERE age>18", "SELECT" in the statement is the operation type, "users" is the operation object, and "FROM", "WHERE" and "age>" are keywords. Performing characterization processing on the first database statement can be understood as finding the content in the first database statement that can reflect the operation characteristics, thereby obtaining the second database statement, avoiding database statements with the same operation characteristics but different contents from causing negative interference to the database performance monitoring process. By extracting the content in the first database statement that can reflect the operation characteristics, the database statements can be classified more accurately, which helps to improve the accuracy of database performance monitoring.
[0082] For example, the contents of the first database statement 1, the first database statement 2, and the first database statement 3 are different from each other, but the first database statement 1, the first database statement 2, and the first database statement 3 have the same operation characteristic information. By performing the characterization process on the first database statement 1, the second database statement 1 is obtained. By performing the characterization process on the first database statement 2, the second database statement 2 is obtained. By performing the characterization process on the first database statement 3, the second database statement 3 is obtained. Among them, the contents of the second database statement 1, the second database statement 2, and the second database statement 3 are exactly the same.
[0083] In some embodiments, the client can obtain a second database statement corresponding to the first database statement by replacing the information to be processed in the first database statement with a unified wildcard. The information to be processed includes information other than the operation feature information in the first database statement, and the unified wildcard is a pre-set character, such as "?". By replacing the information to be processed in the first database statement with a unified wildcard, since the unified wildcard is uniformly set and the information to be processed does not belong to the operation feature information, it is possible to uniformly replace the information in the first database statement that is not used to reflect the operation feature with the same wildcard, and process the database statements with the same operation feature in the first database statement as the same second database statement. Optionally, the information to be processed includes at least one of a query parameter and a key-value pair in the first database statement.
[0084] Step 206: Generate reporting information according to the same at least two second database statements.
[0085] The reporting information is generated based on at least two identical second database statements, and the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold. The unit time and the number threshold are preset, for example, set by the developer of the client. The number of occurrences of the at least two identical second database statements in a unit time is used to reflect the frequency of occurrence of the second database statements in the at least two identical second database statements. The occurrence of the second database statement can be understood as the generation of the first database statement corresponding to the second database statement. Optionally, the number of occurrences of the at least two identical second database statements in a unit time is determined based on the generation time corresponding to each of the at least two identical second database statements. The generation time corresponding to the second database statement can be the start time of the database operation corresponding to the second database statement. For example, the generation time of the second database statement 1 is 00:01, the generation time of the second database statement 2 is 00:02, and the generation time of the second database statement 3 is 00:03. The second database statement 1, the second database statement 2 and the second database statement 3 are the same, and the unit time is 2s. In this case, the number of occurrences of the second database statement 1, the second database statement 2 and the second database statement 3 in the unit time is 3 times. In some embodiments, the client determines database operation information of the database operation corresponding to the second database statements in the same at least two second database statements as the reporting information.
[0086] In some embodiments, when the client obtains the second database statement, it will divide the second database statement into different database statement sets according to the content of the second database statement, and the second database statements in the same database statement set are the same. The second database statements in the database statement set are sorted according to the generation time, that is, the database operation execution time of the database operation corresponding to the second database statement. Then the client determines whether the number of occurrences of multiple consecutive second database statements in the database statement set per unit time is greater than the number threshold. If the conditions are met, the client determines the reporting information based on the multiple consecutive second database statements, for example, determining the reporting information based on the database operation information corresponding to the multiple consecutive second database statements, or determining the reporting information based on the database operation information corresponding to one of the multiple consecutive second database statements.
[0087] Since the at least two identical second database statements whose number of occurrences within a unit time is greater than the number threshold are database statements corresponding to frequently executed database operations of the same type, and frequently executed database operations are operations that may cause performance problems in the database, performance monitoring of the client's database can be achieved by determining the reported information.
[0088] Step 208: Send reporting information to the server.
[0089] After the client determines the reporting information according to the second database statement, it will send the reporting information to its corresponding server. The server corresponding to the client is deployed in a computer device, and the computer device can be a server, such as a background server corresponding to the client, or a server for managing the client, or a server for monitoring the performance of the client's database, which is not limited in the embodiment of the present application.
[0090] In some embodiments, after receiving the report information sent by the client, the server will solidify the acquired report information, that is, store the received report information for subsequent review or analysis of the report information.
[0091] In summary, the method provided in this embodiment obtains a first database statement for operating a database of a client, and performs characterization processing on the first database statement to process the first database statement with the same operation characteristic information into the same second database statement, and then generates reporting information based on the same and frequently occurring second database statement and sends it to the server. Since the characterization processing can extract the operation information corresponding to the same type of database operations, and the reporting information is determined based on the operation information corresponding to the frequently occurring same type of database operations, the reporting information can reflect the frequently occurring same type of database operations. Frequently occurring same type of database operations are database operations that may cause performance problems in the database, so the performance monitoring of the client's database can be accurately achieved through the sent reporting information. Since the performance monitoring process does not need to rely on manual analysis, the efficiency of performance monitoring of the client's database can be improved.
[0092] Figure 3 FIG. 1 is a flow chart of an information reporting method provided by an exemplary embodiment of the present application. The method can be used in a computer device or a server on a computer device. Figure 3 As shown, the method includes:
[0093] Step 302: Receive reporting information sent by the client.
[0094] The reporting information is generated based on at least two identical second database statements, and the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold. The unit time and the number threshold are preset, for example, set by a developer of the client. Optionally, the number of occurrences of the at least two identical second database statements in a unit time is determined based on the generation time corresponding to each of the at least two identical second database statements, and the generation time corresponding to the second database statement may be the start time of the database operation corresponding to the second database statement.
[0095] The second database statement is obtained by performing characterization processing on each of the first database statements in the plurality of first database statements. The first database statement is obtained by the client, and the first database statement is a database statement generated by a database operation, and the database operation is used to operate the database of the client. In some embodiments, the database operation is triggered according to a user operation in the client. Optionally, the database operation includes at least one of an add operation, a delete operation, a modify (update) operation, and a query (read) operation on the data in the database. The database of the client is a local database of the client, for example, the client is deployed in a computer device, and the database of the client is stored locally on the computer device with the client. The first database statement is a statement generated during the execution of the database operation, and the first database statement is used to implement the corresponding operation on the database. In some embodiments, the first database statement is an SQL statement. In some embodiments, in addition to obtaining the first database statement corresponding to the database operation, the client also obtains at least one of the database path of the database operation, the start time corresponding to the first database statement, the end time corresponding to the first database statement, the exception information corresponding to the first database statement, the execution process corresponding to the first database statement, the execution thread corresponding to the first database statement, the execution time corresponding to the first database statement, and the code stack corresponding to the first database statement. After obtaining the above information, the client will determine the obtained information as database operation information corresponding to the database operation.
[0096] The characterization process is used to replace the information in the first database statement except the operation characteristic information with the same information. The first database statement includes the operation characteristic information, and the operation characteristic information is used to reflect the operation process of the first database statement on the client's database. That is, for the first database statement with different content but the same operation characteristic information, after the characterization process, a second database statement with exactly the same content will be obtained. In some implementations, the operation characteristic information includes at least one of an operation type, a keyword, and an operation object. The operation type is used to reflect the type of operation performed by the database statement on the database, the keyword is used to reflect the logical structure of the database statement, and the operation object is used to reflect the object operated by the database statement in the database.
[0097] It should be noted that, for the process of the client obtaining the first database statement, determining the second database statement based on the first database statement, and determining the reporting information based on the second database statement, reference can be made to the relevant contents in other embodiments of the present application and will not be repeated here.
[0098] Step 304: When receiving a query request from a query device, provide reporting information to the query device.
[0099] The reference device includes a computer device for consulting reported information. The reference request is a request triggered in the reference device, for example, triggered by a user operation in the reference device. In some embodiments, the reference device is a computer device where the server is located. In some embodiments, the reference device is different from the computer device where the server is located. Optionally, a World Wide Web (WEB) monitoring terminal corresponding to the server is deployed in the reference device, and the WEB monitoring terminal is used to monitor the performance of the client's database, and the reference request is triggered by the WEB monitoring terminal. When the server receives the reference request, it will send the reported information requested by the reference request to the WEB monitoring terminal, so that the WEB monitoring terminal displays the received reported information.
[0100] In some embodiments, after receiving the report information sent by the client, the server will solidify the acquired report information, that is, store the received report information. In the case of receiving a query request from a query device, the server will obtain the report information requested by the query request from the locally stored data and provide it to the query device.
[0101] In summary, the method provided in this embodiment receives the reporting information sent by the client, and the reporting information is generated by the client by obtaining the first database statement corresponding to the database operation, and performing characterization processing on the first database statement to process the first database statement with the same operation characteristic information into the same second database statement, and then generating it according to the same and frequently occurring second database statement. Since the characterization processing can extract the operation information corresponding to the same type of database operations, and the reporting information is determined based on the operation information corresponding to the frequently occurring same type of database operations, the reporting information can reflect the frequently occurring same type of database operations. Frequently occurring same type of database operations are database operations that may cause performance problems in the database, so the performance monitoring of the client's database can be accurately achieved through the sent reporting information. Since the performance monitoring process does not need to rely on manual analysis, the efficiency of performance monitoring of the client's database can be improved.
[0102] Figure 4 FIG. 1 is a flowchart of an information reporting method provided by an exemplary embodiment of the present application. The method can be used in a computer system composed of a client and a server. Figure 4 As shown, the method includes:
[0103] Step 402: The client obtains a plurality of first database statements.
[0104] The first database statement is a database statement generated by a database operation. The database operation is used to operate the database of the client. The database operation may also be referred to as a database behavior. In some embodiments, the database operation is triggered according to a user operation in the client. Optionally, the database operation includes at least one of an add operation, a delete operation, a modify (update) operation, and a query (read) operation on data in the database. The database of the client is a local database of the client.
[0105] In some embodiments, the database of the client is SQLite. The operating system supported by the client is the Android system, that is, the operating system of the computer device on which the client is deployed is the Android system.
[0106] The first database statement is used to implement corresponding operations on the database, such as adding operations, deleting operations, modifying operations, and querying operations on data in the database. The first database statement includes operation characteristic information, and the operation characteristic information is used to reflect the operation process of the first database statement on the client's database. The first database statement can also be used to create and manage objects in the database, such as tables, views, indexes, etc. In some embodiments, the first database statement is an SQL statement.
[0107] In some embodiments, in addition to obtaining the first database statement corresponding to the database operation, the client also obtains at least one of the database path of the database operation, the start time corresponding to the first database statement, the end time corresponding to the first database statement, the exception information corresponding to the first database statement, the execution process corresponding to the first database statement, the execution thread corresponding to the first database statement, the execution time corresponding to the first database statement, and the code stack corresponding to the first database statement. After obtaining the above information, the client determines the obtained information as the database operation information corresponding to the database operation.
[0108] The database path is used to reflect the storage location of the data operated by the database operation in the database, and the database operation is the operation corresponding to the first database statement. The start time corresponding to the first database statement is used to reflect the time when the first database statement starts to be executed, and the end time corresponding to the first database statement is used to reflect the time when the first database statement is completed. The exception information corresponding to the first database statement is used to reflect whether there is an exception in the process of executing the first database statement. The execution process corresponding to the first database statement is used to reflect the process used to execute the first database statement in the computer device, and the execution thread corresponding to the first database statement is used to reflect the thread used to execute the first database statement in the computer device. The execution time corresponding to the first database statement is used to reflect the time consumed to execute the first database statement, which can be determined according to the difference between the start time and the end time corresponding to the first database statement. The code stack corresponding to the first database statement is used to reflect the position of the code that triggers the execution of the first database statement in the code corresponding to the client.
[0109] Exemplarily, the client first obtains the database path, the start time corresponding to the first database statement, the end time corresponding to the first database statement, and the exception information corresponding to the first database statement. Then, the obtained data is analyzed and expanded to obtain the execution process corresponding to the first database statement, the execution thread corresponding to the first database statement, the execution time corresponding to the first database statement, and the code stack corresponding to the first database statement.
[0110] In some embodiments, the client receives an acquisition configuration sent by the server. The acquisition configuration includes an acquisition frequency and an acquisition switch information. The acquisition frequency is used to indicate the frequency at which the client acquires the first database statement, for example, y first database statements are acquired out of every x first database statements, where x and y are positive integers and x is greater than y. The acquisition frequency can also be referred to as a sampling rate for the first database statement. The acquisition switch information is used to indicate whether the client acquires the first database statement. After the client receives the acquisition configuration, when the acquisition switch information indicates that the client acquires the first database statement, the client acquires the first database statement according to the acquisition frequency, for example, acquires database operation information.
[0111] In some embodiments, the client registers a callback function corresponding to the database, and thus obtains database operation information through the callback function when a database operation is triggered. A callback function is a function that is passed as a parameter to other functions. The callback function corresponding to the database can be understood as a mechanism that is called when the database operation is completed to pass relevant information about the database operation.
[0112] Step 404: The client performs characterization processing on each first database statement in the plurality of first database statements to obtain a second database statement corresponding to each first database statement.
[0113] The second database statement corresponding to the first database statement is obtained by processing the first database statement into the second database statement. The characterization process is used to replace the information in the first database statement except the operation characteristic information with the same information, that is, for the first database statement with different content but the same operation characteristic information, after the characterization process, a second database statement with exactly the same content will be obtained. In some implementations, the operation characteristic information includes at least one of an operation type, a keyword, and an operation object. The operation type is used to reflect the type of operation performed by the database statement on the database, the keyword is used to reflect the logical structure of the database statement, and the operation object is used to reflect the object operated by the database statement in the database.
[0114] For example, the first database statement a is "UPDATE test_table SET param=hello WHERE_id=1", and the first database statement b is "UPDATE test_table SET param=hi WHERE_id=2". By performing characterization processing on the first database statement a, it can be obtained that the second database statement a is "UPDATE test_table SET param=? WHERE_id=?". By performing characterization processing on the first database statement b, it can be obtained that the second database statement b is also "UPDATE test_table SET param=? WHERE_id=?". The operation characteristic information in the above example includes "UPDATE test_table SET param=WHERE_id=".
[0115] In some embodiments, the client can obtain the second database statement corresponding to the i-th first database statement by replacing the information to be processed in the i-th first database statement among multiple first database statements with a unified wildcard, where i is a positive integer. The information to be processed includes information other than the operation feature information in the first database statement, and the unified wildcard is a pre-set character, such as "?". By replacing the information to be processed in the first database statement with a unified wildcard, since the unified wildcard is uniformly set and the information to be processed does not belong to the operation feature information, it is possible to uniformly replace the information in the first database statement that is not used to reflect the operation feature with the same wildcard, and process the database statements with the same operation feature information in the first database statement into the same second database statement. Optionally, the information to be processed includes at least one of a query parameter and a key-value pair in the first database statement.
[0116] In some embodiments, in the process of replacing the information to be processed in the i-th first database statement with a unified wildcard, the client first parses the i-th first database statement into an AST. AST is an abstract representation of the source code structure, which expresses the grammatical structure of the programming language (database statement) in a tree-like form, and each node on the AST represents a structure in the source code. Optionally, the client parses the i-th first database statement into an AST through a parser, and the parser is, for example, JSqlParser, which is used to parse out the structure of the database statement and build a tree structure to represent the grammatical relationship of the database statement, thereby obtaining the corresponding AST. In addition to the above-mentioned JSQLParser, the client can also determine the AST through other types of parsers, and the embodiments of the present application are not limited to this. After that, the client replaces the target node in the AST with a unified wildcard to obtain the processed AST. The target node is the node corresponding to the information to be processed in the AST. In some embodiments, the target node is the root node in the AST, that is, in the process of replacing the unified wildcard, the client determines the root node in the AST as the target node. The client restores the processed AST to a database statement, thereby obtaining the second database statement corresponding to the i-th first database statement. Optionally, the client performs an in-order traversal on the processed AST, thereby restoring the AST to a database statement, thereby obtaining the second database statement. In-order traversal is a method of binary tree traversal, and the traversal order is to first traverse the left subtree of the AST, then visit the root node of the AST, and finally traverse the right subtree of the AST. If the binary tree is empty, the traversal ends.
[0117] In some embodiments, the client inputs the first database statement into the processing model to obtain the second database statement output by the processing model. The processing model can be understood as being used to implement the characterization processing of the first database statement. Optionally, the processing model is an artificial intelligence (AI) model, such as a machine learning model built based on deep neural networks (DNN). The processing model is trained by the first sample database statement, the unified wildcard, and the second sample database statement corresponding to the first sample database statement. The first sample database statement is a database statement collected manually, and the second sample database statement is obtained by manually characterizing the first sample database statement. In the process of training the processing model, the first sample database statement and the unified wildcard are input into the processing model to obtain the predicted database statement output by the processing model. The predicted database statement is a database statement obtained after the first sample database statement predicted by the processing model is characterized. After that, the error loss is determined according to the difference between the predicted database statement and the second sample database statement, and the processing model can be trained by the error loss.
[0118] Step 406: The client determines the reporting information.
[0119] The reporting information is generated based on at least two identical second database statements, and the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold. In some embodiments, the client determines the database operation information of the database operation corresponding to the second database statement in the at least two identical second database statements as the reporting information. The unit time and the number threshold are preset, for example, set by the developer of the client. The number of occurrences of the at least two identical second database statements in a unit time is used to reflect the frequency of occurrence of the second database statement in the at least two identical second database statements, and the occurrence of the second database statement can be understood as the generation of the first database statement corresponding to the second database statement. Optionally, the number of occurrences of the at least two identical second database statements in a unit time is determined based on the generation time corresponding to each second database statement in the at least two identical second database statements, and the generation time corresponding to the second database statement can be the start time of the database operation corresponding to the second database statement.
[0120] Optionally, after acquiring the second database statement, the client generates fingerprint information corresponding to the second database statement according to the content of the second database statement, and the fingerprint information is used to identify the second database statement. Optionally, the client processes the second database statement through Message Digest Algorithm 5 (MD5), so as to generate fingerprint information according to the second database statement. After that, the client divides the second database statement into different database statement sets according to the fingerprint information, for example, divides at least two second database statements with the same fingerprint information into the same database statement set, so as to determine the reporting information according to the second database statements in the database statement set. For example, when the number of occurrences of the second database statement in the database statement set in a unit time is greater than the number threshold, the client generates reporting information according to the second database statement in the database statement set.
[0121] Optionally, the unit time and the number threshold are expressed as n occurrences within an interval of m milliseconds, where m milliseconds is the unit time and n times is the number threshold. In the process of determining the reporting information, the client classifies the second database statements with the same fingerprint information into the same database statement set. In the case where there are k consecutive second database statements in the database statement set, the client generates reporting information according to the second database statements in the k consecutive second database statements. For example, whenever the client determines that there are k consecutive second database statements in the database statement set, the client determines the reporting information according to the k consecutive second database statements that meet the conditions in the database statement set. For example, the client determines the reporting information according to all the database statements in the k consecutive second database statements, or determines the reporting information according to one of the k consecutive second database statements. Among them, the second database statements in the database statement set are sorted according to the corresponding database operation execution time, and the database operation execution time can be the start time of the database operation corresponding to the second database statement. The time difference between the database operation execution time corresponding to the first second database statement in the k consecutive second database statements and the database operation execution time corresponding to the kth second database statement is less than or equal to the unit time, and k is greater than the number threshold.
[0122] Step 408: The client sends reporting information to the server.
[0123] After the client determines the reporting information according to the second database statement, it will send the reporting information to its corresponding server. The server corresponding to the client is deployed in a computer device, and the computer device can be a server, such as a background server corresponding to the client, or a server for managing the client, or a server for monitoring the performance of the client's database, which is not limited in the embodiment of the present application.
[0124] In some embodiments, after receiving the reported information sent by the client, the server will solidify the acquired reported information, that is, store the received reported information for subsequent review or analysis of the reported information. Optionally, in the process of storing the reported information, the server will classify and store the reported information according to the fingerprint information corresponding to the reported information.
[0125] In some embodiments, upon receiving a query request from a query device, the server provides reporting information to the query device. The query device includes a computer device for querying reported information, and the query request is a request triggered in the query device. In some embodiments, the query device is a computer device where the server is located. In some embodiments, the query device is different from the computer device where the server is located. Optionally, a WEB monitoring terminal corresponding to the server is deployed in the query device, and the WEB monitoring terminal is used to monitor the performance of the database of the client, and the query request is triggered by the WEB monitoring terminal. Upon receiving the query request, the server will send the reporting information requested by the query request to the WEB monitoring terminal, so that the WEB monitoring terminal displays the received reporting information.
[0126] Step 410: The server determines the maintenance object corresponding to the code stack according to the preset relationship.
[0127] The reported information includes a code stack corresponding to the target database operation, and the target database operation includes database operations corresponding to database statements in at least two identical second database statements, that is, database operations corresponding to the second database statements used to determine the reported information, and the code stack of the reported information is used to reflect the code that triggers the execution of the database operation corresponding to the reported information, and its location in the client code, and the client code includes code for implementing the deployment / development of the client. The maintenance object is used to maintain the code stack, for example, it is a developer used to maintain the code stack. The preset relationship includes a correspondence between different code stacks and different maintenance objects, and the preset relationship is pre-set in the client. In some embodiments, after determining the maintenance object, the server will assign the reported information to the maintenance object, so that the maintenance object can analyze the code stack of the reported information to solve possible problems.
[0128] In some embodiments, in the process of assigning the reported information to the maintenance object, the server will also send maintenance suggestions corresponding to the reported information to the maintenance object. The maintenance suggestions are generated by the server by calling the Large Language Model (LLM). LLM is an artificial intelligence model built based on deep learning technology. It is pre-trained with a large amount of text data and can handle a variety of natural language processing tasks. In the process of generating maintenance suggestions, the server will input the code stack and prompt information of the reported information to the LLM, so as to prompt the LLM to generate maintenance suggestions based on the code stack through the prompt information. Optionally, the prompt information is used to prompt that the code stack has the problem of frequently triggering database operations, and to prompt to make optimization suggestions for the code stack to solve the problem of frequently triggering database operations. For example, the prompt information is "The input code has the problem of frequently triggering database operations. Please make optimization suggestions for this code to solve the above problem."
[0129] Step 412: The server determines the warning level of the database operation corresponding to the same type of reporting information according to the receiving frequency of the same type of reporting information.
[0130] The same type of reporting information includes reporting information corresponding to the same second database statement, and the receiving frequency is the frequency at which the server receives reporting information corresponding to the same second database statement. For example, the receiving time of reporting information 1 is 15:21, the receiving time of reporting information 2 is 15:22, and the receiving time of reporting information 3 is 15:23. Reporting information 1, reporting information 2, and reporting information 3 correspond to the same second database statement. In this case, the corresponding receiving frequency of reporting information 1, reporting information 2, and reporting information 3 is 3 times every 2 seconds. Optionally, the server will determine the warning level when it determines that the receiving frequency exceeds the frequency threshold. The frequency threshold is pre-set in the server, for example, including a time interval and a reporting quantity threshold of the reporting information corresponding to the time interval.
[0131] The warning level is positively correlated with the receiving frequency, that is, the greater the receiving frequency, the higher the warning level. For example, the above-mentioned reporting quantity threshold includes a first threshold, a second threshold and a third threshold, the first threshold is less than the second threshold, and the second threshold is less than the third threshold. In the case where the number of reporting information received by the server in the above-mentioned time interval exceeds the first threshold but does not exceed the second threshold, the warning level is determined to be mild; in the case where the number of reporting information received by the server in the above-mentioned time interval exceeds the second threshold but does not exceed the third threshold, the warning level is determined to be moderate; in the case where the number of reporting information received by the server in the above-mentioned time interval exceeds the third threshold, the warning level is determined to be severe. When the server receives the reporting information, it will classify and store the obtained reporting information according to the second database statement corresponding to the reporting information. In the case where the receiving frequency of the reporting information under a certain category exceeds the frequency threshold, the server will issue a warning message for the reporting information of the category, for example, send a warning message to the developer of the client, and the warning message is used to reflect the reporting information that triggers the sending of the warning information, as well as the above-mentioned warning level.
[0132] Take the application of the method provided in the embodiment of the present application to the performance monitoring of SQLite as an example. Figure 5 FIG. 1 is a schematic diagram of a process of monitoring the performance of a client database provided by an exemplary embodiment of the present application. Figure 5 As shown, in step A1, the client performs database behavior sample collection. The client obtains the rule parameters (acquisition configuration) issued by the server, and decides whether to perform database behavior sampling according to the sampling rate and collection switch indicated by the rule parameters. In the case of database behavior sampling, the client registers the database callback function of SQLite, and the database operation information corresponding to the operation on the database can be monitored through the callback function, including the database path, the first SQL statement, the start time, the end time, and the exception information. In step A2, the client analyzes and processes the database statement. After obtaining the above information in step A1, the client performs analysis expansion and obtains the following information corresponding to the first SQL statement as database operation information: the execution process of the first SQL statement, the execution thread of the first SQL statement, the execution time of the first SQL statement, and the code stack of the first SQL statement. The client records the database operation information obtained in steps A1 and A2 to a data structure, which can be called an SQL behavior node. After that, the client sends the SQL behavior node to the production queue of the aggregation processing module of the client, and activates the processing thread to process it in the following manner.
[0133] In step A3, the client performs database statement characterization and classification. After the client's processing thread is activated, it will traverse the SQL behavior nodes to be processed, and each SQL behavior node will be processed in turn according to the following logic: (1) The first SQL statement is parsed into AST through the parser; (2) The query parameters and key-value pairs in the AST are set to the wildcard "?"; (3) The AST is traversed in order to generate a new second SQL statement; (4) The second SQL statement is processed through MD5 to obtain the fingerprint information of the second SQL statement. In order to improve the parsing speed of the parser, the following optimization measures can be taken: (1) Classify the keywords such as create, update, insert, select, and delete, and only parse SQL statements that meet the keyword conditions. Since the keywords of different SQL statements are different, the number of matches can be greatly reduced; (2) Use a double-buffered character array to parse SQL statements, making the traversal efficiency o(n); (3) Dynamically configure ignored keywords according to the pre-configured plan. For some database keywords with low activity, they will be dynamically ignored and no longer parsed to improve the parsing speed; (4) Automatically ignore AST nodes that are already wildcards. If a parameter is already a wildcard, it will be added to the AST as a normal string without the need for subsequent processing, thereby improving parsing efficiency.
[0134] In step A4, the client executes the database behavior sample reporting. When the local aggregation processing module of the client is started for the first time, it will read the reporting rule configuration issued by the server (for example, n times within the m millisecond interval). After the processing thread is activated, the SQL behavior nodes processed in step A3 will be processed in sequence according to the time of entering the queue. First, the corresponding fingerprint information is taken out. If the fingerprint appears for the first time during the operation of the processing thread, an SQL data node (database statement set) is generated. The SQL data node corresponds to the following information: fingerprint information, last execution time, and number of executions. The client stores the SQL data node in a hash map (HashMap), and the primary key (key) is the fingerprint information. If the fingerprint information already exists in the hash map, read the corresponding SQL data node for update: a. If the time difference between the last execution time of the SQL data node and the execution time of the SQL behavior node is greater than m, clear the number of executions recorded in the SQL data node and update the last execution time to the execution time of the current SQL behavior node; b. If the time difference between the last execution time of the SQL data node and the execution time of the SQL behavior node is less than or equal to m, increase the number of executions of the SQL data node in sequence. If the number of executions of the SQL data node is greater than n, the client will report the information of the SQL data node to the server.
[0135] In step A5, the server performs data solidification. For the data reported by the client, the server parses the relevant information and fields in the reported data according to the encoding format agreed upon by both ends, and packages it into a static read-only file for compressed storage to avoid database throughput pressure and load burden caused by excessive data volume. These read-only files can be used for historical snapshots, data backup, and downstream reading and processing. In step A6, the server performs data aggregation. The server aggregates the SQL data nodes according to the parsed fingerprint information, and classifies the data under the same fingerprint information. Then sort by version number and retain the original submitted code stack. In step A7, the server performs data attribution. The data entries of all SQL data nodes are aggregated under a certain fingerprint information, each of which contains the original code stack. By analyzing the code stack, the code module where the problem occurs can be located. The code module corresponds to the developer one by one, and can be further assigned to the corresponding developer for processing. In step A8, the server pushes an early warning. When the aggregated data under a certain fingerprint information reports entries exceeding the threshold within the configured time interval, it is pushed to the corresponding developers in different ways according to the warning level reached (mild -> moderate -> severe) for timely processing.
[0136] Through the method provided in the embodiment of the present application, a complete database monitoring solution can be quickly deployed in the client project, thereby detecting the CRUD performance of the client database, improving the overall operating performance of the client, and issuing alarms for high-risk operations to avoid causing related data and economic losses.
[0137] For example, Figure 6 1 is a system architecture diagram of a database performance monitoring system provided by an exemplary embodiment of the present application. Figure 6 As shown, Figure 5 In the example, step A1 and step A2 are executed by the sample collection module of the client 601 , step A3 is executed by the database statement characterization processing module of the client 601 , and step A4 is executed by the aggregation processing module of the client 601 . Figure 5 Steps A5 to A8 in the example are implemented by the service layer of the server 602. For example, Figure 7 1 is a system architecture diagram of a database performance monitoring system provided by an exemplary embodiment of the present application. Figure 7As shown, the smart device 701 deploying the client obtains the first database statement corresponding to the database operation and performs characterization processing on the first database statement, thereby sending the report information to the cloud platform 702 according to the processed second database statement. After obtaining the report information, the cloud platform 702 can store the report information, and when the WEB monitoring terminal 703 requests to view the report information, the cloud platform 702 sends the requested report information to the WEB monitoring terminal 703, so that the WEB monitoring terminal 703 can display the received report information.
[0138] In summary, the method provided in this embodiment obtains a first database statement for operating a database of a client, and performs characterization processing on the first database statement to process the first database statement with the same operation characteristic information into the same second database statement, and then generates reporting information based on the same and frequently occurring second database statement and sends it to the server. Since the characterization processing can extract the operation information corresponding to the same type of database operations, and the reporting information is determined based on the operation information corresponding to the frequently occurring same type of database operations, the reporting information can reflect the frequently occurring same type of database operations. Frequently occurring same type of database operations are database operations that may cause performance problems in the database, so the performance monitoring of the client's database can be accurately achieved through the sent reporting information. Since the performance monitoring process does not need to rely on manual analysis, the efficiency of performance monitoring of the client's database can be improved.
[0139] The method provided in this embodiment also replaces the information to be processed in the first database statement with a unified wildcard to achieve the characterization processing of the first database statement, and can accurately process the first database statement with the same operation characteristics into the second database statement. The second database statement is obtained by parsing the first database statement into AST and then restoring it. Since AST can abstract the first database statement into nodes, the efficiency of the characterization processing can be improved by processing the nodes of AST. By generating fingerprint information for the second database statement and classifying it, the reporting information is determined, which helps to improve the efficiency of determining frequently triggered database operations. Since the reporting information is information corresponding to frequently executed database operations, and frequently executed database operations are operations that may cause performance problems in the database, by determining the maintenance object corresponding to the code stack of the reporting information, it is convenient to maintain the code stack that may have problems. Since the reporting information reported by the client is information corresponding to frequently executed similar database operations, and frequently executed database operations are operations that may cause performance problems in the database, and the warning level is determined for the frequently reported reporting information, the database operation corresponding to the frequently reported reporting information has a higher risk, and the severity of the database performance problem can be determined by determining the warning level.
[0140] It should be noted that before collecting relevant data of users and during the process of collecting relevant data of users, this application can display a prompt interface, pop-up window or output voice prompt information, and the prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that this application only starts to execute the relevant steps of obtaining relevant data of users after obtaining the confirmation operation issued by the user to the prompt interface or pop-up window, otherwise (that is, when the confirmation operation issued by the user to the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data of users are terminated, that is, the relevant data of users are not obtained. In other words, all user data collected by this application are collected with the consent and authorization of the user, and the collection, use and processing of relevant user data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0141] It should be noted that the sequence of the method steps provided in the embodiments of the present application can be appropriately adjusted, and the steps can be increased or decreased accordingly according to the circumstances. Any technician familiar with the technical field can easily think of the changed methods within the technical scope disclosed in the present application, and they should be included in the protection scope of the present application, so they will not be repeated here.
[0142] Figure 8 Schematic diagram of the structure of an information reporting device provided by an exemplary embodiment of the present application. Figure 8 As shown, the device comprises:
[0143] An acquisition module 801 is used to acquire a plurality of first database statements generated by a client, wherein the first database statements include operation characteristic information, and the operation characteristic information is used to reflect the operation process of the first database statements on the database of the client;
[0144] A processing module 802 is used to perform a characterization process on each of the plurality of first database statements to obtain a second database statement corresponding to each of the first database statements, wherein the characterization process is used to replace information other than the operation characteristic information in the first database statement with the same information;
[0145] A generating module 803, configured to generate reporting information according to at least two identical second database statements, wherein the number of occurrences of the at least two identical second database statements within a unit time is greater than a number threshold;
[0146] The sending module 804 is used to send the reporting information to the server.
[0147] In an optional design, the processing module 802 is used to:
[0148] Replacing the information to be processed in the i-th first data statement among the multiple first database statements with a unified wildcard to obtain a second database statement corresponding to the i-th first data statement;
[0149] The information to be processed includes information in the i-th first database statement except the operation feature information, and i is a positive integer.
[0150] In an optional design, the information to be processed includes at least one of the query parameters and key-value pairs in the i-th first database statement.
[0151] In an optional design, the processing module 802 is used to:
[0152] Parse the i-th first database statement into AST;
[0153] Replacing the target node in the AST with the unified wildcard to obtain a processed AST, wherein the target node is the node corresponding to the information to be processed in the AST;
[0154] The second database statement corresponding to the i-th first data statement is obtained by restoring the processed AST to a database statement.
[0155] In an optional design, the generating module 803 is used to:
[0156] generating fingerprint information corresponding to the second database statement according to the content of the second database statement;
[0157] Classifying at least two second database statements having the same fingerprint information into the same database statement set;
[0158] When the number of occurrences of the second database statement in the database statement set within the unit time is greater than the number threshold, the reporting information is generated according to the second database statement in the database statement set.
[0159] In an optional design, the generating module 803 is used to:
[0160] In the case where there are k consecutive second database statements in the database statement set, generating the reporting information according to the second database statements in the k consecutive second database statements, and the second database statements in the database statement set are sorted according to the execution time of the corresponding database operations;
[0161] Among them, the time difference between the database operation execution time corresponding to the first second database statement among the k consecutive second database statements and the database operation execution time corresponding to the kth second database statement is less than or equal to the unit time, and k is greater than the number threshold.
[0162] In an optional design, the acquisition module 801 is used to:
[0163] receiving an acquisition configuration sent by the server, wherein the acquisition configuration includes an acquisition frequency and acquisition switch information, and the acquisition switch information is used to indicate whether to acquire the first database statement;
[0164] When the acquisition switch information indicates to acquire the first database statement, the first database statement is acquired according to the acquisition frequency to obtain the plurality of first database statements.
[0165] Fig. 9 Schematic diagram of the structure of an information reporting device provided by an exemplary embodiment of the present application. Fig. 9 As shown, the device comprises:
[0166] Receiving module 901, used to receive reporting information sent by the client;
[0167] A transmission module 902, configured to provide the reported information to the query device when receiving a query request from the query device;
[0168] The reported information is generated based on at least two identical second database statements, the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold, the second database statement is obtained by performing characterization processing on each first database statement of multiple first database statements, the characterization processing is used to replace information other than operation characteristic information in the first database statement with the same information, the operation characteristic information is used to reflect the operation process of the first database statement on the database of the client, and the multiple first database statements are obtained by the client.
[0169] In an optional design, the reported information includes a code stack corresponding to a target database operation, and the target database operation includes a database operation corresponding to a database statement in the same at least two second database statements; Fig.10 As shown, the device also includes:
[0170] A determination module 903, configured to determine a maintenance object corresponding to the code stack according to a preset relationship;
[0171] The maintenance object is used to maintain the code stack, and the preset relationship includes a corresponding relationship between different code stacks and different maintenance objects.
[0172] In an alternative design, such as Fig.10 As shown, the device also includes:
[0173] A determination module 903, configured to determine the warning level of the database operation corresponding to the same type of reporting information according to the receiving frequency of the same type of reporting information;
[0174] The warning level is positively correlated with the receiving frequency, and the same type of reporting information includes reporting information corresponding to the same second database statement.
[0175] It should be noted that the information reporting device provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the information reporting device provided in the above embodiment and the information reporting method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0176] An embodiment of the present application also provides a computer device, which includes: a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the information reporting method provided by the above-mentioned method embodiments.
[0177] For example, Fig.11 It is a structural diagram of a computer device provided by an exemplary embodiment of the present application.
[0178] The computer device 1100 includes a central processing unit (CPU) 1101, a system memory 1104 including a random access memory (RAM) 1102 and a read-only memory (ROM) 1103, and a system bus 1105 connecting the system memory 1104 and the central processing unit 1101. The computer device 1100 also includes a basic input / output system (I / O system) 1106 for facilitating information transmission between various components in the computer device, and a large-capacity storage device 1107 for storing an operating system 1113, application programs 1114, and other program modules 1115.
[0179] The basic input / output system 1106 includes a display 1108 for displaying information and an input device 1109 such as a mouse and a keyboard for user inputting information. The display 1108 and the input device 1109 are connected to the central processing unit 1101 through an input / output controller 1110 connected to the system bus 1105. The basic input / output system 1106 may also include an input / output controller 1110 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1110 also provides output to a display screen, a printer, or other types of output devices.
[0180] The mass storage device 1107 is connected to the central processing unit 1101 through a mass storage controller (not shown) connected to the system bus 1105. The mass storage device 1107 and its associated computer-readable storage medium provide non-volatile storage for the computer device 1100. That is, the mass storage device 1107 may include a computer-readable storage medium (not shown) such as a hard disk or a compact disc read-only memory (CD-ROM) drive.
[0181] Without loss of generality, the computer-readable storage medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable storage instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electronically Erasable Programmable Read-Only Memory (EEPROM), flash memory or other solid-state storage devices, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 1104 and mass storage device 1107 can be collectively referred to as memory.
[0182] The memory stores one or more programs, and the one or more programs are configured to be executed by one or more central processing units 1101. The one or more programs contain instructions for implementing the above-mentioned method embodiments. The central processing unit 1101 executes the one or more programs to implement the methods provided by the above-mentioned various method embodiments.
[0183] According to various embodiments of the present application, the computer device 1100 can also be connected to a remote computer device on a network through a network such as the Internet. That is, the computer device 1100 can be connected to the network 1112 through the network interface unit 1111 connected to the system bus 1105, or the network interface unit 1111 can be used to connect to other types of networks or remote computer device systems (not shown).
[0184] The memory also includes one or more programs, which are stored in the memory and include steps executed by a computer device in the method provided in the embodiment of the present application.
[0185] A computer-readable storage medium is also provided in an embodiment of the present application, in which at least one instruction, at least one program, code set or instruction set is stored. When the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor of a computer device, the information reporting method provided by the above-mentioned method embodiments is implemented.
[0186] The present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the information reporting method provided by each of the above method embodiments.
[0187] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned readable storage medium may be a read-only memory, a disk or an optical disk, etc.
[0188] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent switching, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. An information reporting method, characterized in that: The method is applied to a client, and the method comprises: Acquire a plurality of first database statements generated by the client, where the first database statements include operation characteristic information, and the operation characteristic information is used to reflect the operation process of the first database statements on the database of the client; Performing characterization processing on each of the plurality of first database statements to obtain a second database statement corresponding to each of the first database statements, wherein the characterization processing is used to replace information in the first database statement except the operation characteristic information with the same information; Generate reporting information according to at least two identical second database statements, where the number of occurrences of the at least two identical second database statements within a unit time is greater than a number threshold; Send the reporting information to the server.
2. The method according to claim 1, characterized in that The performing characterization processing on each of the plurality of first database statements to obtain a second database statement corresponding to each of the first database statements includes: Replace the information to be processed in the i-th first data statement among the multiple first database statements with a unified wildcard to obtain a second database statement corresponding to the i-th first data statement; The information to be processed includes information in the i-th first database statement except the operation feature information, and i is a positive integer.
3. The method according to claim 2, characterized in that The information to be processed includes at least one of a query parameter and a key-value pair in the i-th first database statement.
4. The method according to claim 2, characterized in that: The replacing the information to be processed in the i-th first data statement among the multiple first database statements with a unified wildcard to obtain a second database statement corresponding to the i-th first data statement includes: Parsing the i-th first database statement into an abstract syntax tree AST; Replacing the target node in the AST with the unified wildcard to obtain a processed AST, wherein the target node is the node corresponding to the information to be processed in the AST; The second database statement corresponding to the i-th first data statement is obtained by restoring the processed AST to a database statement.
5. The method according to any one of claims 1 to 4, characterized in that: Generating the reporting information according to the same at least two second database statements includes: generating fingerprint information corresponding to the second database statement according to the content of the second database statement; Classifying at least two second database statements having the same fingerprint information into the same database statement set; When the number of occurrences of the second database statement in the database statement set within the unit time is greater than the number threshold, the reporting information is generated according to the second database statement in the database statement set.
6. The method according to claim 5, characterized in that When the number of occurrences of the second database statement in the database statement set within the unit time is greater than the number threshold, generating the reporting information according to the second database statement in the database statement set includes: In the case where there are k consecutive second database statements in the database statement set, generating the reporting information according to the second database statements in the k consecutive second database statements, and the second database statements in the database statement set are sorted according to the execution time of the corresponding database operations; Among them, the time difference between the database operation execution time corresponding to the first second database statement among the k consecutive second database statements and the database operation execution time corresponding to the kth second database statement is less than or equal to the unit time, and k is greater than the number threshold.
7. The method according to any one of claims 1 to 4, characterized in that: The obtaining of the plurality of first database statements generated by the client includes: receiving an acquisition configuration sent by the server, wherein the acquisition configuration includes an acquisition frequency and acquisition switch information, and the acquisition switch information is used to indicate whether to acquire the first database statement; When the acquisition switch information indicates to acquire the first database statement, the first database statement is acquired according to the acquisition frequency to obtain the plurality of first database statements.
8. An information reporting method, characterized in that: The method is applied to the server, and the method includes: Receive reporting information sent by the client; Upon receiving a query request from a query device, providing the reported information to the query device; The reported information is generated based on at least two identical second database statements, the number of occurrences of the at least two identical second database statements in a unit time is greater than a number threshold, the second database statement is obtained by performing characterization processing on each first database statement of multiple first database statements, the characterization processing is used to replace information other than operation characteristic information in the first database statement with the same information, the operation characteristic information is used to reflect the operation process of the first database statement on the database of the client, and the multiple first database statements are obtained by the client.
9. The method according to claim 8, characterized in that The reporting information includes a code stack corresponding to a target database operation, and the target database operation includes a database operation corresponding to a database statement in the at least two identical second database statements; the method further includes: Determining a maintenance object corresponding to the code stack according to a preset relationship; The maintenance object is used to maintain the code stack, and the preset relationship includes a corresponding relationship between different code stacks and different maintenance objects.
10. The method according to claim 8, characterized in that The method further comprises: Determining the warning level of the database operation corresponding to the same type of reporting information according to the receiving frequency of the same type of reporting information; The warning level is positively correlated with the receiving frequency, and the same type of reporting information includes reporting information corresponding to the same second database statement.
11. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one program, and the at least one program is loaded and executed by the processor to implement the information reporting method according to any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: The readable storage medium stores at least one program, and the at least one program is loaded and executed by the processor to implement the information reporting method according to any one of claims 1 to 10.
13. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the information reporting method as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Database slow query log processing method, server, computing device and system
CN112506951A
Processing method of statistical information of database operation statements, storage medium and equipment
CN115858627A
Database operation monitoring method, system and device and storage medium
CN116089212A
Adaptive learning of actionable statements in natural language conversation
US20170199866A1