Method for identifying database related elements and establishing data structure diagram

By building a data structure chart in a database instance and identifying the associated elements associated with the target SQL element, the problem of lack of effective identification of related SQL requests in the prior art is solved, and the efficiency of SQL optimization is improved.

CN113312431BActive Publication Date: 2025-05-06ALIBABA GROUP HOLDING LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010462483.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-27
Publication Date
2025-05-06
Estimated Expiration
2040-05-27

AI Technical Summary

Technical Problem

There is a lack of methods for effectively identifying related SQL requests in the prior art, which affects the efficiency of SQL optimization.

Method used

By constructing a data structure chart in a database instance, including a collection of vertices and an edge set, vertices represent SQL elements and edges represent the association relationship between SQL elements, and then identify the associated elements associated with the target SQL element.

Benefits of technology

The ability to identify related SQL requests is realized, providing strong support for the SQL optimization process, and improving the efficiency of SQL optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113312431B_ABST
    Figure CN113312431B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for identifying database associated elements and a method for establishing a data structure graph. The method comprises: determining a target element to be detected; analyzing the target element based on a data structure graph of a database instance to obtain associated elements associated with an SQL element associated with the target element, wherein the data structure graph comprises: a vertex set and an edge set, wherein the vertex set at least comprises: vertices for representing SQL elements in the database instance, and the edge set at least comprises: edges for representing the association relationship between SQL elements; and outputting associated elements corresponding to the target element. The present invention solves the technical problem that there is no effective solution for identifying related SQL requests in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of databases, and in particular to a method for identifying database associated elements and a method for establishing a data structure diagram. Background Art

[0002] Database Autonomy Service (DAS) provides self-optimization services for various database platforms to help users optimize database performance. Among them, SQL diagnostic optimization service is one of the core functions of DAS to provide database performance optimization. DAS's SQL diagnostic service generates optimization suggestions for SQL. Optimization suggestions include index addition and deletion suggestions, statement rewriting optimization suggestions, etc. Slow SQL optimization is an application scenario of SQL optimization service. The optimization of multiple slow SQL requests (SQL requests are also called SQL statements or SQL queries) may generate a large number of identical indexes and may also affect the execution plan of other SQL requests. Therefore, the index suggestion for a SQL request needs to consider related SQL requests, and the index set of related SQL requests needs to be deduplicated and integrated. In addition, the automatic optimization service is an autonomous service provided by DAS. Automatic optimization will automatically create indexes for database instances based on index suggestions, perform performance tracking in a timely manner after creation, and roll back in a timely manner when performance regression is found. In the tracking process, in addition to tracking the optimized SQL, it is also necessary to track the performance of related SQL. Therefore, it is necessary to identify related SQL requests.

[0003] However, in the related art, there is no technical means to identify related SQL requests, which affects the optimization efficiency of SQL.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiment of the present invention provides a method for identifying database related elements and a method for establishing a data structure diagram, so as to at least solve the technical problem that there is no effective solution for identifying related SQL requests in the related art.

[0006] According to one aspect of an embodiment of the present invention, a method for identifying associated elements in a database instance is provided, comprising: determining a target element to be detected, wherein the target element is an SQL element in an SQL database; analyzing the target element based on a data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph comprises: a vertex set and an edge set, wherein the vertex set comprises at least: vertices for representing SQL elements in the database instance, and the edge set comprises at least: edges for representing association relationships between SQL elements; and outputting associated elements corresponding to the target element.

[0007] According to another aspect of an embodiment of the present invention, a method for establishing a data structure graph is also provided, comprising: obtaining at least one SQL template in a database instance; parsing at least one SQL template to obtain a first parsed content, wherein the first parsed content at least comprises: associated elements associated with constituent elements of at least one SQL template; generating a data structure graph based at least on the constituent elements and associated elements associated with the constituent elements, wherein the data structure graph comprises: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements.

[0008] According to another aspect of an embodiment of the present invention, a method for identifying associated elements in a database instance is also provided, comprising: receiving an SQL request, and obtaining a target element in the database instance from the SQL request; analyzing the target element based on a data structure graph of the database instance, and obtaining an associated element associated with the target element, wherein the data structure graph comprises: a vertex set and an edge set, wherein the vertices in the vertex set comprise: vertices for representing different SQL requests and vertices for representing SQL elements in the database instance, and the edge set comprises: edges for representing an association relationship between different SQL requests and SQL elements in the database instance, and edges for representing an association relationship between SQL elements; and outputting an associated element corresponding to the target element.

[0009] According to another aspect of the present invention, a method for optimizing elements in a database instance is provided, which includes: receiving an optimization request from a target object, wherein the optimization request carries a target element to be optimized, wherein the target element is a SQL element in a SQL database; obtaining an associated element having an association relationship with the target element; and optimizing the index of the target element and the index of the associated element.

[0010] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided. The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute any method for identifying associated elements in a database instance.

[0011] According to another aspect of an embodiment of the present invention, a computing device is also provided, including: a processor; and a memory, connected to the processor, for providing the processor with instructions for processing the following processing steps: determining a target element to be detected in a database instance, wherein the target element is an SQL element in an SQL database; analyzing the target element based on a data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements; and outputting the associated elements corresponding to the target element.

[0012] In an embodiment of the present invention, a method of identifying related SQL is adopted. First, a target element to be detected in a database instance is determined. Secondly, the target element is analyzed based on a data structure diagram of the database instance to obtain associated elements associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements. Finally, the associated elements corresponding to the target elements are output, thereby achieving the purpose of identifying related SQL, thereby providing strong support for the SQL optimization process, and further solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0014] Figure 1 It is a hardware structure framework diagram of a computer terminal according to a method for identifying associated elements in a database instance according to an embodiment of the present invention;

[0015] Figure 2a is a flow chart of a method for identifying associated elements in a database instance according to an embodiment of the present invention;

[0016] Figure 2b It is a schematic diagram of a main process framework of an optional method for obtaining SQL related to a database embodiment according to an embodiment of the present invention;

[0017] Figure 2c is a schematic diagram of an optional construction of a graph data model according to an embodiment of the present invention;

[0018] Figure 3 is a schematic flow chart of a method for establishing a data structure graph according to an embodiment of the present invention;

[0019] Figure 4 is a flow chart of an element optimization method in a database instance according to an embodiment of the present invention;

[0020] Figure 5 is a schematic diagram of the structure of a device for identifying associated elements in a database instance according to an embodiment of the present invention;

[0021] Figure 6 is a structural block diagram of a computer device according to an embodiment of the present invention;

[0022] Figure 7 It is a flow chart of a method for identifying associated elements in a database instance implemented according to the present invention. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0025] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0026] DAS: Database Autonomy Service is a cloud service that achieves database self-perception, self-repair, self-optimization, self-operation and self-security based on machine learning and expert experience. It helps users eliminate the complexity of database operation and maintenance and service failures caused by manual operations, and effectively ensures the stability, security and efficiency of database services.

[0027] SQL (Structured Query Language) is a special-purpose programming language used to manage relational database management systems (RDBMS) or for stream processing in relational stream data management systems (RDSMS). SQL is based on relational algebra and tuple-relational calculus and includes a data definition language and a data manipulation language. The scope of SQL includes data insertion, query, update and deletion, database schema creation and modification, and data access control.

[0028] T1.C1: T is the abbreviation of table, which means a table in a database; C is the abbreviation of column, which means a column in a database; T1.C1 means column C1 in table T1; the meanings of other combinations in this application can be deduced accordingly.

[0029] Related SQL: In the database field, related SQL refers to multiple SQL queries in a database instance that target the same target table, or multiple SQL predicates point to the same column. Related SQLs will affect each other during actual execution, and may even cause lock waits; related SQLs may use the same or similar indexes. Adding index optimization to one of the SQLs may affect the execution plan of other SQLs.

[0030] SQL automatic optimization: In the database field, in order to improve the overall performance of the database, database vendors automatically recommend indexes for the database and run them online during low business hours. At the same time, they monitor the performance of the database for rapid rollback or profit calculation.

[0031] Graph computing: Abstractly express the entities in the information and the relationships between them as “graph” structured data of vertices and edges between vertices, and perform relationship analysis based on this data structure.

[0032] Example 1

[0033] According to an embodiment of the present invention, a method embodiment for identifying associated elements in a database instance is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0034] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 The hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for identifying associated elements in a database instance is shown. Figure 1As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0035] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0036] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the identification method of associated elements in the database example in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, to implement the vulnerability detection method of the above-mentioned application program. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0037] The transmission module 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0038] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).

[0039] Under the above operating environment, this application provides Figure 2a A method for identifying associated elements in the database instance shown. Figure 2a 4 is a flowchart of a method for identifying associated elements in a database instance according to Embodiment 1 of the present invention.

[0040] like Figure 2a As shown, the method for identifying associated elements in a database instance of the first embodiment of the present invention may include the following steps:

[0041] Step S202, determining a target element to be detected, wherein the target element is a SQL element in a SQL database;

[0042] Step S204: Analyze the target element based on the data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertex set includes at least: vertices for representing SQL elements in the database instance, and the edge set includes at least: edges for representing association relationships between SQL elements;

[0043] Step S206: output the associated element corresponding to the target element.

[0044] In the above-mentioned embodiment of the present application, first, the target element to be detected is determined, and secondly, the target element is analyzed based on the data structure diagram of the database instance to obtain the associated elements associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertex set includes at least: vertices for representing SQL elements in the database instance, and the edge set includes at least: edges for representing the association relationship between SQL elements; finally, the associated elements corresponding to the target element are output, so as to achieve the purpose of identifying related SQL, thereby providing strong support for the SQL optimization process, and further solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology.

[0045] In some embodiments of the present application, the data structure diagram is determined in the following manner: obtaining at least one SQL template in a database instance; parsing at least one SQL template to obtain a first parsed content, the first parsed content at least including: associated elements associated with constituent elements of at least one SQL template; establishing a data structure diagram based at least on the associated elements associated with the constituent elements. For example, parsing SQL template 1 to obtain an element composed of SQL1 that contains field T2.C1, and T2.C2 is included in the composition of the SQL template 2 element, then T2 is an associated element of the above two templates, therefore, a data structure diagram can be established based on the element T2, and it should be noted that the above associated elements at least include but are not limited to: predicates, join conditions, sorting fields, aggregation fields, projection fields, etc. associated between SQL requests.

[0046] When obtaining the SQL template, there can be multiple implementation methods, for example: obtaining the full SQL flow information in the database corresponding to the database instance; parsing the full SQL flow information to obtain the second parsed content, wherein the second parsed content can be the SQL statement within the specified time interval; the second parsed content can be formatted first to obtain the initial SQL template, and then the initial SQL template can be deduplicated to obtain the SQL template. Specifically, the full SQL flow information can be transparently transmitted through the database kernel, and the SQL flow information can be parsed through real-time calculation and offline calculation, and the SQL can be formatted and templated after removing parameters to obtain the SQL template, wherein the above-mentioned SQL template can be the SQL template within the specified time interval of the database instance.

[0047] Among them, the vertices used to represent the SQL elements in the database instance include the following vertices: the field vertices corresponding to the fields in the database instance, and the table vertices corresponding to the tables in the database instance; at this time, the edges used to represent the association relationship between the SQL elements include edges used to indicate the following relationships: the relationship between the fields; the relationship between the table vertex and the field vertex, wherein the SQL elements can be fields, tables, etc. in the database embodiment. Among them, each vertex in the vertex set can include the type and attributes of the vertex, for example, the SQL vertex includes information such as the vertex type and the unique identifier of the SQL template; in the edge set, the relationship between the table vertex and the field vertex can be a belonging relationship. A relationship is established between the SQL request and the field, and different types of relationships are established according to the type of the field associated with the SQL request, such as: predicate relationship, connection field relationship, sorting field relationship, aggregation field relationship, projection field relationship, etc.

[0048] In some optional embodiments, the table vertices and the field vertices may be merged into one type of vertices to obtain target vertices; and a data structure graph may be established based on the association relationship between the target vertices.

[0049] In other optional embodiments, the vertex set also includes: vertices corresponding to different SQL requests; and / or the vertex set also includes the following vertices: index vertices corresponding to the index of the SQL request; the edge set also includes: edges for indicating the relationship between the table and the index, edges for indicating the relationship between the SQL request and the index, for example, by introducing index vertices, recording the relationship between the table and the index, and the relationship between the SQL request and the index, a data structure diagram of four types of vertices is constructed.

[0050] In some optional embodiments of the present application, the data structure graph may also be determined in the following manner: for example, table vertices and field vertices are merged into one type of vertices to construct a data structure graph of two types of vertices.

[0051] In some embodiments of the present application, after determining the data structure graph, in order to obtain relevant SQL requests, relevant SQL requests can be obtained through graph computing. For example, a connected graph algorithm can be implemented, where the connected graph algorithm has multiple implementation methods; or an existing graph computing method provided by a third party can be used, such as: the Connected Component Vetex Program provided by Apache Tinker Pop.

[0052] In some embodiments of the present application, methods for obtaining relevant SQL requests include but are not limited to: identifying relevant SQL requests by matching predicate strings or using relevant SQL requests identified by the user as training data and establishing a machine learning model through AI technology.

[0053] In some embodiments of the present application, after determining the data structure graph, different types of related SQL requests can be obtained based on graph calculation. For example, given a table, obtain all SQL sets related to the table, given a SQL request, obtain the SQL set related to the SQL request, obtain related SQL according to the SQL request, and customize the set of related SQL, such as calculating the correlation coefficient according to the number of associated edges, finding the most relevant SQL request according to the correlation coefficient, finding related SQL requests for a given column, finding related columns for a given column, finding related tables for a given table, etc.

[0054] In the related art, SQLAdvisor of commercial database vendors such as Microsoft SQL Server / Oracle / IBM DB2 has the function of optimizing a single SQL request, but when diagnosing and optimizing a single SQL request, it does not consider the impact of related SQLs. Therefore, when diagnosing multiple SQL requests, duplicate or identical indexes will be generated, and the generated indexes will affect the execution path of other SQL requests, which will lead to low index accuracy and a certain impact on the execution efficiency of other SQL requests. Among them, index refers to the data structure that helps MYSQL to efficiently obtain data, which can be divided into two categories: clustered index and non-clustered index, where the order of clustered index is the physical storage order of data, and the index and data are stored in the same file; non-clustered index: the order of clustered index is different from the physical storage order of data, and the index and data are stored in the same file.

[0055] To solve the above problems, the embodiment of the present application can optimize the relevant SQL requests. At this time, the step of determining the target element to be detected can be implemented in the following manner: receiving an optimization request from the target object, wherein the optimization request carries the target element; analyzing the target element based on the data structure diagram of the database instance, obtaining the associated elements associated with the target element, and obtaining the first index corresponding to the target element, and the index set of the associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set, and integrating the indexes includes: segment-based merging (for example, merging according to the number of segment documents) and sub-directory-based merging (merging the directory to be merged into the specified directory or merging the directory to be merged into the new directory). Deduplication refers to removing duplicate indexes. For example, when the target element is field C1, the index information of this field includes ab, abc, and the SQL element associated with the target element is field C2. The index information of field C2 includes abc, abd, and abe. Then, integration and deduplication can be performed, which removes abc common to the above two indexes, thereby making the retrieval more accurate. It should be noted that there may be multiple indexes of associated elements associated with the target element.

[0056] It should be noted that the target element includes: the table corresponding to the database instance; the associated elements corresponding to the target element include: the SQL request set or table set associated with the table; and / or the target element includes: the column corresponding to the database instance; the associated elements corresponding to the target element include: the column set or SQL request set associated with the column; and / or the target element includes: the target SQL request; the associated elements corresponding to the target element include: the SQL request set associated with the target SQL request.

[0057] In some embodiments of the present application, the set of SQL requests associated with the target SQL request can also be determined in the following manner: determine the number of edges associated with the target SQL request in the data structure graph to determine the correlation coefficient, wherein the edges associated with the target SQL request include: edges between vertices passed from the vertex corresponding to the target SQL request to the target associated vertex, wherein the target associated vertex is the vertex corresponding to the SQL request associated with the target SQL request; determine the SQL request associated with the target SQL request based on the correlation coefficient, and store the SQL request associated with the target SQL request in the SQL request set.

[0058] Figure 2b FIG. 1 is a main flow chart of an optional method for obtaining SQL requests related to a database instance in an embodiment of the present invention. Figure 2b , the process framework diagram mainly includes the following steps:

[0059] Step 1: Get the full SQL, specifically, get all SQL templates within the specified time interval of the database instance. When getting the full SQL of the database instance, you can transparently transmit the full SQL flow information through the database kernel, parse the SQL flow information through real-time and offline calculations, format the SQL, remove parameters, and then template it, then deduplicate based on the full SQL template of the database instance to get the full SQL template information on the database instance.

[0060] Step 2: SQL parsing, that is, parsing all SQL templates to obtain the predicates, connection conditions, sorting fields, aggregation fields, projection fields, etc. associated with each SQL request.

[0061] Step 3: Construct a data structure diagram. There are many modeling methods for constructing a data structure diagram. This embodiment only uses one construction method as an example. Figure 2c It is an optionally constructed graph data model in the embodiment of the present application.

[0062] like Figure 2c As shown in the figure, according to the SQL parsing results, SQL is associated with the column to build a data structure diagram, which can be expressed as a graph data model, in which vertices are represented by circles, for example, T1.C1; edges are represented by straight lines with arrows. In this model, there are three types of vertices: SQL vertex, field vertex, and table vertex. For example, SQL1 is a SQL vertex, T1.C1 represents the C1 column in the T1 table, which is a field vertex, and T2 is a T2 table vertex. It should be noted that each vertex can include the type and attributes of the vertex; for example, the SQL vertex includes information such as the vertex type and the unique identifier of the SQL template. A relationship is established between SQL and the field, such as the relationship between SQL1 and T1C1. Different types of relationships are established according to the type of SQL associated fields, such as predicate relationship, connection field relationship, sorting field relationship, aggregation field relationship, projection field relationship, etc. The relationship between table vertices and field vertices is a belonging relationship, for example, the field vertex T2.C2 belongs to the T2 table vertex. It should be noted that Select (field 1, field 2, ...) from (table name) where (condition) is a query data statement.

[0063] Step 4: Graph computing. Specifically, after the data structure graph model is built, the relevant SQL is obtained through graph computing. There are many ways to perform graph computing. You can implement a connected graph algorithm or use existing graph computing methods provided by a third party. For example, Apache Tinker Pop provides the Connected Component Vetex Program.

[0064] Step 5: Get relevant SQL. Specifically, after building a data structure diagram and graph-based computing, you can get different types of relevant SQL requests or related schemas, for example:

[0065] (1) Given a table, get all SQL sets related to the table.

[0066] (2) Given a SQL request, obtain a set of SQLs related to the SQL. Obtain related SQLs based on the SQL, and you can customize the set of related SQLs. For example, calculate the correlation coefficient based on the number of associated edges, and find the most relevant SQL request based on the correlation coefficient.

[0067] (3) Given a column, find related SQL requests.

[0068] (4) Given a column, find related columns.

[0069] (5) Given a table, find related tables.

[0070] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0071] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0072] Example 2

[0073] According to an embodiment of the present invention, an embodiment of a method for establishing a data structure diagram is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0074] The method embodiment provided in the second embodiment of the present application can still be executed in a mobile terminal, a computer terminal or a similar computing device. It should be noted here that the method embodiment provided in the second embodiment can still be executed in Figure 1 on the computer terminal shown.

[0075] Under the above operating environment, this application provides Figure 3 The method for establishing the data structure diagram shown. Figure 3 It is a flowchart of a method for establishing a data structure diagram according to the second embodiment of the present invention.

[0076] S302, obtaining at least one SQL template in a database instance;

[0077] S304, parsing at least one SQL template to obtain first parsed content, where the first parsed content at least includes: associated elements associated with constituent elements of at least one SQL template;

[0078] S306, generating a data structure graph based at least on the constituent elements and associated elements associated with the constituent elements, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements.

[0079] In the above embodiment, at least one SQL template in a database instance is obtained; at least one SQL template is parsed to obtain a first parsed content, wherein the first parsed content includes at least: associated elements associated with constituent elements of at least one SQL template; finally, a data structure graph is generated based at least on the constituent elements and associated elements associated with the constituent elements, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements, thereby achieving a technical effect of quickly constructing a data graph.

[0080] Specifically, the full amount of SQL flow information can be transparently transmitted through the database kernel, and the SQL flow information can be parsed through real-time calculation and offline calculation, and the SQL can be formatted and templated after removing parameters to obtain an SQL template, wherein the above SQL template can be an SQL template within a specified time interval of the database instance.

[0081] Optionally, the vertices used to represent SQL elements in a database instance include the following vertices: field vertices corresponding to fields in a database instance, and table vertices corresponding to tables in a database instance; the edges used to represent association relationships between SQL elements include edges used to indicate the following relationships: relationships between fields; relationships between table vertices and field vertices. Each vertex in the vertex set may include vertex type and attributes, for example, an SQL vertex includes information such as a vertex type and a unique identifier of an SQL template; in an edge set, the relationship between a table vertex and a field vertex may be a belonging relationship. A relationship is established between SQL and a field, and different types of relationships are established according to the type of SQL associated field, such as predicate relationships, connection field relationships, sorting field relationships, aggregation field relationships, and projection field relationships.

[0082] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0083] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0084] Example 3

[0085] According to an embodiment of the present invention, an embodiment of an element optimization method in a database instance is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0086] The method embodiment provided in the third embodiment of the present application can still be executed in a mobile terminal, a computer terminal or a similar computing device. It should be noted here that the method embodiment provided in the third embodiment can still be executed in Figure 1 on the computer terminal shown.

[0087] Under the above operating environment, this application provides Figure 4 Element optimization method in the database instance shown. Figure 4 It is a flowchart of an element optimization method in a database instance according to the second embodiment of the present invention.

[0088] S402, receiving an optimization request from a target object, wherein the optimization request carries a target element to be optimized;

[0089] S404, obtaining an associated element that has an associated relationship with the target element;

[0090] S406, optimize the index of the target element and the index of the associated element.

[0091] In the above embodiment, an optimization request from a target object is received, wherein the optimization request carries a target element to be optimized; secondly, an associated element having an associated relationship with the target element can be obtained; finally, the index of the target element and the index of the associated element are optimized to achieve the purpose of optimizing the index and the purpose of identifying related SQL, thereby providing strong support for the SQL optimization process and further solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology.

[0092] It should be noted that optimizing the index of the target element and the index of the associated element includes but is not limited to: integrating and deduplicating.

[0093] In some embodiments of the present application, the target element includes: a table corresponding to a database instance; the associated elements corresponding to the target element include: a set of SQL statements or a set of tables associated with the table; and / or the target element includes: a column corresponding to the database instance; the associated elements corresponding to the target element include: a set of columns or a set of SQL statements associated with the column.

[0094] In some embodiments of the present application, the target element includes: a table corresponding to the database instance; the associated elements corresponding to the target element include: a SQL request set or a table set associated with the table; and / or the target element includes: a column corresponding to the database instance; the associated elements corresponding to the target element include: a column set or a SQL request set associated with the column; and / or the target element includes: a target SQL request; the associated elements corresponding to the target element include: a SQL request set associated with the target SQL request.

[0095] In some embodiments of the present application, the set of SQL requests associated with the target SQL request can be determined in the following manner: determine the number of edges associated with the target SQL request in the data structure graph to determine the correlation coefficient, wherein the edges associated with the target SQL request include: edges between vertices passed from the vertex corresponding to the target SQL request to the target associated vertex, wherein the target associated vertex is the vertex corresponding to the SQL request associated with the target SQL request; determine the SQL request associated with the target SQL request based on the correlation coefficient, and store the SQL request associated with the target SQL request in the SQL request set.

[0096] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0098] Example 4

[0099] According to an embodiment of the present invention, there is also provided an identification device for implementing the identification method of the associated element in the above database instance, such as Figure 5 As shown, the device comprises:

[0100] A determination module 50, used to determine a target element to be detected;

[0101] The analysis module 52 is used to analyze the target element based on the data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertex set at least includes: vertices for representing SQL elements in the database instance, and the edge set at least includes: edges for representing association relationships between SQL elements;

[0102] The output module 54 is used to output the associated element corresponding to the target element.

[0103] In the identification device of the method for identifying associated elements in the above-mentioned database instance, the determination module is used to determine the target element to be detected; the analysis module is used to analyze the target element based on the data structure diagram of the database instance to obtain the associated elements associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertex set at least includes: vertices used to represent SQL elements in the database instance, and the edge set at least includes: edges used to represent the association relationship between SQL elements; the output module is used to output the associated elements corresponding to the target element, thereby achieving the purpose of identifying related SQL, thereby providing strong support for the SQL optimization process, and further solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology.

[0104] In some embodiments of the present application, the above-mentioned analysis module 52 is used to obtain at least one SQL template in a database instance; parse at least one SQL template to obtain a first parsed content, which at least includes: associated elements associated with constituent elements of at least one SQL template; and establish a data structure diagram based on at least the associated elements associated with the constituent elements. It should be noted that the above-mentioned associated elements at least include but are not limited to: predicates, connection conditions, sorting fields, aggregation fields, projection fields, etc. associated between SQL requests. For example, when SQL template 1 is parsed and the elements composed of SQL1 contain field T2.C1, and the elements in SQL template 2 contain T2.C2, then T2 is the associated element of the above two templates, and therefore, a data structure diagram can be established based on the element T2.

[0105] In some embodiments of the present application, the above-mentioned analysis module is also used to obtain at least one SQL template in the database instance, including: obtaining the full SQL flow information in the database corresponding to the database instance; parsing the full SQL flow information to obtain a second parsed content, wherein the second parsed content may be an SQL statement within a specified time interval; formatting the second parsed content to obtain an initial SQL template; and then deduplicating the initial SQL template to obtain an SQL template. Specifically, the full SQL flow information can be transparently transmitted through the database kernel, and the SQL flow information can be parsed through real-time calculation and offline calculation, and the SQL is formatted and templated after removing parameters to obtain an SQL template, wherein the above-mentioned SQL template may be an SQL template within a specified time interval of the database instance.

[0106] In some optional embodiments of the present application, the vertices used to represent SQL elements in a database instance include the following vertices: field vertices corresponding to fields in a database instance, and table vertices corresponding to tables in a database instance; the edges used to represent the association relationship between SQL elements include edges used to indicate the following relationships: relationships between fields; relationships between table vertices and field vertices, wherein SQL elements may be fields, tables, etc. in a database embodiment. Each vertex in the vertex set may include vertex type and attributes, for example, an SQL vertex includes information such as a vertex type and a unique identifier of an SQL template; in an edge set, the relationship between a table vertex and a field vertex may be a belonging relationship. A relationship is established between a SQL request and a field, and different types of relationships are established according to the type of the field associated with the SQL request, such as a predicate relationship, a connection field relationship, a sorting field relationship, an aggregation field relationship, a projection field relationship, etc.

[0107] In some embodiments of the present application, the table vertices and the field vertices may be merged into a type of vertex to obtain a target vertex; and a data structure graph may be established based on the association relationship between the target vertices.

[0108] In some embodiments of the present application, the vertex set also includes: vertices corresponding to different SQL requests; and / or the vertex set also includes the following vertices: index vertices corresponding to the index of the SQL request; the edge set also includes: edges used to indicate the relationship between the table and the index, edges used to indicate the relationship between the SQL request and the index. For example, by introducing index vertices, recording the relationship between the table and the index, and the relationship between the SQL request and the index, a data structure diagram of four types of vertices is constructed.

[0109] In an optional embodiment of the present application, the data structure graph may also be determined in the following manner: for example, table vertices and field vertices are merged into one type of vertices to construct a data structure graph of two types of vertices.

[0110] In some embodiments of the present application, after determining the data structure graph, in order to obtain relevant SQL requests, relevant SQL requests can be obtained through graph computing, for example, through a connected graph algorithm, or by using an existing graph computing method provided by a third party, such as: the Connected Component Vetex Program provided by Apache Tinker Pop.

[0111] In some embodiments of the present application, methods for obtaining relevant SQL requests include but are not limited to: identifying relevant SQL requests by matching predicate strings or by identifying correlations on the user side as training data, and establishing a machine learning model through AI technology.

[0112] In some embodiments of the present application, after determining the data structure graph, different types of related SQL requests can be obtained based on graph calculation. For example, given a table, obtain all SQL sets related to the table, given a SQL request, obtain the SQL set related to the SQL request, obtain related SQL according to the SQL request, and customize the set of related SQL, such as calculating the correlation coefficient according to the number of associated edges, finding the most relevant SQL request according to the correlation coefficient, finding related SQL requests for a given column, finding related columns for a given column, finding related tables for a given table, etc.

[0113] In an optional embodiment of the present application, a determination module is used to receive an optimization request from a target object, wherein the optimization request carries a target element; after analyzing the target element based on a data structure diagram of a database instance to obtain associated elements associated with the target element, the method further includes: obtaining a first index corresponding to the target element, and an index set of associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set.

[0114] It should be noted that the target element may be: a table corresponding to a database instance; the associated elements corresponding to the target element include: a SQL request set or a table set associated with the table; and / or the target element includes: a column corresponding to the database instance; the associated elements corresponding to the target element include: a column set or a SQL request set associated with the column; and / or the target element includes: a target SQL request; the associated elements corresponding to the target element include: a SQL request set associated with the target SQL request.

[0115] In some embodiments of the present application, the analysis module 52 is further used to determine the number of edges associated with the target SQL request in the data structure diagram to determine a correlation coefficient, wherein the edges associated with the target SQL request include: edges between vertices passed from a vertex corresponding to the target SQL request to a target associated vertex, wherein the target associated vertex is a vertex corresponding to a SQL request associated with the target SQL request; determining the SQL request associated with the target SQL request based on the correlation coefficient, and storing the SQL request associated with the target SQL request in a SQL request set.

[0116] It should be noted that the above-mentioned determination module 50, analysis module 52 and output module 54 correspond to steps S202 to S206 in Example 1, and the three modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules, as part of the device, can be run in the computer terminal 10 provided in Example 1.

[0117] Example 5

[0118] The embodiment of the present invention may provide a computing device, which may be any computing device in a computing device group. Optionally, in this embodiment, the computing device may also be replaced by a terminal device such as a mobile terminal.

[0119] Optionally, in this embodiment, the computing device may be located in at least one network device among a plurality of network devices of a computer network.

[0120] In this embodiment, the above-mentioned computing device can execute the program code of the following steps in the vulnerability detection method of the application: determining the target element to be detected in the database instance, wherein the target element is an SQL element in the SQL database; analyzing the target element based on the data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements; outputting the associated elements corresponding to the target elements.

[0121] In the above-mentioned embodiment of the present application, first, the target element to be detected in the database instance is determined, and secondly, the target element is analyzed based on the data structure diagram of the database instance to obtain the associated elements associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements; finally, the associated elements corresponding to the target element are output, so as to achieve the purpose of identifying related SQL, thereby providing strong support for the SQL optimization process, and further solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology.

[0122] Optionally, Figure 6 is a structural block diagram of a computing device according to an embodiment of the present invention. Figure 6 As shown, the computing device 60 may include: one or more (only one is shown in the figure) processors 602 and a memory 604 .

[0123] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for identifying the associated elements in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the method for identifying the associated elements in the above-mentioned database instance is realized. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the terminal A via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0124] The processor can call the information and application stored in the memory through the transmission module to perform the following steps: determine the target element to be detected in the database instance; analyze the target element based on the data structure diagram of the database instance to obtain the associated element associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent the SQL elements in the database instance, and the edges in the edge set are used to represent the association relationship between the SQL elements; and output the associated element corresponding to the target element.

[0125] Optionally, the processor may also execute the program code of the following steps: determining a target element to be detected; analyzing the target element based on a data structure diagram of the database instance to obtain associated elements associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertex set includes at least: vertices for representing SQL elements in the database instance, and the edge set includes at least: edges for representing association relationships between SQL elements; and outputting associated elements corresponding to the target element.

[0126] Optionally, the processor may also execute program code of the following steps: obtaining at least one SQL template in a database instance; parsing at least one SQL template to obtain a first parsed content, wherein the first parsed content includes at least: associated elements associated with constituent elements of at least one SQL template; and establishing a data structure diagram at least based on the associated elements associated with the constituent elements.

[0127] Optionally, the processor may also execute the following steps of program code: obtaining the full SQL flow information in the database corresponding to the database instance; parsing the full SQL flow information to obtain a second parsed content; formatting the second parsed content to obtain an initial SQL template; deduplicating the initial SQL template to obtain at least one SQL template. Specifically, the full SQL flow information may be transparently transmitted through the database kernel, and the SQL flow information may be parsed through real-time calculation and offline calculation, and the SQL may be formatted and templated after removing parameters to obtain an SQL template, wherein the SQL template may be an SQL template within a specified time interval of the database instance.

[0128] Optionally, the processor may further execute the program code of the following steps: obtaining the full SQL flow information in the database corresponding to the database instance; parsing the full SQL flow information to obtain the second parsed content; formatting the second parsed content to obtain the initial SQL template; deduplicating the initial SQL template to obtain at least one SQL template.

[0129] Optionally, the processor may also execute program codes of the following steps: merging table vertices and field vertices into one type of vertex to obtain a target vertex; and establishing a data structure graph based on the association relationship between the target vertices.

[0130] Optionally, the processor may also execute program code for the following steps: determining a target element to be detected, including: receiving an optimization request from a target object, wherein the optimization request carries a target element; analyzing the target element based on a data structure diagram of a database instance, and obtaining associated elements associated with the target element, the method further comprising: obtaining a first index corresponding to the target element, and an index set of associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set.

[0131] Optionally, the processor may also execute the program code of the following steps: determining the number of edges associated with the target SQL request in the data structure diagram to determine a correlation coefficient, wherein the edges associated with the target SQL request include: edges between vertices passed from a vertex corresponding to the target SQL request to a target associated vertex, wherein the target associated vertex is a vertex corresponding to the SQL request associated with the target SQL request; determining the SQL request associated with the target SQL request based on the correlation coefficient, and storing the SQL request associated with the target SQL request in a SQL request set.

[0132] According to an embodiment of the present invention, a method of identifying related SQL is adopted. First, a target element to be detected is determined. Secondly, the target element is analyzed based on a data structure diagram of a database instance to obtain associated elements associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertex set includes at least: vertices for representing SQL elements in the database instance, and the edge set includes at least: edges for representing the association relationship between SQL elements. Finally, the associated elements corresponding to the target element are output, thereby achieving the purpose of identifying related SQL, thereby solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology.

[0133] It can be understood by those skilled in the art that Figure 6 The structure shown is for illustration only, and the computing device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 6 The structure of the electronic device is not limited. For example, the computing device 60 may also include Figure 6 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 6 Different configurations are shown.

[0134] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0135] The embodiment of the present invention further provides a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the method for identifying associated elements in the database instance provided in the first embodiment.

[0136] Optionally, in this embodiment, the above storage medium may be located in any one of the computing devices in the computing device group in the computer network, or in any one of the mobile terminals in the mobile terminal group.

[0137] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: determining a target element to be detected; analyzing the target element based on a data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertex set includes at least: vertices for representing SQL elements in the database instance, and the edge set includes at least: edges for representing association relationships between SQL elements; and outputting associated elements corresponding to the target element.

[0138] Example 6

[0139] According to an embodiment of the present invention, an embodiment of a method for identifying associated elements in a database instance is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0140] The method embodiment provided in the sixth embodiment of the present application can still be executed in a mobile terminal, a computer terminal or a similar computing device. It should be noted here that the method embodiment provided in the sixth embodiment can still be executed in Figure 1 on the computer terminal shown.

[0141] Under the above operating environment, this application provides Figure 7 A method for identifying associated elements in the database instance shown. Figure 7 4 is a flow chart of a method for identifying associated elements in a database instance according to Embodiment 6 of the present invention.

[0142] S702, receiving an SQL request, and obtaining a target element in a database instance from the SQL request;

[0143] S704, analyzing the target element based on the data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set include: vertices for representing different SQL requests and vertices for representing SQL elements in the database instance, and the edge set includes: edges for representing associations between different SQL requests and SQL elements in the database instance, and edges for representing associations between SQL elements;

[0144] S706, output the associated element corresponding to the target element.

[0145] In the above embodiment, first, an SQL request can be received, and a target element in a database instance can be obtained from the SQL request; secondly, the target element is analyzed based on a data structure diagram of the database instance to obtain an associated element associated with the target element, wherein the data structure diagram includes: a vertex set and an edge set, wherein the vertices in the vertex set include: vertices for representing different SQL requests and vertices for representing SQL elements in the database instance, and the edge set includes: edges for representing the association relationship between different SQL requests and SQL elements in the database instance, and edges for representing the association relationship between SQL elements; finally, the associated element corresponding to the target element is output, so as to achieve the purpose of identifying related SQL, thereby providing strong support for the SQL optimization process, and further solving the technical problem that there is no effective solution for identifying related SQL requests in the related technology.

[0146] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0147] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.

[0148] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0149] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0150] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0151] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0152] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0153] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.

[0154] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for identifying associated elements in a database instance, comprising: Determine a target element to be detected, wherein the target element is a SQL element in the SQL database; Analyzing the target element based on a data structure graph of a database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertex set includes at least: vertices for representing SQL elements in the database instance, and the edge set includes at least: edges for representing association relationships between the SQL elements, and the data structure graph is determined by an SQL template within a specified time interval in the database instance; Outputting the associated element corresponding to the target element; Wherein, determining the target element to be detected includes: receiving an optimization request from a target object, wherein the optimization request carries the target element; Among them, after analyzing the target element based on the data structure diagram of the database instance to obtain the associated elements associated with the target element, the method also includes: obtaining the first index corresponding to the target element and the index set of the associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set.

2. The method according to claim 1, wherein: The data structure diagram is determined in the following manner: Obtain at least one SQL template in the database instance; Parsing the at least one SQL template to obtain first parsed content, the first parsed content at least including: associated elements associated with constituent elements of the at least one SQL template; The data structure graph is established based at least on the associated elements associated with the constituent elements.

3. The method according to claim 2, wherein: Acquiring at least one SQL template in the database instance includes: Obtain the full SQL transaction information in the database corresponding to the database instance; Parsing the full amount of SQL flow information to obtain second parsed content; Formatting the second parsed content to obtain an initial SQL template; The initial SQL template is deduplicated to obtain the at least one SQL template.

4. The method according to claim 1, wherein: The vertices used to represent the SQL elements in the database instance include the following vertices: The field vertices corresponding to the fields in the database instance and the table vertices corresponding to the tables in the database instance; the edges used to represent the association relationship between the SQL elements include edges used to indicate the following relationships: the relationship between the fields; the relationship between the table vertex and the field vertex.

5. The method according to claim 4, wherein: The method further comprises: The table vertices and field vertices are merged into a type of vertex to obtain a target vertex; and the data structure graph is established based on the association relationship between the target vertices.

6. The method according to claim 1, wherein: The vertex set also includes: vertices corresponding to different SQL requests; and / or The vertex set also includes the following vertices: index vertices corresponding to the index of the SQL request; the edge set also includes: edges for indicating the relationship between the table and the index, and edges for indicating the relationship between the SQL request and the index.

7. The method according to claim 1, wherein: The target element includes: a table corresponding to the database instance; the associated element corresponding to the target element includes: a SQL request set or a table set associated with the table; and / or The target element includes: a column corresponding to the database instance; the associated element corresponding to the target element includes: a column set or a SQL request set associated with the column; and / or The target element includes: a target SQL request; the associated element corresponding to the target element includes: a SQL request set associated with the target SQL request.

8. The method according to claim 7, wherein: The SQL request set associated with the target SQL request is determined in the following manner: Determine the number of edges associated with the target SQL request in the data structure graph to determine the correlation coefficient, wherein the edges associated with the target SQL request include: edges between vertices passed from a vertex corresponding to the target SQL request to a target associated vertex, wherein the target associated vertex is a vertex corresponding to the SQL request associated with the target SQL request; Determine a SQL request associated with the target SQL request according to the correlation coefficient, and store the SQL request associated with the target SQL request in the SQL request set.

9. A method for establishing a data structure diagram, comprising: Obtain at least one SQL template in the database instance, wherein the SQL template includes an SQL template within a specified time interval in the database instance; Parsing the at least one SQL template to obtain first parsed content, the first parsed content at least including: associated elements associated with constituent elements of the at least one SQL template; A data structure graph is generated based at least on the constituent elements and associated elements associated with the constituent elements, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent SQL elements in the database instance, and the edges in the edge set are used to represent association relationships between the SQL elements.

10. A method for identifying associated elements in a database instance, comprising: Receive an SQL request, and obtain a target element in a database instance from the SQL request; Analyzing the target element based on the data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set include: vertices for representing different SQL requests and vertices for representing SQL elements in the database instance, and the edge set includes: edges for representing associations between different SQL requests and SQL elements in the database instance, and edges for representing associations between the SQL elements, and the data structure graph is determined by an SQL template within a specified time interval in the database instance; Outputting the associated element corresponding to the target element; Wherein, determining the target element to be detected includes: receiving an optimization request from a target object, wherein the optimization request carries the target element; Among them, after analyzing the target element based on the data structure diagram of the database instance to obtain the associated elements associated with the target element, the method also includes: obtaining the first index corresponding to the target element and the index set of the associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set.

11. A method for optimizing elements in a database instance, wherein: include: Receiving an optimization request from a target object, wherein the optimization request carries a target element to be optimized, wherein the target element is a SQL element in a SQL database; Acquire an associated element that has an associated relationship with the target element; Optimizing the index of the target element and the index of the associated element; The step of optimizing the index of the target element and the index of the associated element includes: obtaining a first index corresponding to the target element and an index set of associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set; Among them, obtaining the associated elements that have an association relationship with the target element includes: analyzing the target element based on a data structure diagram of a database instance to obtain the associated elements associated with the target element, and the data structure diagram is determined by an SQL template within a specified time interval in the database instance.

12. A non-volatile storage medium, the non-volatile storage medium comprising a stored program, wherein: When the program is running, the device where the non-volatile storage medium is located is controlled to execute the method for identifying associated elements in a database instance as described in any one of claims 1 to 8.

13. A computing device comprising: processor; as well as A memory, connected to the processor, configured to provide the processor with instructions for processing the following processing steps: Determine a target element to be detected in the database instance, wherein the target element is a SQL element in the SQL database; Analyzing the target element based on a data structure graph of the database instance to obtain associated elements associated with the target element, wherein the data structure graph includes: a vertex set and an edge set, wherein the vertices in the vertex set are used to represent SQL elements in the database instance, and the edges in the edge set are used to represent association relationships between the SQL elements, and the data structure graph is determined by an SQL template within a specified time interval in the database instance; Outputting the associated element corresponding to the target element; Wherein, determining the target element to be detected includes: receiving an optimization request from a target object, wherein the optimization request carries the target element; Among them, after analyzing the target element based on the data structure diagram of the database instance to obtain the associated elements associated with the target element, the method also includes: obtaining the first index corresponding to the target element and the index set of the associated elements associated with the target element; integrating and deduplicating the first index and the second index in the index set.

Citation Information

Patent Citations

  • Database-based repetitive association detection method, device and equipment, and storage medium

    CN110909016A