Coding method, data query method and related equipment

By generating target encodings containing query plan node information and parameter information, the problems of low database parameter adjustment efficiency and insufficient encoding methods in the prior art are solved, and high accuracy and efficiency of complex queries are achieved.

CN119513138APending Publication Date: 2025-02-25BEIJING VOLCANO ENGINE TECH CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411449200.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, database parameter adjustment relies on manual experience, is inefficient and difficult to cope with complex loads, and the encoding method cannot effectively contain information about the query execution process.

Method used

A coding method is proposed, by receiving query requests, obtaining query plans and database parameters, generating node vectors and parameter vectors, and determining the association relationship between nodes and parameters, and generating target encodings for database parameter adjustment.

Benefits of technology

The target encoding is implemented to include query plan node information and parameter information, which is suitable for queries with high complexity and improve query accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513138A_ABST
    Figure CN119513138A_ABST
Patent Text Reader

Abstract

The invention provides a coding method, a data query method and related equipment. The encoding method comprises the steps that a query request is received, and the query request is used for requesting to query target data in a target database; obtaining a query plan corresponding to the query request and a plurality of current database parameters of the target database, wherein the query plan comprises a plurality of nodes; generating a plurality of first vectors corresponding to the plurality of nodes and a plurality of second vectors corresponding to the plurality of current database parameters according to the plurality of nodes and the plurality of current database parameters of the query plan; determining an association relationship between the plurality of nodes and the plurality of current database parameters; and obtaining a target code based on the plurality of first vectors and the plurality of second vectors according to the association relationship.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a coding method, a data query method and related equipment. Background Art

[0002] In the field of computer technology, a database is usually used to store data, and data can be queried from the database based on a query request. There are adjustable system parameters in the database. In the related art, database operation and maintenance personnel usually rely on their own experience to adjust the parameters of the database, and it takes a lot of time to tune these parameters.

[0003] The inventors of the present disclosure have discovered that a machine learning method can be used in the related art to automatically adjust the parameters of a database, but this method has certain limitations when encoding query requests. Summary of the invention

[0004] The present disclosure proposes an encoding method, a data query method and related devices to solve or partially solve the above problems.

[0005] In a first aspect, the present disclosure provides an encoding method, comprising:

[0006] Receiving a query request, wherein the query request is used to request to query target data in a target database;

[0007] Obtaining a query plan corresponding to the query request and a plurality of current database parameters of the target database, wherein the query plan includes a plurality of nodes;

[0008] According to the multiple nodes of the query plan and the multiple current database parameters, generate multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters;

[0009] Determining association relationships between the multiple nodes and the multiple current database parameters;

[0010] According to the association relationship, a target code is obtained based on the multiple first vectors and the multiple second vectors.

[0011] In a second aspect of the present disclosure, a data query method is provided, comprising:

[0012] Receiving a query request for target data, wherein the query request is used to request to query the target data in a target database;

[0013] Acquire multiple current database parameters of the target database;

[0014] Using the method of the first aspect, encoding the query request and the multiple current database parameters to obtain a target code corresponding to the query request;

[0015] determining at least one target database parameter of the target database based on the target encoding;

[0016] adjusting at least one database parameter of the target database based on the at least one target database parameter;

[0017] Based on the query request, the target data is queried in the target database after parameter adjustment.

[0018] In a third aspect of the present disclosure, there is provided an encoding device, comprising:

[0019] A receiving module is configured to: receive a query request, wherein the query request is used to request to query target data in a target database;

[0020] An acquisition module is configured to: acquire a query plan corresponding to the query request and a plurality of current database parameters of the target database, wherein the query plan includes a plurality of nodes;

[0021] A generating module, configured to: generate a plurality of first vectors corresponding to the plurality of nodes and a plurality of second vectors corresponding to the plurality of current database parameters according to the plurality of nodes of the query plan and the plurality of current database parameters;

[0022] A determination module is configured to: determine the association relationship between the multiple nodes and the multiple current database parameters;

[0023] The encoding module is configured to obtain a target encoding based on the association relationship, the multiple first vectors and the multiple second vectors.

[0024] In a fourth aspect of the present disclosure, a data query device is provided, comprising:

[0025] A receiving module is configured to: receive a query request for target data, wherein the query request is used to request to query the target data in a target database;

[0026] An acquisition module is configured to: acquire a plurality of current database parameters of the target database;

[0027] The encoding module is configured to: adopt the method described in the first aspect to encode the query request and the multiple current database parameters to obtain a target code corresponding to the query request;

[0028] A determination module is configured to: determine at least one target database parameter of the target database based on the target encoding;

[0029] An adjustment module, configured to: adjust at least one database parameter of the target database based on the at least one target database parameter;

[0030] The query module is configured to: based on the query request, query the target data in the target database after parameter adjustment.

[0031] In a fifth aspect of the present disclosure, a computer device is provided, comprising one or more processors, a memory; and one or more programs, wherein the one or more programs are stored in the memory and executed by the one or more processors, and the program includes instructions for executing the method according to the first aspect or the second aspect.

[0032] According to a sixth aspect of the present disclosure, a non-volatile computer-readable storage medium containing a computer program is provided. When the computer program is executed by one or more processors, the processors execute the method described in the first aspect or the second aspect.

[0033] In a seventh aspect of the present disclosure, a computer program product is provided, comprising computer program instructions, which, when executed on a computer, cause the computer to execute the method described in the first aspect or the second aspect.

[0034] The encoding method, data query method and related equipment provided by the embodiments of the present disclosure simultaneously encode the query plan and database parameters, so that the target code contains both the query plan node information and the parameter information, which is suitable for queries with higher complexity; and, by adding the association between the node and the parameter to the encoding, the target code can contain information on the different effects of different parameters on different query plan nodes, making the encoding more precise, thereby improving query accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0036] Figure 1 A schematic diagram showing an exemplary system provided by an embodiment of the present disclosure is shown.

[0037] Figure 2 A schematic diagram of an exemplary encoding method provided by an embodiment of the present disclosure is shown.

[0038] Figure 3A flowchart of an exemplary method provided by an embodiment of the present disclosure is shown.

[0039] Figure 4 Another flowchart of an exemplary method provided by an embodiment of the present disclosure is shown.

[0040] Figure 5 A schematic diagram of the hardware structure of an exemplary computer device provided in an embodiment of the present disclosure is shown.

[0041] Figure 6 A schematic diagram of an exemplary device provided by an embodiment of the present disclosure is shown.

[0042] Figure 7 A schematic diagram showing another exemplary device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0043] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0044] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0045] It is understandable that before using the technical solutions of each embodiment of the present disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved will be informed to the user in an appropriate manner, and the user's authorization will be obtained.

[0046] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly remind the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can independently choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0047] As an optional but non-limiting implementation, in response to receiving the user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0048] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0049] Figure 1 A schematic diagram of an exemplary system 100 provided by an embodiment of the present disclosure is shown.

[0050] like Figure 1 As shown, the system 100 may include a terminal device 102, a terminal device 104, a server 106, and a database server 108. A medium (e.g., a network) providing a communication link may be included between the terminal device 102, the terminal device 104 and the server 106 and the database server 108. The network may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0051] Exemplarily, various applications (APPs) may be installed on the terminal device 104, such as life service applications, collaborative office applications, video conferencing applications, reading applications, video applications, social applications, payment applications, web browsers, and instant messaging tools.

[0052] The terminal device 102 and the terminal device 104 here can be hardware or software. When the terminal device 102 and the terminal device 104 are hardware, they can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, e-book readers, MP3 players, laptop computers (Laptops) and desktop computers (PCs), etc. When the terminal device 102 and the terminal device 104 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0053] The server 106 may be a server that provides various services, such as a background server that provides support for various applications displayed on the terminal devices 102 and 104. The database server 108 may also be a database server that provides various services. It is understood that if the server 106 can implement the relevant functions of the database server 108, the database server 108 may not be set in the system 100.

[0054] Here, the server 106 and the database server 108 can also be hardware or software. When they are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When they are software, they can be implemented as multiple software or software modules (for example, for providing distributed services), or as a single software or software module. No specific limitation is made here.

[0055] It should be understood that Figure 1 The number of terminal devices, users, servers and database servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, users, servers and database servers.

[0056] As an exemplary scenario, one or more database servers 108 may constitute a database for storing data and searching for corresponding data based on a query request when receiving a query request and then returning the data, etc. For example, a user 112 may use any application of a terminal device 104 to request a service, and the service needs to obtain corresponding data to return to the terminal device 104. At this time, a query request may be generated based on the request of the user 112 and sent to the database for data query. The database queries the corresponding data based on the query request and returns it to the terminal device 104.

[0057] As mentioned above, there are many adjustable system parameters in the database. In the related art, database optimization techniques, such as cost estimation, connection order selection, parameter tuning, index and view recommendation, etc., usually rely on database operation and maintenance personnel to adjust the parameters based on their own experience (for example, user 110 remotely adjusts the hardware parameters of any database server 108 of the database through terminal device 102), and it may also take a lot of time to tune these parameters and maintain the database. This method that relies on manual operation has obvious limitations, and it is difficult to cope with large-scale database instances and complex load changes. Moreover, due to the limited efficiency and ability of manual operation, it is also impossible to meet the strict requirements of various users from different fields and with different needs for high performance of the database.

[0058] As an example, a machine learning method can be used to adjust parameters, which shortens the time required for tuning and improves the quality of tuning.

[0059] For example, this type of parameter adjustment method usually requires encoding the query request as the input of the machine learning model, and then outputting the corresponding parameters for parameter adjustment. In addition, the machine learning model also needs to be trained based on the encoding of historical query requests.

[0060] Artificial intelligence empowers databases (Al for Databases, referred to as AI4DB) is a technology that uses AI to make databases more intelligent and efficient. In recent years, the vigorous development of machine learning and reinforcement learning has brought many innovative methods to the performance optimization of database systems. Learning-based methods to automatically tune parameters have achieved the goal of reducing the tuning time while improving the quality of tuning. These parameter tuning methods usually involve encoding query requests, learning the relationship between query requests, parameters, and database performance through models such as deep learning networks, and finally recommending parameters for adjusting the database. Among them, the effect of encoding query requests will greatly affect the effect of model learning and ultimately affect the quality of recommended parameters.

[0061] The inventors of the present disclosure have discovered that the encoding scheme of the automatic parameter adjustment method of the related art has at least the following defects: First, the encoding method based on the query text cannot include information about the query execution process, and thus does not include fine-grained effective information; Second, the query encoding method based on the tree structure, although it can encode very complex query plans, does not take into account that different parameters will have different effects on different query plan nodes.

[0062] In view of this, an embodiment of the present disclosure provides a coding method to solve or partially solve the above problems.

[0063] Figure 2 Schematic diagram of an exemplary encoding method 200 provided by an embodiment of the present disclosure is shown. The method 200 can be used to generate a target encoding based on a query request, and the target encoding can be used to train a parameter generation model or used as an input of the parameter generation model to obtain relevant parameters for a database to adjust the database. Optionally, the method 200 can be applied to Figure 1 The server 106 may be implemented as Figure 1 The server 106 and the database server 108 are connected.

[0064] like Figure 2As shown, a query request (Query) 202 may be received first, and the query request 202 may be used to request to query target data in a target database (e.g., a database implemented by one or more database servers 108). Optionally, the query request 202 may be, for example, a Structured Query Language (SQL) command, used to request to execute a corresponding query operation.

[0065] Optionally, the query request 202 can be real-time or historical. The real-time query request can be used for real-time query of data, and the historical query request can be used to train a parameter generation model so that the parameter generation model can be used to generate recommended parameters to adjust the parameters of the database.

[0066] Then, if Figure 2 As shown, a corresponding query plan (Query Plan) 204 may be obtained based on the query request 202 .

[0067] The query plan 204 is a specific step in the database system for executing the query request 202 (eg, SQL command), which describes in detail how to obtain the required data, including which indexes to use, how to connect tables, the order in which data is read, etc.

[0068] In some embodiments, in a relational database management system (RDBMS), the query plan 204 may be generated by the database management system (DBMS) based on the submitted query request 202 (e.g., SQL command), and is an optimized representation for efficiently accessing, retrieving, and processing data. Alternatively, the query plan 204 may be a product of a query optimizer, which is a component of the RDBMS that is used to build, evaluate, and select the most effective query plan. The query plan 204 generated by the query optimizer may reduce the resource consumption and time required to execute the query, while improving the query speed and accuracy.

[0069] As an optional embodiment, the query plan can be abstracted into multiple nodes (Plan Node). In some embodiments, according to the query steps described in the query plan, these nodes can also have an execution sequence, and this execution sequence can be abstracted as a connection relationship between nodes.

[0070] In some embodiments, based on the information included in the query plan 204, the query plan 204 can be converted into a directed acyclic graph ( Figure 2 In the tree structure) or tree diagram. Figure 2As shown, the directed acyclic graph (DAG) is composed of vertices and edges, wherein each edge points from one vertex to another vertex, wherein each vertex corresponds to one node, and the edge represents the connection relationship between the nodes. In this way, the information of the query execution process can be refined based on the directed acyclic graph, and the information can be combined into the target code, so that the target code can contain the relevant information of the query execution process, thereby improving the query accuracy.

[0071] Optionally, an adjacency matrix 210 can be determined based on the directed acyclic graph, and the adjacency matrix 210 is used to indicate the connection relationship between the multiple nodes. When encoding is performed subsequently, the adjacency matrix can be used to mask the pre-coding, and then the connection relationship between the nodes can be incorporated into the encoding to improve the query accuracy.

[0072] Furthermore, multiple nodes of the query plan 204 may be encoded into multiple first vectors for subsequent generation of a target code 220 , so that the target code 220 includes information of the query plan 204 , thereby improving query accuracy.

[0073] As an optional embodiment, Figure 2 As shown, when encoding the multiple nodes, they may be first encoded into multiple node vectors, for example, vectors 206A-206E.

[0074] Specifically, each node may be encoded as a node vector. Optionally, encoding may be performed based on multiple description information of each node related to the query request 202. Optionally, the multiple description information may include at least one of an operator, a connection, a scan table, a predicate, and a cardinality estimate. In this way, the node vector encoded based on the description information may contain more query plan information, thereby improving query accuracy.

[0075] In some embodiments, for each of the nodes, the multiple description information of the node can be converted into multiple one-hot vectors. Taking the case where the operators include three operators A, B, and C, if the operator of the node is A, the one-hot vector corresponding to the operator can be [1,0,0], if the operator of the node is B, the one-hot vector corresponding to the operator can be [0,1,0], and if the operator of the node is C, the one-hot vector corresponding to the operator can be [0,0,1]. In this way, each description information can be encoded into a one-hot vector.

[0076] Next, the multiple one-hot vectors corresponding to each of the nodes may be connected to obtain a node vector corresponding to the node. In this way, the node vector corresponding to each node is encoded.

[0077] In some embodiments, if the self-attention score corresponding to each node needs to be calculated later, the multiple one-hot vectors can be connected in a predetermined order to obtain the node vector corresponding to the node; wherein the predetermined order corresponding to each node is the same. In this way, accuracy can be guaranteed when calculating the self-attention score. It can be understood that the predetermined order of connection can be arbitrary, as long as the connection order of each vector is the same.

[0078] Furthermore, after the node vectors are obtained, a plurality of first vectors corresponding to the plurality of nodes may be generated according to the connection relationship between the plurality of nodes (eg, the adjacency matrix 210 ) and the plurality of node vectors.

[0079] As an optional embodiment, when encoding the node vector as the first vector, a self-attention mechanism can be used for further encoding. The self-attention mechanism enables the model to focus on relevant input parts through attention scores. However, since there is no data flow between two unconnected nodes, and the attention mechanism itself lacks the ability to capture the internal structural information of the DAG. Therefore, for a given pair of nodes i and j, the attention score is only calculated when there is an edge connecting the two nodes.

[0080] Therefore, in some embodiments, generating a plurality of first vectors corresponding to the plurality of nodes according to the connection relationship between the plurality of nodes and the plurality of node vectors includes:

[0081] Calculate self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes; Figure 2 As shown, the corresponding query Q1, key K1 and value V1 can be generated based on the node vector, and then the self-attention module 208 is used to calculate the attention score based on the self-attention mechanism as the self-attention score, thereby generating the corresponding self-attention code;

[0082] According to the connection relationship between the multiple nodes (for example, the adjacency matrix 210) and the multiple self-attention codes, multiple first vectors corresponding to the multiple nodes are generated.

[0083] In the adjacency matrix 210, if node i and node j are connected by an edge, the entry bij of the adjacency matrix 210 is set to 1, otherwise it is 0. This matrix is ​​used to mask the self-attention scores, that is, the attention score in the self-attention encoding is equal to the self-attention score Aij multiplied by the corresponding entry bij in the adjacency matrix 210. Therefore, the attention score of any unconnected node pair is set to 0.

[0084] Then, optionally, multiple current database parameters of the target database may be obtained. It is understood that the step of obtaining the current database parameters may be performed in parallel with the aforementioned step, or may be completed before the aforementioned step. The step of obtaining the current database parameters is described later for the convenience of description.

[0085] Optionally, the current database parameters correspond to the aforementioned query request. For example, when the query request 202 is real-time, the current database parameters may also be real-time, that is, the acquisition time is substantially the same as the query request 202 or the acquisition time interval is within a predetermined time difference. For another example, when the query request 202 is a historical query request, the current database parameters may be the parameters of the target database when the historical query request occurs. The real-time current database parameters may be used for real-time query of data, and the historical current database parameters may be used to train a parameter generation model so that the parameter generation model may be used to generate recommended parameters to adjust the parameters of the database.

[0086] It can be understood that the current database parameters can be any parameters of the target database. As an optional embodiment, the current database parameters can include hardware parameters of the target database, such as central processing unit (CPU) parameters, memory (RAM) parameters, hard disk parameters, network adapter parameters, etc. In this way, by adjusting the hardware parameters, the query success rate can be better improved.

[0087] Furthermore, a plurality of second vectors corresponding to the plurality of current database parameters may be generated according to the plurality of current database parameters, so as to encode the parameter information into the target code 220 later, thereby improving the query accuracy.

[0088] In some embodiments, Figure 2 As shown, the multiple current database parameters may be encoded to obtain multiple parameter vectors, for example, vectors 212A to 212E; then, self-attention scores are calculated for the multiple parameter vectors to obtain multiple self-attention codes corresponding to the multiple current database parameters as the multiple second vectors. Figure 2As shown, the corresponding query Q2, key K2 and value V2 can be generated based on the parameter vector, and then the self-attention module 214 is used to calculate the attention score based on the self-attention mechanism as the self-attention score, and then the corresponding self-attention encoding is generated as the second vector corresponding to the current database parameter. Optionally, since the parameters do not contain structural information and data flow, no mask operation is required.

[0089] In some embodiments, when encoding the multiple current database parameters, each of the current database parameters can be normalized according to the value range of the current database parameter to obtain a normalized parameter; then, based on the normalized parameter of each of the current database parameters, the parameter vector corresponding to the current database parameter is generated.

[0090] For example, assuming there is a set of parameters A, B, and C, the three parameter values ​​can be normalized according to the value range of each parameter. For example, assuming that the value range of parameter A is 0 to 1000, and the value of parameter A is 300, then after normalization, the normalized parameter of parameter A can be 0.3. Similarly, parameters B and C can be normalized. Assuming that parameters A, B, and C are normalized to 0.3, 0.6, and 0.9, each parameter can then be projected into a parameter vector, namely [0.3, 0, 0], [0, 0.6, 0], and [0, 0, 0.9]. Next, these parameter vectors are input into the self-attention module 214, the self-attention score is calculated, and then the self-attention code corresponding to each parameter vector is obtained as the second vector of the current database parameter corresponding to the parameter vector.

[0091] In this way, the current database parameters are encoded based on the self-attention mechanism, and the correlation between different parameters is calculated, so that the target code 220 obtained by the final encoding can better reflect the parameter information related to the query request, thereby improving the query accuracy.

[0092] Furthermore, after obtaining multiple first vectors related to the query request and multiple second vectors related to the current database parameters, a target code can be generated based on the multiple first vectors and the multiple second vectors, so that the target code contains both query-related information and parameter-related information, and then the database is adjusted based on the recommended parameters obtained from the target code to improve the query accuracy.

[0093] As an optional embodiment, the target encoding may be generated based on the multiple first vectors and the multiple second vectors based on a cross-attention mechanism.

[0094] Cross-attention is a mechanism in deep learning that allows the model to simultaneously focus on and process information from different data streams when processing input data. This mechanism significantly enhances the model's ability to handle multiple related data types, improving context understanding and prediction accuracy. In this embodiment, a cross-attention module 216 is used to capture the dependencies between the query plan and the database parameters. In addition to the input, the calculation of cross-attention follows the same mechanism as self-attention. However, the input in self-attention is a single sequence, while cross-attention asymmetrically combines two independent sequences of the same dimension as input. Therefore, as an optional embodiment, the first vector generated by the self-attention module 208 for encoding the query plan can be used as a key vector K3 and a value vector V3 as the input of the cross-attention module 216. The second vector generated by the self-attention module 214 for encoding database parameters is used as the query vector Q3 as the input of the cross-attention module 216.

[0095] Specifically, multiple key vectors and multiple value vectors can be generated based on the multiple first vectors, and multiple query vectors can be generated based on the multiple second vectors. Then, based on the multiple query vectors and the multiple key vectors, the self-attention score of each query vector is calculated. Then, the attention weight can be determined based on the self-attention score of each query vector; finally, the target encoding 220 is obtained based on the attention weight and the multiple value vectors.

[0096] In some embodiments, the cross-attention module 216 can further include three different linear layers for projecting these inputs to new vectors. These linear layers are set by some parameters so that K3, Q3 and V3 are in the same dimension in order to calculate the attention score. In this way, for the cross-attention module 216, the attention score aij represents the "correlation score" between parameter i and query plan node j.

[0097] The inventors of the present disclosure have found that a parameter will only affect certain specific types of query plan nodes. For example, adjusting the value of a parameter that controls filter behavior will only affect the execution time of a query plan node of the filter type, and will not affect other nodes. Therefore, the association relationship between the multiple nodes and the multiple current database parameters can be used to explain how different parameters affect the nodes to generate the final vector representation (i.e., the target encoding 220).

[0098] Therefore, in some embodiments, Figure 2 As shown, the method 200 may further include a step of determining associations between the plurality of nodes and the plurality of current database parameters, so as to capture correlation information between the nodes and the parameters.

[0099] As an optional implementation, we can ask database experts to give the node types affected by each parameter, and then build a correlation matrix based on this (for example, Figure 2 222), which is used to mask unnecessary attention calculations in cross attention. In this matrix 222, if it is determined that parameter i has an impact on the type of node j, the item cij is set to 1, otherwise it is 0.

[0100] In order to reduce labor costs, in some embodiments, an algorithm for interpreting a tree-based model (TreeSHAP) can be used to construct a correlation matrix 222 between the multiple nodes and the multiple current database parameters, and the correlation matrix is ​​used to describe the association relationship. TreeSHAP (Shapley additive interpretation of tree models) is a method for calculating feature importance and attributing model predictions to a single input feature. The core idea of ​​TreeSHAP is to use the inherent structure of a tree-based model to effectively calculate Shapley values ​​to quantify the contribution of each feature to the model output. In a machine learning model, the higher the absolute value of the Shapley value of a feature, the more important or influential the feature is in the prediction of the model. In this embodiment, TreeSHAP is used to identify parameters that affect different types of nodes, and a correlation matrix 222 is constructed based on the identification results.

[0101] In some embodiments, the correlation matrix 222 may be constructed based on the data of the tuning history (paired information of nodes and parameters) in combination with TreeSHAP, so that the correlation matrix 222 can better reflect the actual situation.

[0102] After constructing the correlation matrix 222, the self-attention score of each query vector is calculated based on the multiple query vectors and the multiple key vectors, which may further include calculating the self-attention score of each query vector based on the multiple query vectors and the multiple key vectors according to the correlation matrix 222. Specifically, the initial self-attention score of each query vector may be calculated based on the multiple query vectors and the multiple key vectors; then, the initial self-attention score of each query vector is masked using the correlation matrix 222 to obtain the self-attention score of each query vector. That is, the correlation matrix 222 is used to mask unnecessary attention calculations in cross-attention.

[0103] Thus, according to the association relationship (for example, Figure 2), based on the plurality of first vectors and the plurality of second vectors, obtain a target code 220, so that the target code 220 does not include parameter information that is not related to the query plan node. Optionally, as Figure 2 As shown, before outputting the final target code 220, the output of the cross-attention module 216 can also be normalized using the linear layer 218, and the final vector obtained can be the target code 220.

[0104] It can be seen from the above embodiments that the encoding method provided by the embodiments of the present disclosure simultaneously encodes the query plan and database parameters, so that the target encoding simultaneously contains rich operations, cost information and parameter information of the query plan nodes, and is suitable for queries with higher complexity; and, by adding the association relationship between the nodes and the parameters to the encoding, the target encoding can contain information on the different effects of different parameters on different query plan nodes, making the encoding more precise, thereby improving query accuracy.

[0105] It should be noted that the method of the embodiment of the present disclosure can be performed by a single device, such as a computer or a server. The method of the present embodiment can also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present disclosure, and the multiple devices will interact with each other to complete the described method.

[0106] It should be noted that the above describes some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0107] The embodiment of the present disclosure also provides an encoding method. Figure 3 FIG. 3 is a flow chart of an exemplary method 300 provided by an embodiment of the present disclosure. The method 300 may be Figure 1 It can be implemented by the server 106, or it can be implemented by the server 106 and the database server 108, or by Figure 1 The system 100 is implemented as Figure 3 As shown, the method 300 may include the following steps.

[0108] In step 302, a query request (e.g., Figure 2 A query request 202), wherein the query request is used to request to query target data in a target database;

[0109] In step 304, a query plan corresponding to the query request is obtained (for example, Figure 2 A query plan 204) and a plurality of current database parameters of the target database, the query plan comprising a plurality of nodes;

[0110] At step 306, a plurality of first vectors corresponding to the plurality of nodes and a plurality of second vectors corresponding to the plurality of current database parameters are generated according to the plurality of nodes of the query plan and the plurality of current database parameters;

[0111] In step 308, determining the association relationship between the plurality of nodes and the plurality of current database parameters;

[0112] In step 310, a target code is obtained according to the association relationship based on the plurality of first vectors and the plurality of second vectors.

[0113] It can be seen from the above embodiments that the encoding method provided by the embodiments of the present disclosure, by simultaneously encoding the query plan and database parameters, makes the target code contain both the query plan node information and the parameter information, which is suitable for queries with higher complexity; and, by adding the association relationship between the node and the parameter to the encoding, the target code can contain information on the different effects of different parameters on different query plan nodes, making the encoding more precise, thereby improving query accuracy.

[0114] In some embodiments, the query plan also includes the connection relationship between the multiple nodes (for example, Figure 2 adjacency matrix 210);

[0115] Generating, according to the multiple nodes of the query plan and the multiple current database parameters, multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters, comprises:

[0116] The multiple nodes of the query plan are encoded respectively to obtain multiple node vectors (for example, Figure 2 Vectors 206A to 206E);

[0117] A plurality of first vectors corresponding to the plurality of nodes are generated according to the connection relationship between the plurality of nodes and the plurality of node vectors.

[0118] In this way, the connection relationship between multiple nodes is used to generate the first vector, so that the target code can better reflect the query execution process information and improve the query accuracy.

[0119] In some embodiments, generating a plurality of first vectors corresponding to the plurality of nodes according to the connection relationship between the plurality of nodes and the plurality of node vectors includes:

[0120] Calculating self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes;

[0121] According to the connection relationship between the multiple nodes and the multiple self-attention codes, multiple first vectors corresponding to the multiple nodes are generated.

[0122] The self-attention mechanism allows the model to automatically focus on different parts of the input according to the attention score when processing data, and assign different weights according to their importance. Unlike traditional attention mechanisms, self-attention focuses on the relationship within the input itself. In this way, through the self-attention mechanism, long-distance dependencies between multiple nodes can be captured, rather than just limited to local contextual information, which is very helpful for understanding complex language structures and semantic relationships. In addition, combined with the connection relationship, the self-attention scores of nodes with connection relationships can be introduced into the target encoding, while enriching the encoding information as much as possible, ensuring the simplicity of the encoding. In addition, the self-attention mechanism can be calculated in parallel, greatly improving the computational efficiency. At the same time, it can adaptively learn the relationship between different nodes without manually designing complex feature extractors, which makes the model more flexible and powerful, and can better handle various complex tasks and data. In addition, self-attention also provides a certain degree of interpretability for the model. By observing the distribution of attention weights, we can understand the key areas that the model focuses on when processing data.

[0123] In some embodiments, generating a plurality of first vectors corresponding to the plurality of nodes and a plurality of second vectors corresponding to the plurality of current database parameters according to the plurality of nodes of the query plan includes:

[0124] The multiple current database parameters are encoded to obtain multiple parameter vectors (for example, Figure 2 Vectors 212A to 212E);

[0125] Calculate self-attention scores for the multiple parameter vectors to obtain multiple self-attention codes corresponding to the multiple current database parameters as the multiple second vectors.

[0126] In this way, the current database parameters are encoded based on the self-attention mechanism, and the correlation between different parameters is calculated, so that the target encoding obtained by the final encoding can better reflect the parameter information related to the query request, thereby improving the query accuracy.

[0127] In some embodiments, the multiple current database parameters are encoded to obtain multiple parameter vectors, including:

[0128] For each of the current database parameters, the current database parameter is normalized according to a value range of the current database parameter to obtain a normalized parameter;

[0129] The parameter vector corresponding to the current database parameter is generated according to the normalized parameter of each current database parameter.

[0130] In this way, normalization processing is adopted to avoid the problem of inaccurate encoding caused by large differences in the absolute values ​​of different parameters.

[0131] In some embodiments, obtaining a target code according to the association relationship based on the first vector and the second vector includes:

[0132] generating a plurality of key vectors and a plurality of value vectors according to the plurality of first vectors;

[0133] generating a plurality of query vectors according to the plurality of second vectors;

[0134] According to the association relationship, based on the multiple query vectors and the multiple key vectors, calculating a self-attention score of each of the query vectors;

[0135] Determining an attention weight according to the self-attention score of each of the query vectors;

[0136] The target encoding is obtained according to the attention weight and the multiple value vectors.

[0137] In this way, the dependency between the query plan and database parameters is captured through the cross-attention mechanism, making the encoding more accurate.

[0138] In some embodiments, determining the association relationship between the plurality of nodes and the plurality of current database parameters includes: using an algorithm for interpreting a tree-based model to construct a correlation matrix between the plurality of nodes and the plurality of current database parameters, wherein the correlation matrix is ​​used to describe the association relationship. In this way, using an algorithm to determine the correlation matrix can reduce manpower and improve efficiency.

[0139] In some embodiments, according to the association relationship, based on the multiple query vectors and the multiple key vectors, calculating the self-attention score of each query vector includes:

[0140] Based on the multiple query vectors and the multiple key vectors, calculating an initial self-attention score for each of the query vectors;

[0141] The initial self-attention score of each query vector is masked using the correlation matrix to obtain a self-attention score of each query vector.

[0142] In this way, according to the association relationship, based on the multiple first vectors and the multiple second vectors, the target code is obtained, so that the target code does not include parameter information irrelevant to the query plan node, making the coding more accurate.

[0143] In some embodiments, the current database parameters include hardware parameters of the target database. Thus, by adjusting the hardware parameters, the query success rate can be better improved.

[0144] It should be noted that the method of the embodiment of the present disclosure can be performed by a single device, such as a computer or a server. The method of the present embodiment can also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present disclosure, and the multiple devices will interact with each other to complete the described method.

[0145] It should be noted that the above describes some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0146] The disclosed embodiment also provides a data query method. Figure 4 FIG. 4 is a flow chart of an exemplary method 400 provided by an embodiment of the present disclosure. The method 400 may be Figure 1 It can be implemented by the server 106, or it can be implemented by the server 106 and the database server 108, or by Figure 1 The system 100 is implemented as Figure 4 As shown, the method 400 may include the following steps.

[0147] In step 402, a query request for target data is received, wherein the query request is used to request to query the target data in a target database;

[0148] In step 404, a plurality of current database parameters of the target database are obtained;

[0149] In step 406, the query request and the multiple current database parameters are encoded to obtain a target code corresponding to the query request using any embodiment or permutation or combination of the method 300;

[0150] At step 408, at least one target database parameter of the target database is determined based on the target encoding;

[0151] At step 410, at least one database parameter of the target database is adjusted based on the at least one target database parameter;

[0152] In step 412, based on the query request, the target data is queried in the target database after parameter adjustment.

[0153] It can be seen from the above embodiments that the encoding method provided by the embodiments of the present disclosure, by simultaneously encoding the query plan and database parameters, makes the target code contain both the query plan node information and the parameter information, which is suitable for queries with higher complexity; and, by adding the association between the node and the parameter to the encoding, the target code can contain information on the different effects of different parameters on different query plan nodes, making the encoding more precise, thereby improving query accuracy.

[0154] In some embodiments, based on the target code, determining at least one target database parameter of the target database includes: inputting the target code into a parameter generation model, and outputting at least one target database parameter of the target database. Since the target code contains richer query information and database parameter information, the parameter generation model can output more accurate target database parameters, and then after adjusting the parameters of the target database, the query accuracy can be improved.

[0155] Optionally, the parameter generation model can also be pre-trained, and the pre-trained training data can be a plurality of codes for training obtained by encoding a plurality of historical query requests using any embodiment of the method 300 or a permutation or combination of the embodiments, and the codes and the database parameters corresponding to the historical query requests are used as training data. The initial model is then trained using the training data to obtain the parameter generation model. In this way, the model obtained by training the plurality of codes for training obtained by encoding a plurality of historical query requests using any embodiment of the method 300 or a permutation or combination of the embodiments can make the output database parameters more matched with the query request, thereby improving the query accuracy.

[0156] The embodiment of the present disclosure further provides a computer device for implementing the above method 300 or method 400. Figure 5FIG. 5 is a schematic diagram showing the hardware structure of an exemplary computer device 500 provided in an embodiment of the present disclosure. The computer device 500 can be used to implement Figure 1 The server 106 can also be used to implement Figure 1 In some scenarios, the computer device 500 can also be used to implement Figure 1 The database server 108.

[0157] like Figure 5 As shown, the computer device 500 may include: a processor 502, a memory 504, a network module 506, a peripheral interface 508 and a bus 510. The processor 502, the memory 504, the network module 506 and the peripheral interface 508 are connected to each other in communication within the computer device 500 through the bus 510.

[0158] Processor 502 may be a central processing unit (CPU), an image processor, a neural network processor (NPU), a microcontroller (MCU), a programmable logic device, a digital signal processor (DSP), an application specific integrated circuit (ASIC), or one or more integrated circuits. Processor 502 may be used to perform functions related to the technology described in this disclosure. In some embodiments, processor 502 may also include multiple processors integrated into a single logical component. For example, Figure 5 As shown, processor 502 may include a plurality of processors 502a, 502b, and 502c.

[0159] The memory 504 may be configured to store data (eg, instructions, computer code, etc.). Figure 5 As shown, the data stored in the memory 504 may include program instructions (e.g., program instructions for implementing the method 300 or method 400 of the embodiment of the present disclosure) and data to be processed (e.g., the memory may store configuration files of other modules, etc.). The processor 502 may also access the program instructions and data stored in the memory 504, and execute the program instructions to operate on the data to be processed. The memory 504 may include a volatile storage device or a non-volatile storage device. In some embodiments, the memory 504 may include a random access memory (RAM), a read-only memory (ROM), an optical disk, a magnetic disk, a hard disk, a solid-state drive (SSD), a flash memory, a memory stick, etc.

[0160] The network interface 506 can be configured to provide the computer device 500 with communication with other external devices via a network. The network can be any wired or wireless network capable of transmitting and receiving data. For example, the network can be a wired network, a local wireless network (e.g., Bluetooth, WiFi, near field communication (NFC)), a cellular network, the Internet, or a combination thereof. It is understood that the type of network is not limited to the above specific examples.

[0161] The peripheral interface 508 can be configured to connect the computer device 500 to one or more peripheral devices to achieve information input and output. For example, the peripheral devices can include input devices such as a keyboard, a mouse, a touch pad, a touch screen, a microphone, and various sensors, and output devices such as a display, a speaker, a vibrator, and an indicator light.

[0162] The bus 510 may be configured to transmit information between various components of the computer device 500 (e.g., the processor 502, the memory 504, the network interface 506, and the peripheral interface 508), such as an internal bus (e.g., a processor-memory bus), an external bus (USB port, PCI-E bus), etc.

[0163] It should be noted that, although the architecture of the above-mentioned computer device 500 only shows the processor 502, the memory 504, the network interface 506, the peripheral interface 508 and the bus 510, in the specific implementation process, the architecture of the computer device 500 may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the architecture of the above-mentioned computer device 500 may also only include the components necessary for implementing the embodiments of the present disclosure, and does not necessarily include all the components shown in the figure.

[0164] The embodiment of the present disclosure also provides an encoding device 600 . Figure 6 FIG. 6 is a schematic diagram of an exemplary device 600 provided by an embodiment of the present disclosure. Figure 6 As shown, the device 600 can be used to implement the method 300 and can further include the following modules.

[0165] The receiving module 602 is configured to: receive a query request, wherein the query request is used to request to query target data in a target database;

[0166] The acquisition module 604 is configured to: acquire a query plan corresponding to the query request and a plurality of current database parameters of the target database, wherein the query plan includes a plurality of nodes;

[0167] A generating module 606 is configured to: generate a plurality of first vectors corresponding to the plurality of nodes and a plurality of second vectors corresponding to the plurality of current database parameters according to the plurality of nodes of the query plan and the plurality of current database parameters;

[0168] The determination module 608 is configured to: determine the association relationship between the multiple nodes and the multiple current database parameters;

[0169] The encoding module 610 is configured to obtain a target encoding based on the association relationship, the multiple first vectors and the multiple second vectors.

[0170] In some embodiments, the query plan also includes connection relationships between the multiple nodes;

[0171] The generating module 606 is configured to:

[0172] Encoding the multiple nodes of the query plan respectively to obtain multiple node vectors;

[0173] A plurality of first vectors corresponding to the plurality of nodes are generated according to the connection relationship between the plurality of nodes and the plurality of node vectors.

[0174] In some embodiments, the generating module 606 is configured to:

[0175] Calculating self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes;

[0176] According to the connection relationship between the multiple nodes and the multiple self-attention codes, multiple first vectors corresponding to the multiple nodes are generated.

[0177] In some embodiments, the generating module 606 is configured to:

[0178] Encoding the multiple current database parameters to obtain multiple parameter vectors;

[0179] Calculate self-attention scores for the multiple parameter vectors to obtain multiple self-attention codes corresponding to the multiple current database parameters as the multiple second vectors.

[0180] In some embodiments, the generating module 606 is configured to:

[0181] For each of the current database parameters, the current database parameter is normalized according to a value range of the current database parameter to obtain a normalized parameter;

[0182] The parameter vector corresponding to the current database parameter is generated according to the normalized parameter of each current database parameter.

[0183] In some embodiments, the encoding module 610 is configured to:

[0184] generating a plurality of key vectors and a plurality of value vectors according to the plurality of first vectors;

[0185] generating a plurality of query vectors according to the plurality of second vectors;

[0186] According to the association relationship, based on the multiple query vectors and the multiple key vectors, calculating a self-attention score of each of the query vectors;

[0187] Determining an attention weight according to the self-attention score of each of the query vectors;

[0188] The target encoding is obtained according to the attention weight and the multiple value vectors.

[0189] In some embodiments, the determination module 608 is configured to: adopt an algorithm for interpreting a tree-based model to construct a correlation matrix between the plurality of nodes and the plurality of current database parameters, wherein the correlation matrix is ​​used to describe the association relationship.

[0190] In some embodiments, the encoding module 610 is configured to:

[0191] Based on the multiple query vectors and the multiple key vectors, calculating an initial self-attention score for each of the query vectors;

[0192] The initial self-attention score of each query vector is masked using the correlation matrix to obtain a self-attention score of each query vector.

[0193] In some embodiments, the current database parameters include hardware parameters of the target database.

[0194] For the convenience of description, the above device is described by dividing it into various modules according to its functions. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0195] The device of the above embodiment is used to implement the corresponding method 300 in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0196] The embodiment of the present disclosure also provides a data query device 700 . Figure 7 FIG. 7 is a schematic diagram of an exemplary device 700 provided by an embodiment of the present disclosure. Figure 7As shown, the device 700 can be used to implement the method 400, and can further include the following modules.

[0197] The receiving module 702 is configured to: receive a query request for target data, wherein the query request is used to request to query the target data in a target database;

[0198] The acquisition module 704 is configured to: acquire multiple current database parameters of the target database;

[0199] The encoding module 706 is configured to: adopt any embodiment or arrangement or combination of the embodiments of the method 300 to encode the query request and the multiple current database parameters to obtain a target code corresponding to the query request;

[0200] The determination module 708 is configured to: determine at least one target database parameter of the target database based on the target encoding;

[0201] The adjustment module 710 is configured to: adjust at least one database parameter of the target database based on the at least one target database parameter;

[0202] The query module 712 is configured to query the target data in the target database after parameter adjustment based on the query request.

[0203] In some embodiments, the determination module 708 is configured to: generate a model by inputting the target encoding parameters, and output at least one target database parameter of the target database.

[0204] For the convenience of description, the above device is described by dividing it into various modules according to its functions. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0205] The device of the above embodiment is used to implement the corresponding method 400 in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0206] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute method 300 or method 400 as described in any of the above embodiments.

[0207] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0208] The computer instructions stored in the storage medium of the above embodiments are used to enable the computer to execute method 300 or method 400 as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0209] Based on the same inventive concept, corresponding to the method 300 or the method 400 in any of the above embodiments, the present disclosure further provides a computer program product, which includes a computer program. In some embodiments, the computer program is executable by one or more processors so that the processors execute the method 300 or the method 400. Corresponding to the execution subject corresponding to each step in each embodiment of the method 300 or the method 400, the processor that executes the corresponding step may belong to the corresponding execution subject.

[0210] The computer program product of the above embodiment is used to enable the processor to execute method 300 or method 400 as described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.

[0211] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. Based on the concept of the present disclosure, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present disclosure as described above, which are not provided in detail for the sake of simplicity.

[0212] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present disclosure difficult to understand, the known power / ground connections to the integrated circuit (IC) chips and other components may or may not be shown in the provided figures. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present disclosure difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present disclosure will be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present disclosure, it is apparent to those skilled in the art that the embodiments of the present disclosure can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0213] Although the present disclosure has been described in conjunction with specific embodiments of the present disclosure, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0214] The embodiments of the present disclosure are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present disclosure should be included in the scope of protection of the present disclosure.

Claims

1. A coding method, comprising: Receiving a query request, wherein the query request is used to request to query target data in a target database; Obtaining a query plan corresponding to the query request and a plurality of current database parameters of the target database, wherein the query plan includes a plurality of nodes; According to the multiple nodes of the query plan and the multiple current database parameters, generate multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters; Determining association relationships between the multiple nodes and the multiple current database parameters; According to the association relationship, a target code is obtained based on the multiple first vectors and the multiple second vectors.

2. The method of claim 1, wherein: The query plan also includes connection relationships between the multiple nodes; Generating, according to the multiple nodes of the query plan and the multiple current database parameters, multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters, comprises: Encoding the multiple nodes of the query plan respectively to obtain multiple node vectors; A plurality of first vectors corresponding to the plurality of nodes are generated according to the connection relationship between the plurality of nodes and the plurality of node vectors.

3. The method of claim 2, wherein: Generating a plurality of first vectors corresponding to the plurality of nodes according to the connection relationship between the plurality of nodes and the plurality of node vectors includes: Calculating self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes; According to the connection relationship between the multiple nodes and the multiple self-attention codes, multiple first vectors corresponding to the multiple nodes are generated.

4. The method of claim 1, wherein: Generating, according to the multiple nodes of the query plan and the multiple current database parameters, multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters, comprises: Encoding the multiple current database parameters to obtain multiple parameter vectors; Calculate self-attention scores for the multiple parameter vectors to obtain multiple self-attention codes corresponding to the multiple current database parameters as the multiple second vectors.

5. The method of claim 4, wherein: The multiple current database parameters are encoded to obtain multiple parameter vectors, including: For each of the current database parameters, the current database parameter is normalized according to a value range of the current database parameter to obtain a normalized parameter; The parameter vector corresponding to the current database parameter is generated according to the normalized parameter of each current database parameter.

6. The method of claim 1, wherein: Obtaining a target code according to the association relationship and based on the first vector and the second vector includes: generating a plurality of key vectors and a plurality of value vectors according to the plurality of first vectors; generating a plurality of query vectors according to the plurality of second vectors; According to the association relationship, based on the multiple query vectors and the multiple key vectors, calculating a self-attention score of each of the query vectors; Determining an attention weight according to the self-attention score of each of the query vectors; The target encoding is obtained according to the attention weight and the multiple value vectors.

7. The method of claim 6, wherein: Determining the association relationship between the multiple nodes and the multiple current database parameters includes: An algorithm for interpreting a tree-based model is used to construct a correlation matrix between the plurality of nodes and the plurality of current database parameters, wherein the correlation matrix is ​​used to describe the association relationship.

8. The method of claim 7, wherein: Calculating a self-attention score of each query vector based on the multiple query vectors and the multiple key vectors according to the association relationship includes: Based on the multiple query vectors and the multiple key vectors, calculating an initial self-attention score for each of the query vectors; The initial self-attention score of each query vector is masked using the correlation matrix to obtain a self-attention score of each query vector.

9. The method of claim 1, wherein: The current database parameters include hardware parameters of the target database.

10. A data query method, comprising: Receiving a query request for target data, wherein the query request is used to request to query the target data in a target database; Acquire multiple current database parameters of the target database; Adopting the method according to any one of claims 1 to 9, encoding the query request and the multiple current database parameters to obtain a target code corresponding to the query request; determining at least one target database parameter of the target database based on the target encoding; adjusting at least one database parameter of the target database based on the at least one target database parameter; Based on the query request, the target data is queried in the target database after parameter adjustment.

11. The method of claim 10, wherein: Determining at least one target database parameter of the target database based on the target encoding includes: The target encoding is input into a parameter generation model, and at least one target database parameter of the target database is output.

12. An encoding device, comprising: A receiving module is configured to: receive a query request, wherein the query request is used to request to query target data in a target database; An acquisition module is configured to: acquire a query plan corresponding to the query request and a plurality of current database parameters of the target database, wherein the query plan includes a plurality of nodes; A generating module, configured to: generate a plurality of first vectors corresponding to the plurality of nodes and a plurality of second vectors corresponding to the plurality of current database parameters according to the plurality of nodes of the query plan and the plurality of current database parameters; A determination module is configured to: determine the association relationship between the multiple nodes and the multiple current database parameters; The encoding module is configured to obtain a target encoding based on the association relationship, the multiple first vectors and the multiple second vectors.

13. A data query device, comprising: A receiving module is configured to: receive a query request for target data, wherein the query request is used to request to query the target data in a target database; An acquisition module is configured to: acquire a plurality of current database parameters of the target database; The encoding module is configured to: adopt the method according to any one of claims 1 to 9 to encode the query request and the multiple current database parameters to obtain a target code corresponding to the query request; A determination module is configured to: determine at least one target database parameter of the target database based on the target encoding; An adjustment module, configured to: adjust at least one database parameter of the target database based on the at least one target database parameter; The query module is configured to: based on the query request, query the target data in the target database after parameter adjustment.

14. A computer device comprising one or more processors, a memory; and one or more programs, wherein the one or more programs are stored in the memory and executed by the one or more processors, and the programs include instructions for executing the method according to any one of claims 1 to 9 or the method according to claim 10 or 11.

15. A non-volatile computer-readable storage medium containing a computer program, which, when executed by one or more processors, causes the processors to perform the method of any one of claims 1 to 9 or the method of claim 10 or 11.

16. A computer program product, comprising computer program instructions, which, when executed on a computer, cause the computer to execute the method according to any one of claims 1 to 9 or the method according to claim 10 or 11.

Citation Information

Patent Citations

  • Data query method, device and system based on feature association

    CN115794891A

  • Data query method and device in database and computer equipment

    CN116701455A

  • Database query optimization method and device, storage medium and electronic equipment

    CN116795874A

  • Text retrieval method and device, electronic equipment and storage medium

    CN117149990A

  • Database query optimizer cost model based on machine learning

    CN117874071A