Encoding methods, data query methods and related equipment
By encoding query plans and database parameters through self-attention and cross-attention mechanisms, target codes are generated, solving the problem of low efficiency in database parameter tuning in existing technologies and achieving high-accuracy database query optimization.
Patent Information
- Application Number
- CN202411449200.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2044-10-16
AI Technical Summary
In existing technologies, database parameter tuning relies on manual operation, which is inefficient and difficult to cope with large-scale database instances and complex load changes. Furthermore, existing machine learning coding methods cannot include fine-grained information about the query execution process and the impact of different parameters on query plan nodes.
The query plan and database parameters are encoded using self-attention and cross-attention mechanisms to generate target codes containing query plan node information and parameter information. The influence of different parameters on nodes is captured through association relationships.
It improves the accuracy and efficiency of database tuning, is suitable for highly complex queries, and enhances query accuracy and database performance.
Smart Images

Figure CN119513138B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to an encoding method, a data query method, and related equipment. Background Technology
[0002] In the field of computer technology, databases are commonly used to store data and can be retrieved based on query requests. Databases contain adjustable system parameters. In related technologies, database administrators typically rely on their own experience to tune these parameters, requiring a significant amount of time to optimize them.
[0003] The inventors of this disclosure have discovered that machine learning methods can be used to automatically adjust the parameters of a database in related technologies, but this method has certain limitations when encoding query requests. Summary of the Invention
[0004] This disclosure proposes an encoding method, a data query method, and related equipment to solve or partially solve the above-mentioned problems.
[0005] In a first aspect, this disclosure provides an encoding method, comprising:
[0006] Receive a query request, the query request being used to request the query of target data in the target database;
[0007] Obtain the query plan corresponding to the query request and multiple current database parameters of the target database, wherein the query plan includes multiple nodes;
[0008] Based on 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] Determine the association between the plurality of nodes and the plurality of current database parameters;
[0010] Based on the aforementioned association, and using the plurality of first vectors and the plurality of second vectors, the target encoding is obtained.
[0011] A second aspect of this disclosure provides a data query method, including:
[0012] Receive a query request for target data, the query request being used to request the query for the target data in the target database;
[0013] Obtain multiple current database parameters of the target database;
[0014] Using the method described in the first aspect, the query request and the plurality of current database parameters are encoded to obtain the target code corresponding to the query request;
[0015] Based on the target encoding, at least one target database parameter of the target database is determined;
[0016] Based on the at least one target database parameter, adjust at least one database parameter of the target database;
[0017] Based on the query request, the target data is queried in the target database after parameter adjustment.
[0018] A third aspect of this disclosure provides an encoding device, comprising:
[0019] The receiving module is configured to receive a query request, wherein the query request is used to request query target data in the target database;
[0020] The acquisition module is configured to: acquire the query plan corresponding to the query request and multiple current database parameters of the target database, wherein the query plan includes multiple nodes;
[0021] The generation module is configured to: generate multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters based on the multiple nodes of the query plan and the multiple current database parameters;
[0022] The determination module is configured to: determine the association relationship between the plurality of nodes and the plurality of current database parameters;
[0023] The encoding module is configured to obtain the target encoding based on the plurality of first vectors and the plurality of second vectors according to the association relationship.
[0024] A fourth aspect of this disclosure provides a data query apparatus, comprising:
[0025] The receiving module is configured to receive a query request for target data, wherein the query request is used to request a query for the target data in the target database;
[0026] The acquisition module is configured to acquire multiple current database parameters of the target database;
[0027] The encoding module is configured to: use the method described in the first aspect to encode the query request and the plurality of current database parameters to obtain the target encoding corresponding to the query request;
[0028] The determining module is configured to: determine at least one target database parameter of the target database based on the target encoding;
[0029] The adjustment module is 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: query the target data in the target database after parameter adjustment based on the query request.
[0031] A fifth aspect of this disclosure provides a computer device including 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, the programs including instructions for performing the method according to the first or second aspect.
[0032] A sixth aspect of this disclosure provides a non-volatile computer-readable storage medium comprising a computer program that, when executed by one or more processors, causes the processors to perform the method described in the first or second aspect.
[0033] A seventh aspect of this disclosure provides a computer program product including computer program instructions that, when executed on a computer, cause the computer to perform the method as described in the first or second aspect.
[0034] The encoding method, data query method, and related device provided in this disclosure simultaneously encode the query plan and database parameters, so that the target encoding simultaneously contains query plan node information and parameter information, which is suitable for queries with high complexity. Furthermore, by incorporating the association between nodes and parameters into the encoding, the target encoding can contain information on the different effects of different parameters on different query plan nodes, making the encoding more accurate and thus improving query accuracy. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in this disclosure or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 A schematic diagram of an exemplary system provided by an embodiment of this disclosure is shown.
[0037] Figure 2 A schematic diagram of an exemplary encoding method provided in an embodiment of this disclosure is shown.
[0038] Figure 3A flowchart illustrating an exemplary method provided in an embodiment of this disclosure is shown.
[0039] Figure 4 Another flowchart illustrating an exemplary method provided by an embodiment of this disclosure is shown.
[0040] Figure 5 A schematic diagram of the hardware structure of an exemplary computer device provided in an embodiment of this disclosure is shown.
[0041] Figure 6 A schematic diagram of an exemplary apparatus provided by an embodiment of the present disclosure is shown.
[0042] Figure 7 A schematic diagram of another exemplary apparatus provided by an embodiment of this disclosure is shown. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.
[0044] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this disclosure should have the ordinary meaning understood by one of ordinary skill in the art to which this disclosure pertains. The terms "first," "second," and similar terms used in the embodiments of this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only 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 understood that before using the technical solutions of the various embodiments in this disclosure, users will be informed of the type, scope of use, and usage scenarios of the personal information involved in an appropriate manner, and user authorization will be obtained.
[0046] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose, based on the prompt message, whether to provide personal information to the software or hardware such as electronic devices, applications, servers, or storage media performing the operations of this disclosed technical solution.
[0047] As an optional but not limited implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0048] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0049] Figure 1 A schematic diagram of an exemplary system 100 provided in an embodiment of this disclosure is shown.
[0050] like Figure 1 As shown, system 100 may include terminal device 102, terminal device 104, server 106, and database server 108. A medium (e.g., a network) may be provided to provide a communication link between terminal device 102, terminal device 104, server 106, and database server 108. This network may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0051] For example, various applications (APPs) can 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 devices 102 and 104 here can be hardware or software. When terminal devices 102 and 104 are hardware, they can be various electronic devices with displays, including but not limited to smartphones, tablets, e-book readers, MP3 players, laptops, and desktop computers (PCs). When terminal devices 102 and 104 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software programs or software modules (e.g., to provide distributed services) or as a single software program or software module. No specific limitations are made here.
[0053] Server 106 can be a server providing various services, such as a backend server supporting various applications displayed on terminal devices 102 and 104. Database server 108 can also be a database server providing various services. It is understood that if server 106 can implement the relevant functions of database server 108, database server 108 may not need to be set up in system 100.
[0054] The server 106 and database server 108 here can be either 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 programs or software modules (e.g., used to provide distributed services), or as a single software program or software module. No specific limitations are made here.
[0055] It should be understood that Figure 1 The number of terminal devices, users, servers, and database servers shown is merely illustrative. Depending on implementation needs, there can be any number of terminal devices, users, servers, and database servers.
[0056] As an example scenario, one or more database servers 108 can constitute a database for storing data and retrieving and returning relevant data based on a query request. For instance, user 112 can request a service using any application on terminal device 104. This service needs to retrieve relevant data to return to terminal device 104. In this case, a query request can be generated based on user 112's request and sent to the database to retrieve the data. The database retrieves the relevant data based on the query request and returns it to terminal device 104.
[0057] As mentioned earlier, databases contain many adjustable system parameters. In related technologies, database optimization techniques, such as cost estimation, connection order selection, parameter tuning, and index and view recommendations, typically rely on database administrators' experience to adjust these parameters (e.g., user 110 remotely adjusts the hardware parameters of any database server 108 via terminal device 102). Furthermore, this process can require significant time for parameter tuning and database maintenance. This manual approach has clear limitations; it struggles to handle large-scale database instances and complex load variations. Moreover, due to the limited efficiency and capabilities of manual operations, it cannot meet the stringent high-performance requirements of various users from different fields with varying needs.
[0058] As an example, machine learning methods can be used for parameter tuning. This approach reduces the time required for tuning while also improving the quality of the tuning.
[0059] For example, this type of parameter tuning method typically requires encoding the query request as input to the machine learning model, and then outputting the corresponding parameters for parameter tuning. Furthermore, the machine learning model also needs to be trained based on the encoding of historical query requests.
[0060] AI for Databases (AI4DB) is a technology that leverages AI to make databases increasingly intelligent and efficient. In recent years, the rapid development of machine learning and reinforcement learning has brought numerous innovative methods for optimizing database system performance. Learning-based methods for automatic parameter tuning have reduced tuning time and improved tuning quality. These tuning methods typically involve encoding query requests and using models such as deep learning networks to learn the relationship between query requests, parameters, and database performance, ultimately recommending parameters for database tuning. The effectiveness of query request encoding significantly impacts the model's learning performance and ultimately the quality of the recommended parameters.
[0061] The inventors of this disclosure have discovered that the encoding scheme of the automatic parameter tuning method in the related technology has at least the following defects: First, the encoding method based on query text cannot include information about the query execution process, and therefore does not contain fine-grained effective information; Second, although the query encoding method based on tree structure can encode very complex query plans, it does not take into account that different parameters will have different effects on different query plan nodes.
[0062] In view of this, embodiments of the present disclosure provide an encoding method to solve or partially solve the above-mentioned problems.
[0063] Figure 2 A schematic diagram of an exemplary encoding method 200 provided in an embodiment of this disclosure is shown. Method 200 can be used to generate a target encoding based on a query request. This target encoding can be used to train a parameter generation model or as input to the parameter generation model to obtain relevant parameters for adjusting the database. Optionally, method 200 can be applied to... Figure 1 Server-side 106, or, implemented as Figure 1 The server 106 and the database server 108.
[0064] like Figure 2As shown, a query request 202 can be received first. The query request 202 can be used to request the query of target data in a target database (e.g., a database implemented by one or more database servers 108). Optionally, the query request 202 can be, for example, a Structured Query Language (SQL) command used to request the execution of a corresponding query operation.
[0065] Optionally, the query request 202 can be real-time or historical. Real-time query requests can be used for real-time data retrieval, while historical query requests 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] Next, as Figure 2 As shown, the corresponding query plan 204 can be obtained based on query request 202.
[0067] Query plan 204 is the specific steps in a database system used to execute query request 202 (e.g., an SQL command). It details how to obtain the required data, including which indexes to use, how to join tables, and the order in which data is read.
[0068] In some embodiments, within a relational database management system (RDBMS), query plan 204 can be generated by the DBMS based on a submitted query request 202 (e.g., an SQL command), and is an optimized representation for efficiently accessing, retrieving, and processing data. Optionally, query plan 204 can be a product of a query optimizer, a component of the RDBMS used to build, evaluate, and select the most efficient query plan. Query plan 204 generated by the query optimizer can reduce the resource consumption and time required to execute a query, while improving query speed and accuracy.
[0069] As an alternative embodiment, the query plan can be abstracted into multiple plan nodes. In some embodiments, these nodes may also have an execution order based on the query steps described in the query plan, which can be abstracted as the connection relationship between the nodes.
[0070] In some embodiments, based on the information contained in query plan 204, query plan 204 can be converted into a directed acyclic graph (DAG). Figure 2 (A tree-like structure) or tree diagram. For example... Figure 2As shown, the directed acyclic graph (DAG) consists of vertices and edges, where each edge points from one vertex to another. Each vertex corresponds to a node, and the edges represent the connections between nodes. In this way, information about the query execution process can be extracted based on the DAG, and this information can be incorporated into the target encoding, allowing the target encoding to contain relevant information about the query execution process and improving query accuracy.
[0071] Optionally, an adjacency matrix 210 can be determined based on the directed acyclic graph. This adjacency matrix 210 indicates the connection relationships between the plurality of nodes. During subsequent encoding, this adjacency matrix can be used to mask the pre-encoding, thereby incorporating the connection relationships between nodes into the encoding and improving query accuracy.
[0072] Furthermore, multiple nodes of query plan 204 can be encoded into multiple first vectors for subsequent generation of target code 220, thereby enabling target code 220 to contain information of query plan 204 and improving query accuracy.
[0073] As an optional embodiment, such as Figure 2 As shown, when encoding the multiple nodes, they can first be encoded into multiple node vectors, for example, vectors 206A to 206E.
[0074] Specifically, each node can be encoded as a node vector. Optionally, the encoding can be based on multiple descriptive information contained in each node that is related to the query request 202. Optionally, the multiple descriptive information may include at least one of operators, joins, scan tables, predicates, and cardinality estimates. In this way, the node vector encoded based on the descriptive information can contain more information about the query plan, thereby improving query accuracy.
[0075] In some embodiments, for each node, the plurality of description information of the node can be converted into a plurality of one-hot vectors. Taking the operators as a total of three types, A, B, and C, as an example, if the node's operator is A, then its corresponding one-hot vector can be [1,0,0]; if the node's operator is B, then its corresponding one-hot vector can be [0,1,0]; and if the node's operator is C, then its corresponding one-hot vector can be [0,0,1]. Using this method, each description information can be encoded into a one-hot vector.
[0076] Next, the multiple one-hot vectors corresponding to each node can be concatenated to obtain the node vector corresponding to that node. In this way, the node vector corresponding to each node is encoded.
[0077] In some embodiments, if it is necessary to calculate the self-attention score corresponding to each node subsequently, the plurality of one-hot vectors can be concatenated in a predetermined order to obtain the node vector corresponding to the node; wherein the predetermined order corresponding to each node is the same. This ensures accuracy when calculating the self-attention score. It is understood that the predetermined order of concatenation can be arbitrary, as long as the concatenation order of each vector is the same.
[0078] Furthermore, after obtaining the node vectors, multiple first vectors corresponding to the multiple nodes can be generated based on the connection relationships between the multiple nodes (e.g., adjacency matrix 210) and the multiple node vectors.
[0079] As an alternative implementation, a self-attention mechanism can be used for further encoding when encoding the node vectors into the first vector. The self-attention mechanism allows 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 information about the internal structure of the DAG, for a given pair of nodes i and j, the attention score is only calculated if an edge connecting the two nodes exists.
[0080] Therefore, in some embodiments, generating multiple first vectors corresponding to the multiple nodes based on the connection relationships between the multiple nodes and the multiple node vectors includes:
[0081] Calculate self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes; such as Figure 2 As shown, the corresponding query Q1, key K1 and value V1 can be generated based on the node vector. Then, the attention score is calculated based on the self-attention mechanism using the self-attention module 208 as the self-attention score, thereby generating the corresponding self-attention code.
[0082] Based on the connection relationships between the plurality of nodes (e.g., adjacency matrix 210) and the plurality of self-attention codes, a plurality of first vectors corresponding to the plurality of nodes are generated.
[0083] In adjacency matrix 210, if node i and node j are connected by an edge, the item bij in adjacency matrix 210 is set to 1; otherwise, it is set to 0. This matrix is used to mask the self-attention score, i.e., the attention score in the self-attention encoding is equal to the self-attention score Aij multiplied by the corresponding item bij in adjacency matrix 210. Therefore, the attention score of any unconnected node pair is set to 0.
[0084] Next, optionally, multiple current database parameters of the target database can be obtained. It is understood that the step of obtaining the current database parameters can be performed in parallel with the aforementioned steps, or can be completed before the aforementioned steps; the step of obtaining the current database parameters is described later here only for the sake of convenience.
[0085] Optionally, the current database parameters correspond to the aforementioned query request. For example, when query request 202 is real-time, the current database parameters can also be real-time, meaning they are obtained at approximately the same time as query request 202 or the time interval between the acquisitions is within a predetermined time difference. As another example, when query request 202 is a historical query request, the current database parameters can be the parameters of the target database at the time the historical query request occurred. The real-time current database parameters can be used for real-time data querying, while the historical current database parameters can be used to train a parameter generation model, enabling the model to generate recommended parameters to adjust the database parameters.
[0086] It is understood that the current database parameters can be any parameters of the target database. As an optional embodiment, the current database parameters may include the 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 improved.
[0087] Furthermore, multiple second vectors corresponding to the multiple current database parameters can be generated based on the multiple current database parameters, so that the parameter information can be encoded into the target code 220 in the subsequent process, thereby improving the query accuracy.
[0088] In some embodiments, such as Figure 2 As shown, the multiple current database parameters can be encoded first to obtain multiple parameter vectors, for example, vectors 212A to 212E; then, self-attention scores are calculated on 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. Then, the self-attention module 214 calculates the attention score based on the self-attention mechanism as the self-attention score, thereby generating the corresponding self-attention code as the second vector corresponding to the current database parameter. Optionally, since the parameters do not contain structural information and data flow, a masking operation is not required.
[0089] In some embodiments, when encoding the plurality of current database parameters, for each current database parameter, the current database parameter can be normalized according to the value range of the current database parameter to obtain a normalized parameter; then, the parameter vector corresponding to the current database parameter is generated according to the normalized parameter of each current database parameter.
[0090] For example, assuming a set of parameters A, B, and C, the values of these three parameters can first be normalized according to the range of each parameter. For instance, assuming the range of parameter A is 0 to 1000, and the value of parameter A is 300, then the normalized parameter of parameter A can be 0.3. Similarly, parameters B and C can be normalized. Assuming that the normalized values of parameters A, B, and C are 0.3, 0.6, and 0.9, then each parameter can 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 to calculate the self-attention score, thereby obtaining the self-attention code corresponding to each parameter vector, which is used as the second vector of the current database parameter corresponding to that parameter vector.
[0091] In this way, by encoding the current database parameters based on the self-attention mechanism and calculating the correlation between different parameters, the final target code 220 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. Then, after adjusting the database based on the recommended parameters obtained from the target code, the query accuracy can be improved.
[0093] As an alternative embodiment, the target encoding can be generated based on the plurality of first vectors and the plurality of second vectors using a cross-attention mechanism.
[0094] Cross-attention is a mechanism in deep learning that allows a model to simultaneously focus on and process information from different data streams while processing input data. This mechanism significantly enhances the model's ability to handle multiple related data types and improves contextual understanding and prediction accuracy. In this embodiment, cross-attention module 216 is used to capture the dependency between the query plan and database parameters. Except for the input, the computation of cross-attention follows the same mechanism as self-attention. However, while the input in self-attention is a single sequence, 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 the key vector K3 and value vector V3 as input to the cross-attention module 216. The second vector generated by the self-attention module 214 for encoding the database parameters is used as the query vector Q3 as input to 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, a self-attention score is calculated for each query vector based on the multiple query vectors and the multiple key vectors. Next, an attention weight is determined based on the self-attention score of each query vector; finally, the target code 220 is obtained based on the attention weight and the multiple value vectors.
[0096] In some embodiments, the cross-attention module 216 may further include three distinct linear layers for projecting these inputs onto a new vector. These linear layers are configured with parameters such that K3, Q3, and V3 are in the same dimension to compute attention scores. 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 this disclosure have discovered that a parameter only affects certain specific types of query plan nodes. For example, adjusting the value of a parameter that controls filter behavior only affects the execution time of the query plan node of the filter type, and has no effect on other nodes. Therefore, the association 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., target encoding 220).
[0098] Therefore, in some embodiments, such as Figure 2 As shown, method 200 may further include a step of determining the association between the plurality of nodes and the plurality of current database parameters, in order to capture the correlation between the nodes and the parameters.
[0099] As an alternative implementation, one could ask a database expert to specify the node types affected by each parameter, and then construct a correlation matrix based on this (e.g., Figure 2 The matrix 222 is used to mask unnecessary attention computations in cross-attention. In this matrix 222, the term cij is set to 1 if it is determined that parameter i has an influence on the type of node j, and 0 otherwise.
[0100] To reduce labor costs, in some embodiments, an algorithm for interpreting tree-based models (TreeSHAP) can be employed to construct a correlation matrix 222 between the plurality of nodes and the plurality of current database parameters, the correlation matrix being used to describe the association relationships. TreeSHAP (Shapley additive interpretation of tree models) is a method for calculating feature importance and attributing model predictions to individual input features. The core idea of TreeSHAP is to leverage the inherent structure of tree-based models to efficiently compute Shapley values, used to quantify the contribution of each feature to the model output. In machine learning models, the higher the absolute value of a feature's Shapley value, the more important or influential that feature is in the model's predictions. In this embodiment, TreeSHAP is used to identify parameters that influence different types of nodes, and a correlation matrix 222 is constructed based on the identification results.
[0101] In some embodiments, a correlation matrix 222 can be constructed by combining TreeSHAP with data from the Tuning History (paired information of nodes and parameters) to make the correlation matrix 222 more reflective of the actual situation.
[0102] After constructing the relevance matrix 222, the self-attention score of each query vector is calculated based on the plurality of query vectors and the plurality of key vectors. This can further include calculating the self-attention score of each query vector based on the relevance matrix 222 and the plurality of key vectors. Specifically, an initial self-attention score can be calculated for each query vector based on the plurality of query vectors and the plurality of key vectors; then, the initial self-attention score of each query vector is masked using the relevance matrix 222 to obtain the self-attention score of each query vector. That is, unnecessary attention calculations are masked in cross-attention using the relevance matrix 222.
[0103] Thus, based on the aforementioned association (e.g., Figure 2The correlation matrix 222), based on the plurality of first vectors and the plurality of second vectors, yields a target code 220, such that the target code 220 does not include parameter information unrelated 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 be normalized using the linear layer 218, and the resulting final vector can be the target code 220.
[0104] As can be seen from the above embodiments, the encoding method provided in this disclosure, by simultaneously encoding the query plan and database parameters, enables the target encoding to simultaneously contain rich operation, cost information and parameter information of the query plan nodes, and is suitable for queries with high complexity; furthermore, by adding the association relationship between nodes and 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 accurate, thereby improving query accuracy.
[0105] It should be noted that the method of this disclosure embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this disclosure embodiment, and the multiple devices will interact with each other to complete the method described.
[0106] It should be noted that the above description describes some embodiments of this 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 a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0107] This disclosure also provides an encoding method. Figure 3 A flowchart illustrating an exemplary method 300 provided in an embodiment of this disclosure is shown. This method 300 can be... Figure 1 It can be implemented by server 106, or by server 106 and database server 108 together, or by... Figure 1 The system is 100% implemented. For example... Figure 3 As shown, the method 300 may include the following steps.
[0108] In step 302, a query request is received (e.g., Figure 2 Query request 202), the query request is used to request to query target data in the target database;
[0109] In step 304, obtain the query plan corresponding to the query request (e.g., Figure 2 The query plan (204) and multiple current database parameters of the target database, wherein the query plan includes multiple nodes;
[0110] In step 306, based on 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 are generated.
[0111] In step 308, the association between the plurality of nodes and the plurality of current database parameters is determined;
[0112] In step 310, the target code is obtained based on the association relationship, the plurality of first vectors and the plurality of second vectors.
[0113] As can be seen from the above embodiments, the encoding method provided in this disclosure, by simultaneously encoding the query plan and database parameters, enables the target encoding to simultaneously contain query plan node information and parameter information, making it suitable for queries with high complexity; furthermore, by incorporating the association between nodes and parameters into the encoding, the target encoding can contain information on the different effects of different parameters on different query plan nodes, making the encoding more accurate and thus improving query accuracy.
[0114] In some embodiments, the query plan also includes the connection relationships between the plurality of nodes (e.g., Figure 2 The adjacency matrix (210);
[0115] Based on 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, including:
[0116] The multiple nodes of the query plan are encoded respectively to obtain multiple node vectors (e.g., Figure 2 Vectors 206A~206E);
[0117] Based on the connection relationships between the multiple nodes and the multiple node vectors, multiple first vectors corresponding to the multiple nodes are generated.
[0118] In this way, by using the connection relationships between multiple nodes to generate the first vector, the target encoding can better reflect the query execution process information and improve query accuracy.
[0119] In some embodiments, generating multiple first vectors corresponding to the multiple nodes based on the connection relationships between the multiple nodes and the multiple node vectors includes:
[0120] Calculate self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes;
[0121] Based on the connection relationships 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 based on attention scores and assign different weights according to their importance when processing data. Unlike traditional attention mechanisms, self-attention primarily focuses on the relationships within the input itself. This allows the model to capture long-range dependencies between multiple nodes, rather than being limited to local contextual information, which is very helpful for understanding complex language structures and semantic relationships. Furthermore, by incorporating these connections, the self-attention scores of nodes with connections can be introduced into the target encoding, enriching the encoded information while maintaining conciseness. In addition, the self-attention mechanism can be computed in parallel, greatly improving computational efficiency. Simultaneously, it can adaptively learn the relationships between different nodes without the need for manually designing complex feature extractors, making the model more flexible and powerful, and better able to handle various complex tasks and data. Moreover, self-attention provides a degree of interpretability to the model; by observing the distribution of attention weights, one can understand the key regions the model focuses on when processing data.
[0123] In some embodiments, generating multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters based on the multiple nodes of the query plan and the multiple current database parameters includes:
[0124] The multiple current database parameters are encoded to obtain multiple parameter vectors (e.g., Figure 2 Vectors 212A~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, by encoding the current database parameters based on the self-attention mechanism and calculating the correlation between different parameters, the final target encoding can better reflect the parameter information related to the query request, thereby improving the query accuracy.
[0127] In some embodiments, the plurality of current database parameters are encoded to obtain a plurality of parameter vectors, including:
[0128] For each of the current database parameters, the current database parameter is normalized according to its value range to obtain a normalized parameter;
[0129] Generate the parameter vector corresponding to each current database parameter based on the normalization parameter of each current database parameter.
[0130] In this way, normalization is used to avoid inaccurate encoding caused by large differences in the absolute values of different parameters.
[0131] In some embodiments, the target encoding is obtained based on the first vector and the second vector according to the association relationship, including:
[0132] Based on the plurality of first vectors, generate a plurality of key vectors and a plurality of value vectors;
[0133] Based on the multiple second vectors, generate multiple query vectors;
[0134] Based on the association, and using the plurality of query vectors and the plurality of key vectors, calculate the self-attention score for each query vector;
[0135] The attention weights are determined based on the self-attention score of each query vector;
[0136] The target encoding is obtained based on the attention weights and the plurality of value vectors.
[0137] In this way, by using the cross-attention mechanism to capture the dependencies between the query plan and database parameters, the coding becomes more accurate.
[0138] In some embodiments, determining the association between the plurality of nodes and the plurality of current database parameters includes: constructing a correlation matrix between the plurality of nodes and the plurality of current database parameters using an algorithm for interpreting a tree-based model, wherein the correlation matrix is used to describe the association. Thus, using an algorithm to determine the correlation matrix can reduce manpower and improve efficiency.
[0139] In some embodiments, based on the association relationship and the plurality of query vectors and the plurality of key vectors, a self-attention score for each query vector is calculated, including:
[0140] Based on the plurality of query vectors and the plurality of key vectors, calculate the initial self-attention score for each query vector;
[0141] The initial self-attention score of each query vector is masked using the correlation matrix to obtain the self-attention score of each query vector.
[0142] In this way, based on the aforementioned association relationship and the plurality of first vectors and the plurality of second vectors, a target code is obtained, such that the target code does not include parameter information unrelated to the query plan node, making the code more accurate.
[0143] In some embodiments, the current database parameters include the hardware parameters of the target database. This allows for improved query success rates by adjusting the hardware parameters.
[0144] It should be noted that the method of this disclosure embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this disclosure embodiment, and the multiple devices will interact with each other to complete the method described.
[0145] It should be noted that the above description describes some embodiments of this 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 a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0146] This disclosure also provides a data query method. Figure 4 A flowchart illustrating an exemplary method 400 provided in an embodiment of this disclosure is shown. Method 400 can be... Figure 1 It can be implemented by server 106, or by server 106 and database server 108 together, or by... Figure 1 The system is 100% implemented. For example... Figure 4 As shown, the method 400 may include the following steps.
[0147] In step 402, a query request for target data is received, the query request being used to request a query for the target data in the target database;
[0148] In step 404, obtain multiple current database parameters of the target database;
[0149] In step 406, using any embodiment or arrangement / combination of the embodiments of method 300, the query request and the plurality of current database parameters are encoded to obtain the target code corresponding to the query request;
[0150] In step 408, based on the target encoding, at least one target database parameter of the target database is determined;
[0151] In step 410, based on the at least one target database parameter, at least one database parameter of the target database is adjusted;
[0152] In step 412, based on the query request, the target data is queried in the target database after parameter adjustment.
[0153] As can be seen from the above embodiments, the encoding method provided in this disclosure, by simultaneously encoding the query plan and database parameters, enables the target encoding to simultaneously contain query plan node information and parameter information, making it suitable for queries with high complexity; furthermore, by incorporating the association between nodes and parameters into the encoding, the target encoding can contain information on the different effects of different parameters on different query plan nodes, making the encoding more accurate and thus improving query accuracy.
[0154] In some embodiments, determining at least one target database parameter of the target database based on the target encoding includes: inputting the target encoding into a parameter generation model and outputting at least one target database parameter of the target database. Since the target encoding contains richer query information and database parameter information, the parameter generation model can output more accurate target database parameters, thereby improving query accuracy after parameter adjustment of the target database.
[0155] Optionally, the parameter generation model can also be pre-trained. The pre-training training data can be multiple codes obtained by encoding multiple historical query requests using any embodiment or arrangement / combination of the embodiments of method 300. These codes, along with the database parameters corresponding to the historical query requests, are used as training data. Then, the initial model is trained using this training data to obtain the parameter generation model. In this way, the model trained using multiple codes obtained by encoding multiple historical query requests using any embodiment or arrangement / combination of the embodiments of method 300 can make the output database parameters more closely match the query requests, improving query accuracy.
[0156] This disclosure also provides a computer device for implementing the above-described method 300 or method 400. Figure 5A schematic diagram of the hardware structure of an exemplary computer device 500 provided in an embodiment of this disclosure is shown. The computer device 500 can be used to implement... Figure 1 Server 106 can also be used to implement Figure 1 Terminal devices 102 and 104. In some scenarios, this computer device 500 can also be used to implement... Figure 1 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, memory 504, network module 506, and peripheral interface 508 are interconnected within the computer device 500 via the bus 510.
[0158] Processor 502 may be a central processing unit (CPU), image processor, neural network processor (NPU), microcontroller (MCU), programmable logic device, digital signal processor (DSP), application-specific integrated circuit (ASIC), or one or more integrated circuits. Processor 502 can be used to perform functions related to the techniques described in this disclosure. In some embodiments, processor 502 may also include multiple processors integrated as a single logic component. For example, such as... Figure 5 As shown, processor 502 may include multiple processors 502a, 502b and 502c.
[0159] Memory 504 can be configured to store data (e.g., instructions, computer code, etc.). Figure 5 As shown, the data stored in memory 504 may include program instructions (e.g., program instructions for implementing method 300 or method 400 of the embodiments of this disclosure) and data to be processed (e.g., the memory may store configuration files of other modules, etc.). Processor 502 may also access the program instructions and data stored in memory 504 and execute the program instructions to operate on the data to be processed. Memory 504 may include volatile storage devices or non-volatile storage devices. In some embodiments, memory 504 may include random access memory (RAM), read-only memory (ROM), optical disk, magnetic disk, hard disk, solid-state drive (SSD), flash memory, memory stick, etc.
[0160] Network interface 506 can be configured to provide communication with other external devices to computer device 500 via a network. This 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), etc.), a cellular network, the Internet, or a combination thereof. It is understood that the type of network is not limited to the specific examples described above.
[0161] The peripheral interface 508 can be configured to connect the computer device 500 to one or more peripheral devices to enable information input and output. For example, peripheral devices may include input devices such as keyboards, mice, touchpads, touch screens, microphones, and various sensors, as well as output devices such as displays, speakers, vibrators, and indicator lights.
[0162] Bus 510 can be configured to transfer information between various components of computer device 500 (e.g., processor 502, memory 504, network interface 506, and peripheral interface 508), such as internal buses (e.g., processor-memory bus), external buses (USB port, PCI-E bus), etc.
[0163] It should be noted that although the architecture of the computer device 500 described above only shows the processor 502, memory 504, network interface 506, peripheral interface 508, and bus 510, in specific implementations, the architecture of the computer device 500 may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the architecture of the computer device 500 described above may only include the components necessary for implementing the embodiments of this disclosure, and does not necessarily include all the components shown in the figures.
[0164] This disclosure also provides an encoding device 600. Figure 6 A schematic diagram of an exemplary apparatus 600 provided in an embodiment of this disclosure is shown. For example... Figure 6 As shown, the device 600 can be used to implement method 300 and may 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 query target data in the target database;
[0166] The acquisition module 604 is configured to: acquire the query plan corresponding to the query request and multiple current database parameters of the target database, wherein the query plan includes multiple nodes;
[0167] The generation module 606 is configured to: generate multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters based on the multiple nodes of the query plan and the multiple current database parameters;
[0168] The determination module 608 is configured to: determine the association relationship between the plurality of nodes and the plurality of current database parameters;
[0169] The encoding module 610 is configured to obtain the target encoding based on the plurality of first vectors and the plurality of second vectors according to the association relationship.
[0170] In some embodiments, the query plan also includes the connection relationships between the plurality of nodes;
[0171] Module 606 is configured as follows:
[0172] The multiple nodes of the query plan are encoded respectively to obtain multiple node vectors;
[0173] Based on the connection relationships between the multiple nodes and the multiple node vectors, multiple first vectors corresponding to the multiple nodes are generated.
[0174] In some embodiments, the generation module 606 is configured to:
[0175] Calculate self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes;
[0176] Based on the connection relationships 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 generation module 606 is configured to:
[0178] The multiple current database parameters are encoded 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 generation module 606 is configured to:
[0181] For each of the current database parameters, the current database parameter is normalized according to its value range to obtain a normalized parameter;
[0182] Generate the parameter vector corresponding to each current database parameter based on the normalization parameter of each current database parameter.
[0183] In some embodiments, the encoding module 610 is configured to:
[0184] Based on the plurality of first vectors, generate a plurality of key vectors and a plurality of value vectors;
[0185] Based on the multiple second vectors, generate multiple query vectors;
[0186] Based on the association, and using the plurality of query vectors and the plurality of key vectors, calculate the self-attention score for each query vector;
[0187] The attention weights are determined based on the self-attention score of each query vector;
[0188] The target encoding is obtained based on the attention weights and the plurality of value vectors.
[0189] In some embodiments, the determining module 608 is configured to: construct a correlation matrix between the plurality of nodes and the plurality of current database parameters using an algorithm for interpreting a tree-based model, the correlation matrix being used to describe the association relationship.
[0190] In some embodiments, the encoding module 610 is configured to:
[0191] Based on the plurality of query vectors and the plurality of key vectors, calculate the initial self-attention score for each query vector;
[0192] The initial self-attention score of each query vector is masked using the correlation matrix to obtain the self-attention score of each query vector.
[0193] In some embodiments, the current database parameters include the hardware parameters of the target database.
[0194] For ease of description, the above apparatus is described in terms of its functions, divided into various modules. Of course, in implementing this disclosure, the functions of each module can be implemented in one or more software and / or hardware.
[0195] The apparatus of the above embodiments is used to implement the corresponding method 300 in any of the foregoing embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0196] This disclosure also provides a data query device 700. Figure 7 A schematic diagram of an exemplary apparatus 700 provided in an embodiment of this disclosure is shown. For example... Figure 7As shown, the device 700 can be used to implement method 400 and may 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 a query for the target data in the target database;
[0198] The acquisition module 704 is configured to: acquire multiple current database parameters of the target database;
[0199] Encoding module 706 is configured to: encode the query request and the plurality of current database parameters to obtain the target code corresponding to the query request by using any embodiment or arrangement and combination of the embodiments of the method 300;
[0200] The determining 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 determining module 708 is configured to: generate a model from the target encoding input parameters and output at least one target database parameter to obtain the target database.
[0204] For ease of description, the above apparatus is described in terms of its functions, divided into various modules. Of course, in implementing this disclosure, the functions of each module can be implemented in one or more software and / or hardware.
[0205] The apparatus of the above embodiments is used to implement the corresponding method 400 in any of the foregoing embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0206] Based on the same inventive concept, corresponding to any of the above embodiments, this disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the 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, program modules, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0208] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to perform the 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 method 300 or method 400 in any of the above embodiments, this disclosure also provides a computer program product, which includes a computer program. In some embodiments, the computer program is executable by one or more processors to cause the processors to perform the method 300 or method 400. Corresponding to the execution entity for each step in each embodiment of method 300 or method 400, the processor executing the corresponding step may belong to the corresponding execution entity.
[0210] The computer program product of the above embodiments is used to cause a processor to execute the 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 repeated here.
[0211] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of this disclosure (including the claims) is limited to these examples; within the framework of this disclosure, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of this disclosure as described above, which are not provided in detail for the sake of brevity.
[0212] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of this disclosure, the provided drawings may or may not show well-known power / ground connections to integrated circuit (IC) chips and other components. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of this disclosure, and this also takes into account the fact that the details of implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of this disclosure will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuitry) have been set forth to describe exemplary embodiments of this disclosure, it will be apparent to those skilled in the art that the embodiments of this disclosure may be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0213] Although this disclosure has been described in conjunction with specific embodiments thereof, many substitutions, 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 be used with the embodiments discussed.
[0214] This disclosure is 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 this disclosure should be included within the scope of protection of this disclosure.
Claims
1. An encoding method, comprising: Receive a query request, the query request being used to request the query of target data in the target database; The query plan corresponding to the query request and multiple current database parameters of the target database are obtained. The query plan is generated based on the query request and includes steps for executing the query request. The query plan is converted into multiple nodes. Based on 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; Determine the association between the plurality of nodes and the plurality of current database parameters; The association is used to indicate the impact of the current database parameters on the node; Based on the aforementioned association, and using the plurality of first vectors and the plurality of second vectors, the target encoding is obtained; The target code is used to determine the target database parameters, and the target database parameters are used to adjust the database parameters of the target database; The query plan also includes the connection relationships between the multiple nodes; Based on 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, including: The multiple nodes of the query plan are encoded respectively to obtain multiple node vectors; Based on the connection relationships between the plurality of nodes and the plurality of node vectors, generate a plurality of first vectors corresponding to the plurality of nodes; Specifically, based on 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 are generated, including: The multiple current database parameters are encoded 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.
2. The method of claim 1, wherein, Based on the connection relationships between the plurality of nodes and the plurality of node vectors, generate a plurality of first vectors corresponding to the plurality of nodes, including: Calculate self-attention scores for the multiple node vectors to obtain multiple self-attention codes corresponding to the multiple nodes; Based on the connection relationships between the multiple nodes and the multiple self-attention codes, multiple first vectors corresponding to the multiple nodes are generated.
3. The method as described in claim 1, 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 its value range to obtain a normalized parameter; Generate the parameter vector corresponding to each current database parameter based on the normalization parameter of each current database parameter.
4. The method of claim 1, wherein, Based on the aforementioned association, and using the first vector and the second vector, the target encoding is obtained, including: Based on the plurality of first vectors, generate a plurality of key vectors and a plurality of value vectors; Based on the multiple second vectors, generate multiple query vectors; Based on the association, and using the plurality of query vectors and the plurality of key vectors, calculate the self-attention score for each query vector; The attention weights are determined based on the self-attention score of each query vector; The target encoding is obtained based on the attention weights and the plurality of value vectors.
5. The method of claim 4, wherein, Determining the association between the plurality of nodes and the plurality of current database parameters includes: An algorithm for interpreting tree-based models is used to construct a correlation matrix between the plurality of nodes and the plurality of current database parameters, the correlation matrix being used to describe the association relationship.
6. The method of claim 5, wherein, Based on the association, and using the plurality of query vectors and the plurality of key vectors, calculate the self-attention score for each query vector, including: Based on the plurality of query vectors and the plurality of key vectors, calculate the initial self-attention score for each query vector; The initial self-attention score of each query vector is masked using the correlation matrix to obtain the self-attention score of each query vector.
7. The method of claim 1, wherein, The current database parameters include the hardware parameters of the target database.
8. A data query method, comprising: Receive a query request for target data, the query request being used to request the query for the target data in the target database; Obtain multiple current database parameters of the target database; The method described in any one of claims 1 to 7 is used to encode the query request and the plurality of current database parameters to obtain the target code corresponding to the query request; Based on the target encoding, at least one target database parameter of the target database is determined; Based on the at least one target database parameter, adjust at least one database parameter of the target database; Based on the query request, the target data is queried in the target database after parameter adjustment.
9. The method of claim 8, wherein, Based on the target encoding, at least one target database parameter of the target database is determined, including: The target encoding input parameters are used to generate a model, and at least one target database parameter is output to obtain the target database.
10. An encoding device, comprising: The receiving module is configured to receive a query request, wherein the query request is used to request query target data in the target database; The acquisition module is configured to: acquire the query plan corresponding to the query request and multiple current database parameters of the target database, wherein the query plan is generated based on the query request and includes steps for executing the query request, and the query plan is converted into multiple nodes; The generation module is configured to: generate multiple first vectors corresponding to the multiple nodes and multiple second vectors corresponding to the multiple current database parameters based on the multiple nodes of the query plan and the multiple current database parameters; The determination module is configured to: determine the association relationship between the plurality of nodes and the plurality of current database parameters; the association relationship is used to indicate the influence of the current database parameters on the nodes; The encoding module is configured to: obtain a target encoding based on the association relationship, the plurality of first vectors, and the plurality of second vectors; the target encoding is used to determine target database parameters, and the target database parameters are used to adjust the database parameters of the target database; The query plan also includes the connection relationships between the multiple nodes; Based on 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, including: The multiple nodes of the query plan are encoded respectively to obtain multiple node vectors; Based on the connection relationships between the plurality of nodes and the plurality of node vectors, generate a plurality of first vectors corresponding to the plurality of nodes; Specifically, based on 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 are generated, including: The multiple current database parameters are encoded 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.
11. A data query device, comprising: The receiving module is configured to receive a query request for target data, wherein the query request is used to request a query for the target data in the target database; The acquisition module is configured to acquire multiple current database parameters of the target database; The encoding module is configured to: encode the query request and the plurality of current database parameters to obtain the target encoding corresponding to the query request by using the method described in any one of claims 1 to 7; The determining module is configured to: determine at least one target database parameter of the target database based on the target encoding; The adjustment module is 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: query the target data in the target database after parameter adjustment based on the query request.
12. 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, the programs comprising instructions for performing the method according to any one of claims 1 to 7 or the method according to claim 8 or 9.
13. A non-volatile computer-readable storage medium comprising 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 7 or the method of claim 8 or 9.
14. A computer program product comprising computer program instructions that, when executed on a computer, cause the computer to perform the method as claimed in any one of claims 1 to 7 or the method as claimed in claim 8 or 9.
Citation Information
Patent Citations
Text retrieval method and device, electronic equipment and storage medium
CN117149990A
