Database Request Evaluation Method, Device, Readable Storage Medium and Electronic Device
By extracting and aggregating database request statements from the database logs, scoring and evaluating, the problem of difficulty in filtering out optimization requests in the existing technology is solved, efficient optimization suggestions are provided, and the efficiency and accuracy of database request optimization are improved.
Patent Information
- Application Number
- CN202111402672.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-11-19
AI Technical Summary
The prior art has limitations when evaluating database request status, making it difficult to filter out the most worthy of optimization requests from massive requests, and slow query logs and explanation commands cannot provide effective optimization suggestions.
By extracting a set of database request statements of preset types from the database log, performing aggregation and semantic analysis, generating an aggregated array, and scoring the request statements based on the parsing results, generating request evaluation information to identify database request statements that need to be optimized.
It realizes finding the statements that need to be optimized from massive database requests, provides targeted optimization suggestions, and improves the efficiency and accuracy of database request optimization.
Smart Images

Figure CN114116784B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for evaluating database requests, a computer-readable storage medium, a computer program product, and an electronic device. Background Art
[0002] In the Internet field, databases (such as MySQL databases, etc.) are used by a large number of enterprises. Many enterprises usually have multiple database clusters, each cluster has multiple databases, each database has multiple tables, and countless database requests are generated every day. The execution time of these requests is one of the main bottlenecks of service bearing capacity and an important indicator for service optimization and governance.
[0003] Currently, the evaluation of database request status in the industry usually uses slow query logs, and the governance usually uses the explain command. The slow query log is a function built into the MySQL database. The principle is to set an execution time standard, such as 3 seconds, and any SQL statement that exceeds this execution time will be recorded in the slow query log. The explain command is also a function built into the MySQL database. The principle is to analyze the execution plan of a request and give information such as the possible indexes to be used and the number of scanned rows. Summary of the Invention
[0004] Embodiments of the present disclosure provide a method and apparatus for evaluating database requests, a computer-readable storage medium, an electronic device, and a computer program product.
[0005] Embodiments of the present disclosure provide a method for evaluating database requests. The method includes: extracting a set of database request statements of a preset type from a database log; aggregating the set of database request statements to obtain at least one aggregation array; determining the databases respectively corresponding to the at least one aggregation array; for each aggregation array in the at least one aggregation array, parsing the database request statements included in the aggregation array, and scoring the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array; generating request evaluation information for evaluating requests for the databases respectively corresponding to the at least one aggregation array based on the scores of the at least one aggregation array.
[0006] In some embodiments, aggregating a set of database request statements to obtain at least one aggregation array, including: performing semantic analysis on the database request statements in the set of database request statements to obtain at least one statement model; aggregating the set of database request statements based on the at least one statement model to obtain at least one sub-set of sentences; and generating at least one aggregation array based on the at least one sub-set of sentences. In some embodiments, generating at least one aggregation array based on the at least one sub-set of sentences includes: for a statement model in the at least one statement model, determining a model encoding corresponding to the statement model; determining an example statement from the sub-set of sentences corresponding to the statement model; and generating an aggregation array corresponding to the statement model based on the model encoding and the example statement corresponding to the statement model.
[0007] In some embodiments, determining an example statement from the sub-set of sentences corresponding to the statement model includes: determining an average execution time of the database request statements in the sub-set of sentences corresponding to the statement model, and determining as the example statement the database request statement whose statement execution time is closest to the average execution time; and / or sorting the database request statements in the sub-set of sentences corresponding to the statement model according to the magnitude of the statement execution time, and determining an example statement from the sub-set of sentences corresponding to the statement model according to the sorting.
[0008] In some embodiments, parsing the database request statements included in the aggregation array and scoring the database request statements included in the aggregation array based on the parsing result to obtain a score of the aggregation array, including: parsing the example statements included in the aggregation array and scoring the example statements included in the aggregation array based on the parsing result to obtain a score of the aggregation array.
[0009] In some embodiments, the method further includes: determining entities respectively corresponding to the at least one aggregation array based on a pre-established correspondence between entities and databases; for an entity in the at least one entity, generating and displaying entity evaluation information corresponding to the entity based on the score of the aggregation array corresponding to the entity, and displaying database request evaluation information of the aggregation array corresponding to the entity.
[0010] In some embodiments, generating and displaying entity evaluation information corresponding to the entity based on the score of the aggregation array corresponding to the entity, and displaying database request evaluation information of the aggregation array corresponding to the entity includes: determining at least one service corresponding to the entity and aggregation arrays respectively corresponding to the at least one service; generating and displaying entity evaluation information corresponding to the entity and service evaluation information respectively corresponding to the at least one service corresponding to the entity based on the score of the aggregation array corresponding to the entity, and displaying database request evaluation information of the aggregation array corresponding to the entity.
[0011] In some embodiments, determining the entities corresponding to at least one aggregation array based on a pre-established correspondence between entities and databases includes: for an aggregation array among the at least one aggregation array, determining the original entity to which the database corresponding to the aggregation array belongs from a preset basic correspondence table; determining whether there is a corrected entity corresponding to the aggregation array from a preset corrected correspondence table; if there is, determining the corrected entity as the entity corresponding to the aggregation array; if not, determining the original entity as the entity corresponding to the aggregation array.
[0012] In some embodiments, scoring the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array includes: based on the parsing result, determining the evaluation level corresponding to the database request statements included in the aggregation array; and determining the score of the aggregation array according to the preset scoring rule corresponding to the evaluation level.
[0013] In some embodiments, aggregating a database request statement set to obtain at least one aggregation array includes: aggregating the database request statement set to obtain at least one initial aggregation array; and extracting at least one aggregation array from the at least one initial aggregation array based on the number of database request statements included in the sentence subsets respectively corresponding to the at least one initial aggregation array.
[0014] According to another aspect of the embodiments of the present disclosure, there is provided a database request evaluation device, including: an extraction module, configured to extract a database request statement set of a preset type from a database log; an aggregation module, configured to aggregate the database request statement set to obtain at least one aggregation array; a first determination module, configured to determine the databases corresponding to the at least one aggregation array respectively; a scoring module, configured to, for an aggregation array among the at least one aggregation array, parse the database request statements included in the aggregation array and score the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array; and a generation module, configured to generate request evaluation information for evaluating requests for the databases corresponding to the at least one aggregation array respectively based on the scores of the at least one aggregation array.
[0015] In some embodiments, the aggregation module includes: an analysis unit, configured to perform semantic analysis on the database request statements in the database request statement set to obtain at least one statement model; and a first aggregation unit, configured to aggregate the database request statement set based on the at least one statement model to obtain at least one aggregation array.
[0016] In some embodiments, the first aggregation unit includes: an encoding subunit, configured to determine a model encoding corresponding to at least one statement model in the at least one statement model; a determination subunit, configured to determine an example statement from a set of example sentences corresponding to the statement model; and a generation subunit, configured to generate an aggregation array corresponding to the statement model based on the model encoding corresponding to the statement model and the example statement.
[0017] In some embodiments, the apparatus further includes: a second determination module, configured to determine an entity corresponding to each of the at least one aggregation array based on a pre-established correspondence between entities and databases; and a display module, configured to generate and display entity evaluation information corresponding to each of the at least one entity based on the score of the aggregation array corresponding to the entity, and display database request evaluation information of the aggregation array corresponding to the entity.
[0018] In some embodiments, the display module includes: a first determination unit, configured to determine at least one service corresponding to the entity and an aggregation array corresponding to each of the at least one service; and a display unit, configured to generate and display entity evaluation information corresponding to the entity and service evaluation information corresponding to each of the at least one service corresponding to the entity based on the score of the aggregation array corresponding to the entity, and display database request evaluation information of the aggregation array corresponding to the entity.
[0019] In some embodiments, the second determination module includes: a second determination unit, configured to determine, for each of the at least one aggregation array, a primitive entity to which the database corresponding to the aggregation array belongs from a preset basic correspondence table; a third determination unit, configured to determine whether there is a corrected entity corresponding to the aggregation array from a preset corrected correspondence table; a fourth determination unit, configured to, if there is, determine the corrected entity as the entity corresponding to the aggregation array; and a fifth determination unit, configured to, if not, determine the primitive entity as the entity corresponding to the aggregation array.
[0020] In some embodiments, the scoring module includes: a sixth determination unit, configured to determine an evaluation level corresponding to a database request statement included in the aggregation array based on a parsing result; and a seventh determination unit, configured to determine a score of the aggregation array according to a preset scoring rule corresponding to the evaluation level.
[0021] In some embodiments, the aggregation module includes: a second aggregation unit, configured to aggregate a set of database request statements to obtain at least one initial aggregation array; and an extraction unit, configured to extract at least one aggregation array from the at least one initial aggregation array based on the number of database request statements included in the set of example sentences corresponding to each of the at least one initial aggregation array.
[0022] According to another aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium storing a computer program for executing the above database request evaluation method.
[0023] According to another aspect of the embodiments of the present disclosure, there is provided an electronic device including: a processor; a memory for storing executable instructions of the processor; and the processor for reading the executable instructions from the memory and executing the instructions to implement the above database request evaluation method.
[0024] According to another aspect of the embodiments of the present disclosure, there is provided a computer program product including computer program / instructions which, when executed by a processor, implement the steps of the above database request evaluation method.
[0025] Based on the database request evaluation method, apparatus, computer-readable storage medium, electronic device and computer program product provided by the above embodiments of the present disclosure, by extracting a set of database request statements of a preset type from the database log, then aggregating the set of database request statements to obtain at least one aggregated array, then determining the databases corresponding to the at least one aggregated array respectively, then parsing the database request statements included in the aggregated array, and scoring the database request statements included in the aggregated array based on the parsing result to obtain the score of the aggregated array, and finally, generating request evaluation information for evaluating requests for the database based on the scores of the at least one aggregated array respectively, thereby realizing finding out the database request statements that need to be optimized according to the scores from a large number of database request statements, and at the same time, targeted optimization suggestions can be provided for users through the request evaluation information, which helps users optimize the database request statements through the request evaluation information.
[0026] The technical solution of the present disclosure will be further described in detail below with reference to the drawings and embodiments. Description of the Drawings
[0027] By describing the embodiments of the present disclosure in more detail in conjunction with the drawings, the above and other objects, features and advantages of the present disclosure will become more obvious. The drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification, and are used to explain the present disclosure together with the embodiments of the present disclosure, and do not constitute a limitation to the present disclosure. In the drawings, the same reference numerals generally represent the same components or steps.
[0028] Figure 1 is a system diagram applicable to the present disclosure.
[0029] Figure 2 is a flowchart of a database request evaluation method provided by an exemplary embodiment of the present disclosure.
[0030] Figure 3 It is a schematic flowchart of a database request evaluation method provided by another exemplary embodiment of the present disclosure.
[0031] Figure 4 It is a schematic flowchart of a database request evaluation method provided by another exemplary embodiment of the present disclosure.
[0032] Figure 5 It is a schematic flowchart of a database request evaluation method provided by another exemplary embodiment of the present disclosure.
[0033] Figure 6 It is a schematic flowchart of a database request evaluation method provided by another exemplary embodiment of the present disclosure.
[0034] Figure 7 It is a schematic structural diagram of a database request evaluation device provided by an exemplary embodiment of the present disclosure.
[0035] Figure 8 It is a schematic structural diagram of a database request evaluation device provided by another exemplary embodiment of the present disclosure.
[0036] Figure 9 It is a structural diagram of an electronic device provided by an exemplary embodiment of the present disclosure. Detailed Embodiments
[0037] Next, exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments of the present disclosure. It should be understood that the present disclosure is not limited by the exemplary embodiments described herein.
[0038] It should be noted that: Unless otherwise specifically stated, the relative arrangements of components and steps, numerical expressions and values set forth in these embodiments do not limit the scope of the present disclosure.
[0039] Those skilled in the art can understand that terms such as "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate an inevitable logical order between them.
[0040] It should also be understood that in the embodiments of the present disclosure, "a plurality of" may refer to two or more, and "at least one" may refer to one, two or more.
[0041] It should also be understood that for any component, data or structure mentioned in the embodiments of the present disclosure, unless clearly defined or given a contrary indication in the context, it can generally be understood as one or more.
[0042] In addition, the term "and / or" in the present disclosure is merely a description of the relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in the present disclosure generally indicates that the associated objects before and after are in an "or" relationship.
[0043] It should also be understood that the descriptions of the various embodiments in the present disclosure emphasize the differences between the various embodiments, and their similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail one by one.
[0044] At the same time, it should be understood that for the sake of description, the dimensions of the various parts shown in the drawings are not drawn in actual proportional relationships.
[0045] The following description of at least one exemplary embodiment is actually merely illustrative and in no way restricts the present disclosure or its application or use.
[0046] Techniques, methods, and devices known to those of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, the techniques, methods, and devices should be regarded as part of the specification.
[0047] It should be noted that like reference numerals and letters indicate like items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further discussed in subsequent figures.
[0048] The embodiments of the present disclosure can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, and so on.
[0049] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system-executable instructions (such as program modules) executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked via a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media, including storage devices.
[0050] Application Overview
[0051] Currently, the slow query log and explain command used to evaluate database request status have certain limitations:
[0052] Under complex network conditions, a network fluctuation may cause a long query. Such request statements appear occasionally, often taking up a lot of R&D personnel's time to troubleshoot but finding nothing.
[0053] Some medium- to large-scale internet companies generate massive database requests daily, and these requests have varying weights on overall service quality. Some requests occur on highly concurrent core links, and while a single query may not seem particularly slow, even a small optimization can significantly improve average response time. Conversely, some requests occur on non-core links or are used by external users. In these cases, optimizing every slow query is not the most cost-effective option. Selecting the most worthy candidates for optimization from this massive volume of requests is a problem that slow query logs cannot solve.
[0054] The explain command only displays the current execution plan for a request and does not provide optimization suggestions. In reality, a request may have multiple optimization points, and the difficulty of optimization and its impact on execution efficiency may vary.
[0055] Exemplary System
[0056] Figure 1 An exemplary system architecture 100 is shown to which the database request evaluation method or the database request evaluation apparatus according to the embodiments of the present disclosure can be applied.
[0057] like Figure 1 As shown, system architecture 100 may include terminal device 101, network 102, and server 103. Network 102 is used to provide a medium for a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0058] A user can use the terminal device 101 to interact with the server 103 via the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as search applications, web browser applications, shopping applications, instant messaging tools, etc.
[0059] The terminal device 101 can be various electronic devices, including but not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc.
[0060] The server 103 can be a server that provides various services, such as a background database server that supports database request statements uploaded by the terminal device 101. The background database server can generate database logs and extract a set of database request statements from the database logs, and process the set of database request statements to obtain a processing result (such as request evaluation information).
[0061] It should be noted that the database request evaluation method provided by the embodiments of the present disclosure can be executed by the server 103 or by the terminal device 101. Correspondingly, the database request evaluation device can be set in the server 103 or in the terminal device 101.
[0062] It should be understood that Figure 1 the numbers of the terminal devices, networks, and servers in
[0063] Exemplary Method
[0064] Figure 2 is a schematic flow diagram of a database request evaluation method provided by an exemplary embodiment of the present disclosure. This embodiment can be applied to an electronic device (such as Figure 1 the server 103 or the terminal device 101 shown in Figure 2 ), and as shown in
[0065] Step 201, extract a set of database request statements of a preset type from the database log.
[0066] In this embodiment, the electronic device can extract a set of database request statements of a preset type from the database log. Among them, the database log can be a document for recording operations performed on the databases in the database cluster. For example, the database log can be a BinLog document. The preset type of database request statements can be arbitrarily set in advance. For example, the preset type of database request statements can include statements for adding, deleting, modifying, and querying, and can also include statements for using the database (such as usedatabase xxx).
[0067] As an example, a log extraction service can be set up in the electronic device. The log extraction will collect data according to the database cluster to obtain BinLog. There is a lot of information in BinLog. The log extraction service will extract the thread_id (proxy thread id), timestamp, exec_time (execution time consumption), info (specific request information), and event_type (operation type) in each BinLog, and select the statements with event_type being add, delete, modify, or query, and store them as text logs one by one, that is, the text logs containing the set of database request statements. The log name can be attached with database cluster information, such as cluster name, port, etc. Usually, considering the huge consumption of software and hardware resources caused by enabling BinLog, it can be selected to enable BinLog for a short period of time regularly according to a preset cycle, such as enabling it for 5 minutes every day.
[0068] Step 202: Aggregate the set of database request statements to obtain at least one aggregated array.
[0069] In this embodiment, the electronic device can aggregate the set of database request statements to obtain at least one aggregated array. Specifically, aggregation means counting statements with the same or similar syntactic structures to obtain at least one sub-set of sentences. For each sub-set of sentences, a corresponding aggregated array is generated, that is, the same aggregated array corresponds to the same syntactic structure or multiple similar syntactic structures of statements.
[0070] The aggregated array can include one or more representative database request statements. For example, it can be a database request statement whose execution time is closest to the average execution time of all database request statements corresponding to this aggregated array. Optionally, the aggregated array can also include other information, such as cluster information, table information, average execution time, the occurrence times of each corresponding statement, etc. Optionally, the aggregated array can also include all database request statements of a sub-set of sentences after aggregation. Usually, the form of the aggregated array can be a json array.
[0071] Step 203: Determine the databases corresponding to at least one aggregated array respectively.
[0072] In this embodiment, the electronic device can determine the databases corresponding to at least one aggregation array. As an example, if the database request statement is "use database xxx", record the database currently used by this thread according to the thread_id. If it is an insert, delete, update, or query statement, find out which database this thread is currently using and record it. Generally, since different databases perform different functions, and the set of sentences corresponding to the same aggregation array has the same or similar syntax structures, that is, they perform the same or similar functions. Therefore, the set of sentences corresponding to the same aggregation array targets the same database, and generally there will not be a situation where one aggregation array corresponds to multiple databases. Therefore, the database corresponding to each aggregation array can be determined.
[0073] Step 204: For the aggregation array in the at least one aggregation array, parse the database request statements included in the aggregation array, and score the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array.
[0074] In this embodiment, for the aggregation array in the at least one aggregation array, the electronic device can parse the database request statements included in the aggregation array, and score the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array.
[0075] Specifically, the electronic device can build a syntax tree for the database request statements included in each aggregation array, and match and score each syntax tree according to the preset scoring rules to obtain the score of each aggregation array. For example, assume that the database request statement included in a certain aggregation array is "select username,ismale from userinfo where age>20 and level>5 and 1=1". According to the rule, if a comparison condition that is always true like "1=1" appears, subtract 20 points from the initial score of 100 points, that is, the score of this aggregation array is 80 points.
[0076] It should be noted that the number of database request statements included in an aggregation array can be one or more. When it is one, score this one database request statement to obtain the score of the aggregation array; if it is multiple, the database request statements can be scored separately, and the average value of the scores (or any other arbitrarily set method) can be used as the score of the aggregation array.
[0077] Step 205: Generate request evaluation information for evaluating requests to the databases corresponding to the at least one aggregation array respectively based on the scores of the at least one aggregation array.
[0078] In this embodiment, the electronic device may generate request evaluation information for evaluating requests for databases corresponding to at least one aggregation array respectively based on the scores of the at least one aggregation array.
[0079] Among them, the request evaluation information is used to represent the quality of the set of database request sentences corresponding to a certain aggregation array. As an example, the request evaluation information may include a score, may also include the level where the score is located, and in addition, may also include specific reasons for deduction, improvement strategies, etc.
[0080] The method provided in the above embodiment of the present disclosure extracts a set of database request sentences of a preset type from the database log, then aggregates the set of database request sentences to obtain at least one aggregation array, then determines the databases corresponding to the at least one aggregation array respectively, then parses the database request sentences included in the aggregation array, and scores the database request sentences included in the aggregation array based on the parsing result to obtain the score of the aggregation array. Finally, based on the scores of the at least one aggregation array respectively, request evaluation information for evaluating requests for the database is generated, so as to realize finding out the database request sentences that need to be optimized according to the scores from a large number of database request sentences, and at the same time, targeted optimization suggestions can be provided for users through the request evaluation information, which helps users optimize the database request sentences through the request evaluation information.
[0081] In some alternative implementation manners, as Figure 3 shown, step 202 may include the following sub-steps:
[0082] Step 2021, perform semantic analysis on the database request sentences in the set of database request sentences to obtain at least one sentence model.
[0083] Specifically, the sentence model may be a representative model abstracted by replacing the specific data in the actual database request sentence with special symbols. For example, for the database request sentence "select col1,col2 from t where col1>100 and col3 = "test" limit 20,10", it may be abstracted into the sentence model "select col1,col2 from t where col1>? and col3 = "?" limit?,?". The same sentence model corresponds to at least one database request sentence.
[0084] Step 2022, aggregate the set of database request sentences based on the at least one sentence model to obtain at least one set of sentence subsets.
[0085] Specifically, at least one database request statement corresponding to the same statement model can be used as a sentence set. The database request statements in the same sentence set have the same or similar semantics, and the same statement model can be used to represent this semantics.
[0086] Step 2023: Generate at least one aggregation array based on at least one sentence set.
[0087] Among them, the sentence sets in at least one sentence set correspond one-to-one with the aggregation arrays in at least one aggregation array. As an example, an aggregation array may include a statement model and at least one database request statement in the corresponding sentence set. It may also include other information, such as the database cluster information corresponding to the aggregation array, the database information corresponding to the aggregation array, the table information corresponding to the aggregation array, the average execution time of the sentence set corresponding to the aggregation array, the occurrence times of each database request statement corresponding to the aggregation array, etc.
[0088] In this implementation, by performing semantic analysis on database request statements and generating statement models, at least one database request statement can be aggregated under the same statement model, improving the efficiency of finding statements with the same or similar functions from a large number of database request statements, and thus contributing to improving the efficiency of generating request evaluation information for statements with different functions.
[0089] In some alternative implementations, as Figure 4 shown, step 2023 may include the following sub-steps:
[0090] Step 20231: For the statement models in at least one statement model, determine the model encoding corresponding to this statement model.
[0091] Specifically, the electronic device can encode the statement model according to various existing algorithms. For example, use the hash algorithm to encrypt the statement model to obtain a unique model encoding (also known as a fingerprint) representing the statement model.
[0092] Step 20232: Determine example statements from the sentence set corresponding to this statement model.
[0093] Among them, the example statements can be at least one database request statement with representativeness in the sentence set.
[0094] Optionally, the example statements corresponding to this statement model can be determined in at least one of the following ways:
[0095] Method 1: Determine the average execution time of the database request statements in the sentence set corresponding to the statement model, and determine the database request statement with the execution time closest to the average execution time as the example statement. For the example statement determined by this method, since its execution time is closest to the average execution time, it has strong representativeness in the sentence set, which helps to improve the accuracy of determining the score of the aggregation array.
[0096] Method 2: Sort the database request statements in the sentence set corresponding to the statement model according to the size of the statement execution time, and determine the example statement from the sentence set corresponding to the statement model according to the sorting.
[0097] As an example, the sorting method can be in descending order of the statement execution time. The statement ranked first (i.e., the statement corresponding to the largest statement execution time) can be used as the example statement. Alternatively, the statement with a larger statement execution time can be selected from the sentence set in any specified manner (for example, randomly select statements from the first 50% of the sorted sentence set) as the example statement. For the example statement determined by this method, since its statement execution time is longer, the scoring standard for the example statement can be correspondingly improved, so that the score of the example statement can reflect complex scenarios (for example, when using the limit statement to filter data, the amount of data returned is different, and the statement execution time is also different. Using the example statement with a longer statement execution time for scoring can reflect the execution situation of complex scenarios), and the objectivity of the score can be improved.
[0098] Step 20233: Generate the aggregation array corresponding to the statement model based on the model encoding and example statement corresponding to the statement model.
[0099] Specifically, based on the information included in the aggregation array described in the above Figure 3 corresponding embodiment, the model encoding and example statement can be added to the aggregation array.
[0100] In this implementation, by generating the model encoding of the statement model, the model encoding can uniquely represent the statement model and the aggregation array, thus facilitating the correct distinction between different statement models and aggregation arrays and avoiding errors when calling similar statement models and aggregation arrays.
[0101] In some alternative implementation manners, as Figure 5 shown, the method may further include the following steps:
[0102] Step 206: Determine the entities corresponding to at least one aggregation array based on the pre-established correspondence between entities and the database.
[0103] Among them, the entity can be any form of specific or abstract entity that applies the database. For example, it can be an enterprise or institution, a department within an enterprise or institution, an individual, etc. Usually, one entity can correspond to at least one database, and one database usually corresponds to one entity. In some rare cases, one database can correspond to multiple entities. The correspondence between the entity and the database can be represented by a pre-established correspondence table.
[0104] It should be noted that step 206 can be executed at any stage after obtaining at least one aggregation array.
[0105] Step 207, for the entities in at least one entity, based on the scores of the aggregation arrays corresponding to the entity, generate and display the entity evaluation information corresponding to the entity, and display the request evaluation information of the aggregation array corresponding to the entity.
[0106] Among them, the entity evaluation information is used to represent the summary of the usage of database request statements by the personnel under the entity when operating on the database. According to the scores of the respective aggregation arrays corresponding to the entity, the corresponding entity evaluation information can be generated. Usually, the entity evaluation information and the request evaluation information can be displayed hierarchically, that is, the entity evaluation information includes the overall usage of the database used by the entity, and also includes the corresponding request evaluation information.
[0107] As an example, the entity evaluation information can include the average score of the scores of multiple aggregation arrays corresponding to the entity, used to represent the usage of the database corresponding to the entity. It can also display the statement model that most needs to be optimized under the entity (for example, the statement model in the aggregation array with the lowest score), and can also display the leaderboard, progress list, etc. of the aggregation arrays according to the scores. In addition, the entity evaluation information can also include other information (such as text descriptions, entity names, database names corresponding to the entity, etc.), which will not be listed one by one here.
[0108] Usually, as the personnel and organizational structure included in the entity are continuously adjusted, the attribution relationship between the database and the business line will become increasingly complex. Taking a department within an enterprise as an example, assume that database cluster A belongs to department 1, but database DbTest in database cluster A belongs to department 2, and a certain table TbTest included in database DbTest in database cluster A belongs to department 3. In this case, the database request statements that need to be optimized cannot be quickly corresponded to the relevant departments and personnel. And this implementation method can achieve the aggregated display of the database request statements that need to be optimized under each entity by determining the entity corresponding to the aggregation array and generating and displaying the entity evaluation information and the database request evaluation information, which helps users to optimize the database request statements for different departments specifically, and solves the problem that it is difficult to locate the statements that need to be optimized to the corresponding entity in the scenario where the attribution relationship between the database and the entity is complex.
[0109] In some alternative implementation manners, in step 207, for an entity among at least one entity, the following steps may be performed for the entity:
[0110] First, determine at least one service corresponding to the entity and aggregation arrays respectively corresponding to the at least one service.
[0111] Wherein, a service may be a specific application program or software aggregated by multiple application programs. Generally, different services perform different functions by using corresponding databases. Since at least one service corresponding to the entity and at least one service managed by the entity correspond to at least one database, aggregation arrays corresponding to the services can be determined.
[0112] Then, based on the scores of the aggregation arrays corresponding to the entity, generate and display entity evaluation information corresponding to the entity, service evaluation information respectively corresponding to the at least one service corresponding to the entity, and database request evaluation information of the aggregation arrays corresponding to the entity.
[0113] Among them, the descriptions of the entity evaluation information and the database request evaluation information may refer to the above embodiments. The service evaluation information is used to represent the request situation of the database corresponding to a certain service. According to the scores of the aggregation arrays corresponding to the service, corresponding service evaluation information can be generated. For example, the service evaluation information may include the average score of the scores of multiple aggregation arrays corresponding to the service, which is used to represent the usage situation of the database corresponding to the service. The statement model that most needs to be optimized under the service (for example, the statement model in the aggregation array with the lowest score) can also be displayed, etc. In addition, the service evaluation information may further include other information (such as text descriptions, service names, database names corresponding to the services, etc.), which will not be listed one by one here.
[0114] Generally, the entity evaluation information, the service evaluation information, and the database request evaluation information may be displayed in layers, that is, at least one service evaluation information is displayed under the entity evaluation information, and at least one database request evaluation information is displayed under each service evaluation.
[0115] This implementation manner can achieve aggregated display of the services under each entity and the database request statements that need to be optimized under the services by determining, generating, and displaying the entity evaluation information, the service evaluation information, and the database request evaluation information, which helps the user to optimize the database request statements for different services specifically, enables the user to quickly locate the service corresponding to the database request statement that needs to be optimized, and improves the optimization efficiency of the services.
[0116] In some alternative implementation manners, as Figure 6 shown, the above step 206 may include the following sub-steps:
[0117] Step 2061: For each aggregation array in at least one aggregation array, determine the original entity to which the database corresponding to this aggregation array belongs from a preset basic correspondence table.
[0118] Among them, the basic correspondence table is used to represent the correspondence between databases and entities under normal circumstances. Under normal circumstances, a single database cluster belongs to the same entity. There are multiple database clusters under the same entity. The situations where databases belong to different entities or tables in databases belong to different entities are rare. Therefore, generally, one database corresponds to one entity, and each database identifier stored in this basic correspondence table corresponds to one entity.
[0119] Step 2062: Determine whether there is a corrected entity corresponding to this aggregation array from a preset corrected correspondence table.
[0120] In the corrected correspondence table, the situations of cross-entity attribution of databases or tables in databases are stored. From this corrected correspondence table, the identifier of the database corresponding to the aggregation array or the table in the corresponding database can be determined, and then the entity corresponding to the aggregation array can be determined as the corrected entity according to the identifier.
[0121] Generally, the basic correspondence table and the corrected correspondence table can be assembled into a mapping map data structure in advance and placed in the memory cache, and this mapping map is called from the memory when in use.
[0122] If there is a corrected entity corresponding to this aggregation array in the corrected correspondence table, execute Step 2063; otherwise, execute Step 2064.
[0123] Step 2063: Determine the corrected entity as the entity corresponding to this aggregation array.
[0124] Step 2064: Determine the original entity as the entity corresponding to this aggregation array.
[0125] By executing the above steps for each aggregation array in the above at least one aggregation array, the entity corresponding to each aggregation array can be obtained.
[0126] In this implementation manner, by presetting the basic correspondence table and the corrected correspondence table, it is possible to quickly locate the databases actually corresponding to each aggregation array in the case of cross-entity attribution of databases or tables in databases, thereby improving the efficiency of determining the databases corresponding to the aggregation arrays.
[0127] In some optional implementation manners, in the above Step 204, for each aggregation array in at least one aggregation array, the score of this aggregation array can be obtained according to the following steps:
[0128] First, based on the parsing result, determine the evaluation level corresponding to the database request statement included in the aggregation array.
[0129] Among them, each evaluation level corresponds to a number of scoring rules. As an example, the evaluation level can include four levels, namely:
[0130] Level L0: Suggestion, no deduction of points.
[0131] It is recommended to use the AS keyword to explicitly declare an alias
[0132] The '!=' operator is non-standard, it is recommended to use '<>'
[0133] Level L1: Each occurrence deducts 5 points.
[0134] Use IN with caution, too many elements will cause a full table scan
[0135] The alias should not be the same as the name of the table or column
[0136] When querying indexed columns with OR, try to use the IN predicate
[0137] Eliminate unnecessary DISTINCT conditions
[0138] It is not recommended to use SELECT* type queries
[0139] Level L2: Each occurrence deducts 10 points.
[0140] It is not recommended to use functions in subqueries
[0141] Add an index to the field with high degree of dispersion
[0142] Add an ORDER BY condition explicitly for GROUP BY
[0143] It is not recommended to use GROUP BY for equality query columns
[0144] The condition of ORDER BY is an expression
[0145] GROUP BY or ORDER BY in different tables
[0146] Too many JOINs
[0147] When COUNT(DISTINCT) has multiple columns, the result may be different from what you expect
[0148] Level L3: Each occurrence deducts 20 points
[0149] The parameter comparison contains implicit conversion and cannot use the index
[0150] LIMIT query without using ORDER BY
[0151] The outermost SELECT does not specify a WHERE condition
[0152] A comparison condition that is always true
[0153] MySQL has a poor optimization effect on subqueries
[0154] The same table is joined twice
[0155] Non-deterministic GROUP BY
[0156] The electronic device can match the parsing result with the scoring rules of each of the above levels, so as to determine the evaluation level corresponding to the database request statement included in the aggregation array.
[0157] Then, according to the preset scoring rules corresponding to the evaluation level, determine the score of the aggregation array.
[0158] As an example, assume that the database request statement included in a certain aggregation array is "select username,ismale from userinfo where age>20and level>5and 1=1". According to the rule, if "1=1" appears, the rule of "a comparison condition that is always true" in the above L3 level is hit, and 20 points are deducted from the initial score of 100 points, that is, the score of the aggregation array is 80 points.
[0159] This implementation method can fully reflect the severity of the problems that occur in the database request statements included in the aggregation array by presetting the evaluation level, so that the score can more accurately represent the situation of the database request, which helps to more accurately optimize the database request statements.
[0160] In some alternative implementation methods, step 202 can be executed as follows:
[0161] First, aggregate the database request statement set to obtain at least one initial aggregation array.
[0162] Then, based on the number of database request statements included in the sentence subsets corresponding to at least one initial aggregation array respectively, extract at least one aggregation array from the at least one initial aggregation array.
[0163] As an example, the initial aggregation arrays corresponding to the sentence subsets whose number of included database request statements exceeds the preset threshold can be determined as the above at least one aggregation array. For another example, the sentence subsets can be sorted in descending order according to the number of included database request statements, and the aggregation arrays corresponding to the preset number of sentence subsets ranked in the front can be determined as the above at least one aggregation array.
[0164] In this implementation manner, by extracting at least one aggregation array from at least one initial aggregation array according to the number of database request statements included in each language sentence set, the at least one extracted aggregation array can reflect the database request statements with a large usage amount, and filter out the database request statements with a small usage amount, which can improve the efficiency of generating request evaluation information, thereby helping to efficiently and targeted provide optimization suggestions for the database.
[0165] Exemplary Device
[0166] Figure 7 It is a schematic structural diagram of a database request evaluation device provided by an exemplary embodiment of the present disclosure. This embodiment can be applied to an electronic device, such as Figure 7 As shown, the database request evaluation device includes: an extraction module 701, configured to extract a set of database request statements of a preset type from a database log; an aggregation module 702, configured to aggregate the set of database request statements to obtain at least one aggregation array; a first determination module 703, configured to determine the databases respectively corresponding to the at least one aggregation array; a scoring module 704, configured to, for the aggregation arrays in the at least one aggregation array, parse the database request statements included in the aggregation array, and score the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array; a generation module 705, configured to generate request evaluation information for evaluating requests for the databases respectively corresponding to the at least one aggregation array based on the scores of the at least one aggregation array respectively.
[0167] In this embodiment, the extraction module 701 can extract a set of database request statements of a preset type from a database log. Among them, the database log can be a document for recording operations performed on databases in a database cluster. For example, the database log can be a BinLog document. The preset type of database request statements can be arbitrarily set in advance. For example, the preset type of database request statements can include insert, delete, update, and query statements, and can also include statements for using databases (such as use database xxx).
[0168] As an example, a log extraction service can be set up in the device. The log extraction collects data from the database cluster to obtain BinLog. There is a lot of information in BinLog. The log extraction service extracts the thread_id (proxy thread id), timestamp, exec_time (execution time consumption), info (specific request information), and event_type (operation type) from each BinLog. For statements with event_type of insert, delete, update, or query, they are stored as text logs one by one, that is, text logs containing a set of database request statements. The log name can be appended with database cluster information, such as cluster name, port, etc. Usually, considering the huge consumption of software and hardware resources caused by enabling BinLog, it can be selected to enable BinLog for a short period of time at regular intervals according to a preset cycle, for example, enabling it for 5 minutes every day.
[0169] In this embodiment, the aggregation module 702 can aggregate the set of database request statements to obtain at least one aggregation array. Specifically, aggregation refers to counting statements with the same or similar syntactic structures to obtain at least one set of sentence subsets. For each set of sentence subsets, a corresponding aggregation array is generated, that is, the same aggregation array corresponds to statements with the same syntactic structure or multiple similar syntactic structures.
[0170] The aggregation array can include one or more representative database request statements. For example, a database request statement whose execution time is closest to the average execution time of all database request statements corresponding to the aggregation array. Optionally, the aggregation array can also include other information, such as cluster information, table information, average execution time, the occurrence times of each corresponding statement, etc. Optionally, the aggregation array can also include all database request statements of a set of sentences after aggregation. Usually, the form of the aggregation array can be a json array.
[0171] In this embodiment, the first determination module 703 can determine the databases corresponding to at least one aggregation array respectively. As an example, if the database request statement is use database xxx, it is recorded as the database currently used by this thread according to the thread_id. If it is an insert, delete, update, or query statement, it is searched for which database this thread is currently using and recorded. Usually, since different databases perform different functions, and the set of sentence subsets corresponding to the same aggregation array has the same or similar syntactic structures, that is, they perform the same or similar functions, therefore, the set of sentence subsets corresponding to the same aggregation array targets the same database, and generally there will not be a situation where one aggregation array corresponds to multiple databases. Therefore, the database corresponding to each aggregation array can be determined.
[0172] In this embodiment, for the aggregation arrays in at least one aggregation array, the scoring module 704 may parse the database request statements included in the aggregation array, and score the database request statements included in the aggregation array based on the parsing results to obtain the score of the aggregation array.
[0173] Specifically, the scoring module 704 may build a syntax tree for the database request statements included in each aggregation array, and match and score each syntax data according to the preset scoring rules to obtain the score of each aggregation array. For example, assume that the database request statement included in a certain aggregation array is "select username,ismale from userinfo where age>20 and level>5 and 1=1". According to the rule, if a comparison condition that is always true like "1=1" appears, 20 points will be deducted from the initial score of 100 points, that is, the score of this aggregation array is 80 points.
[0174] It should be noted that the number of database request statements included in an aggregation array can be one or more. When it is one, scoring this one database request statement can obtain the score of the aggregation array; if it is multiple, these database request statements can be scored separately, and the average value of the scores (or any other arbitrarily set method) can be used as the score of the aggregation array.
[0175] In this embodiment, the generation module 705 may generate request evaluation information for evaluating requests for databases corresponding to at least one aggregation array respectively based on the scores of at least one aggregation array.
[0176] Among them, the request evaluation information is used to represent the quality of a subset of database request statements corresponding to a certain aggregation array. As an example, the request evaluation information may include scores, and may also include the level where the scores are located. In addition, it may also include specific reasons for deduction of points, improvement strategies, etc.
[0177] Refer to Figure 8 , Figure 8 is a schematic structural diagram of a database request evaluation device provided by another exemplary embodiment of the present disclosure.
[0178] In some optional implementation manners, the aggregation module 702 includes: an analysis unit 7021, configured to perform semantic analysis on the database request statements in the database request statement set to obtain at least one statement model; a first aggregation unit 7022, configured to aggregate the database request statement set based on at least one statement model to obtain at least one subset of statement sentences; a generation unit 7023, configured to generate at least one aggregation array based on at least one subset of statement sentences.
[0179] In some alternative implementation manners, the generating unit 7023 includes: an encoding subunit 70231, configured to determine a model encoding corresponding to at least one statement model for the statement models in at least one statement model; a determining subunit 70232, configured to determine an example statement from the set of statement sentences corresponding to the statement model; and a generating subunit 70233, configured to generate an aggregation array corresponding to the statement model based on the model encoding corresponding to the statement model and the example statement.
[0180] In some alternative implementation manners, the determining subunit 70232 is further configured to: determine an average execution time of a database request statement in the set of statement sentences corresponding to the statement model, and determine the database request statement with the statement execution time closest to the average execution time as the example statement; and / or, sort the database request statements in the set of statement sentences corresponding to the statement model according to the magnitudes of the statement execution times, and determine an example statement from the set of statement sentences corresponding to the statement model according to the sorting.
[0181] In some alternative implementation manners, the scoring module 704 is further configured to: parse the example statements included in the aggregation array, and score the example statements included in the aggregation array based on the parsing result to obtain a score of the aggregation array.
[0182] In some alternative implementation manners, the apparatus further includes: a second determining module 706, configured to determine an entity corresponding to each of at least one aggregation array based on a pre-established correspondence between an entity and a database; and a display module 707, configured to generate and display entity evaluation information corresponding to an entity in at least one entity based on the score of the aggregation array corresponding to the entity, and display database request evaluation information of the aggregation array corresponding to the entity.
[0183] In some alternative implementation manners, the display module 707 includes: a first determining unit 7071, configured to determine at least one service corresponding to the entity and an aggregation array corresponding to each of the at least one service; and a display unit 7072, configured to generate and display entity evaluation information corresponding to the entity and service evaluation information corresponding to each of the at least one service corresponding to the entity based on the score of the aggregation array corresponding to the entity, and display database request evaluation information of the aggregation array corresponding to the entity.
[0184] In some alternative implementations, the second determination module 706 includes: a second determination unit 7061, configured to determine, for an aggregation array in at least one aggregation array, an original entity to which the database corresponding to the aggregation array belongs from a preset basic correspondence table; a third determination unit 7062, configured to determine whether there is a corrected entity corresponding to the aggregation array from a preset correction correspondence table; a fourth determination unit 7063, configured to, if there is, determine the corrected entity as the entity corresponding to the aggregation array; and a fifth determination unit 7064, configured to, if not, determine the original entity as the entity corresponding to the aggregation array.
[0185] In some alternative implementations, the scoring module 704 includes: a sixth determination unit 7041, configured to determine an evaluation level corresponding to a database request statement included in the aggregation array based on the parsing result; and a seventh determination unit 7042, configured to determine a score of the aggregation array according to a preset scoring rule corresponding to the evaluation level.
[0186] In some alternative implementations, the aggregation module 702 includes: a second aggregation unit 7024, configured to aggregate a database request statement set to obtain at least one initial aggregation array; and an extraction unit 7025, configured to extract at least one aggregation array from the at least one initial aggregation array based on the number of database request statements included in the sentence sets corresponding to the at least one initial aggregation array.
[0187] The database request evaluation device provided in the above embodiments of the present disclosure extracts a database request statement set of a preset type from a database log, then aggregates the database request statement set to obtain at least one aggregation array, then determines databases corresponding to the at least one aggregation array respectively, then parses the database request statements included in the aggregation array, and scores the database request statements included in the aggregation array based on the parsing result to obtain scores of the aggregation array. Finally, based on the scores of the at least one aggregation array respectively, request evaluation information for evaluating requests for the database is generated, thereby implementing finding database request statements that need to be optimized according to the scores from a large number of database request statements, and at the same time, targeted optimization suggestions can be provided to users through the request evaluation information, which helps users optimize the database request statements through the request evaluation information.
[0188] Exemplary Electronic Device
[0189] Next, refer to Figure 9 to describe an electronic device according to an embodiment of the present disclosure. The electronic device may be, for example, Figure 1Any one or both of the terminal device 101 and the server 103 shown, or a stand-alone device independent of them, which can communicate with the terminal device 101 and the server 103 to receive the collected input signals from them.
[0190] Figure 9 The block diagram of an electronic device according to an embodiment of the present disclosure is illustrated.
[0191] As Figure 9 shown, the electronic device 900 includes one or more processors 901 and a memory 902.
[0192] The processor 901 may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 900 to perform desired functions.
[0193] The memory 902 may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage media, and the processor 901 may run the program instructions to implement the database request evaluation methods of the various embodiments of the present disclosure above and / or other desired functions. Various contents such as database logs and database request statements may also be stored in the computer-readable storage media.
[0194] In one example, the electronic device 900 may further include: an input device 903 and an output device 904, and these components are interconnected through a bus system and / or other forms of connection mechanisms (not shown).
[0195] For example, when the electronic device is the terminal device 101 or the server 103, the input device 903 may be a device such as a mouse or a keyboard for inputting contents such as database request statements. When the electronic device is a stand-alone device, the input device 903 may be a communication network connector for receiving the input database request statements and other contents from the terminal device 101 and the server 103.
[0196] The output device 904 may output various information to the outside, including request evaluation information. The output device 904 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0197] Of course, for simplicity, Figure 9Only some of the components related to the present disclosure in the electronic device 900 are shown, and components such as buses, input / output interfaces, etc. are omitted. In addition, according to specific application scenarios, the electronic device 900 may further include any other appropriate components.
[0198] Exemplary Computer Program Product and Computer Readable Storage Medium
[0199] In addition to the above methods and devices, embodiments of the present disclosure may also be computer program products, which include computer program instructions that, when run by a processor, cause the processor to execute the steps in the database request evaluation method according to various embodiments of the present disclosure described in the above "Exemplary Method" section of this specification.
[0200] The computer program product may be written in any combination of one or more programming languages for programming code to perform the operations of the embodiments of the present disclosure. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, executed as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0201] Furthermore, embodiments of the present disclosure may also be computer-readable storage media, on which computer program instructions are stored, and when the computer program instructions are run by a processor, cause the processor to execute the steps in the database request evaluation method according to various embodiments of the present disclosure described in the above "Exemplary Method" section of this specification.
[0202] The computer-readable storage medium may adopt any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0203] Exemplary Computer Program
[0204] Embodiments of the present disclosure also provide a computer program product, including computer programs / instructions, which can implement the database request evaluation method in any of the above possible implementation manners when executed by a processor.
[0205] This computer program product can be specifically implemented in the form of hardware, software, or a combination thereof. In an alternative example, this computer program product is specifically embodied as a computer storage medium. In another alternative example, this computer program product is specifically embodied as a software product, such as a Software Development Kit (SDK), etc.
[0206] The basic principles of the present disclosure have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, benefits, effects, etc. mentioned in the present disclosure are only examples and not limitations. It cannot be considered that these advantages, benefits, effects, etc. are essential for each embodiment of the present disclosure. Additionally, the above-disclosed specific details are only for illustrative and easy-to-understand purposes and not limitations. The above details do not limit the present disclosure to necessarily adopt the above specific details for implementation.
[0207] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For system embodiments, since they basically correspond to method embodiments, they are described relatively simply. For related parts, reference can be made to the partial description of the method embodiments.
[0208] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present disclosure are only illustrative examples and do not intend to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open-ended terms, meaning "including but not limited to", and can be used interchangeably with each other. The word "or" and "and" used herein refer to the word "and / or", and can be used interchangeably with each other unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to", and can be used interchangeably with each other.
[0209] The methods and apparatuses of the present disclosure can be implemented in many ways. For example, the methods and apparatuses of the present disclosure can be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of the steps for the methods is for illustration only. The steps of the methods of the present disclosure are not limited to the specific order described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure can also be implemented as a program recorded in a recording medium, and these programs include machine-readable instructions for implementing the methods according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the methods according to the present disclosure.
[0210] It should also be noted that in the apparatuses, devices, and methods of the present disclosure, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present disclosure.
[0211] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0212] The above description has been given for purposes of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although several example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and subcombinations thereof.
Claims
1. A database request evaluation method, comprising: extracting a set of database request statements of a preset type from a database log; aggregating the set of database request statements to obtain at least one aggregation array; determining the databases corresponding to the at least one aggregation array respectively; for an aggregation array in the at least one aggregation array, parsing the database request statements included in the aggregation array, and scoring the database request statements included in the aggregation array based on the parsing result to obtain a score of the aggregation array; generating request evaluation information for evaluating requests for the databases corresponding to the at least one aggregation array respectively based on the scores of the at least one aggregation array, where the request evaluation information is used to represent the quality of the sub - set of database request statements corresponding to the aggregation array; determining the entities corresponding to the at least one aggregation array respectively based on the pre - established correspondence between entities and databases; for an entity in the at least one entity, determining at least one service corresponding to the entity and the aggregation arrays corresponding to the at least one service respectively, generating and displaying entity evaluation information corresponding to the entity and service evaluation information corresponding to the at least one service corresponding to the entity respectively based on the scores of the aggregation arrays corresponding to the entity, and displaying the request evaluation information of the aggregation array corresponding to the entity.
2. The method according to claim 1, wherein The aggregating the set of database request statements to obtain at least one aggregation array includes: performing semantic analysis on the database request statements in the set of database request statements to obtain at least one statement model; aggregating the set of database request statements based on the at least one statement model to obtain at least one sub - set of sentences; generating at least one aggregation array based on the at least one sub - set of sentences.
3. The method according to claim 2, wherein, The generating at least one aggregation array based on the at least one sub - set of sentences includes: for a statement model in the at least one statement model, determining the model code corresponding to the statement model; determining an example statement from the sub - set of sentences corresponding to the statement model; generating an aggregation array corresponding to the statement model based on the model code and the example statement corresponding to the statement model.
4. The method according to claim 3, wherein, The determining an example statement from the sub - set of sentences corresponding to the statement model includes: determining the average execution time of the database request statements in the sub - set of sentences corresponding to the statement model, and determining the database request statement with the execution time closest to the average execution time as the example statement; and / or, sorting the database request statements in the sub - set of sentences corresponding to the statement model according to the size of the statement execution time, and determining an example statement from the sub - set of sentences corresponding to the statement model according to the sorting.
5. The method according to claim 3 or 4, wherein The parsing the database request statements included in the aggregation array and scoring the database request statements included in the aggregation array based on the parsing result to obtain a score of the aggregation array includes: parsing the example statements included in the aggregation array, and scoring the example statements included in the aggregation array based on the parsing result to obtain a score of the aggregation array.
6. The method according to claim 1, wherein Determining the entities corresponding to the at least one aggregation array based on the pre - established correspondence between entities and databases includes: For an aggregation array in the at least one aggregation array, determining the original entity to which the database corresponding to this aggregation array belongs from a preset basic correspondence table; Determining whether there is a corrected entity corresponding to this aggregation array from a preset corrected correspondence table; If it exists, determining the corrected entity as the entity corresponding to this aggregation array; If it does not exist, determining the original entity as the entity corresponding to this aggregation array.
7. The method according to claim 1, wherein, Scoring the database request statements included in the aggregation array based on the parsing result to obtain the score of the aggregation array includes: Based on the parsing result, determining the evaluation level corresponding to the database request statements included in this aggregation array; Determining the score of this aggregation array according to the preset scoring rules corresponding to the evaluation level; and / or, Aggregating the database request statement set to obtain at least one aggregation array includes: Aggregating the database request statement set to obtain at least one initial aggregation array; Based on the number of database request statements included in the sentence sets corresponding to the at least one initial aggregation array respectively, extracting the at least one aggregation array from the at least one initial aggregation array.
8. A computer - readable storage medium storing a computer program for executing the method according to any one of claims 1 - 7 above.
9. A computer program product including computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 - 7.
Citation Information
Patent Citations
Performance analysis method, performance analysis apparatus, storage medium and electronic apparatus
CN109240901A
Query statement management method and device, readable storage medium and electronic equipment
CN111949785A