Database query parameter optimization method and device, medium, equipment and product
By predicting the execution success status of database query parameters and updating parameters, the problem of database query performance optimization is solved, and efficient and accurate query operations are achieved.
Patent Information
- Application Number
- CN202411596953.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-01-21
AI Technical Summary
In a database system, how to effectively optimize database query parameters to improve query performance and adapt to different usage scenarios.
By obtaining the database query parameters, the successful status of query operations based on these parameters and preset query plan information, and update the query parameters under the prediction of success to ensure the accuracy and integrity of the query operation.
The accurate update of the database query parameters has been achieved, the database query performance is improved, and the success and efficiency of the query operation is ensured.
Smart Images

Figure CN119336793A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of database technology, and in particular, to a database query parameter optimization method, device, medium, equipment and product. Background Art
[0002] With the continuous development of the Internet, the amount of data that needs to be processed on the Internet is increasing day by day. As a system for storing, managing, maintaining and retrieving data, databases play an increasingly important role.
[0003] In a database system, database parameters play a very important role. Taking an analytical query engine as an example, when executing SQL query operations, the analytical query engine needs to consume a lot of resources for data scanning and calculation. Many query-level parameters in the database system are closely related to the amount of resources used for the query. Therefore, the parameters in the database system have a direct impact on the operations performed by the database. In addition, during the use of the database, the parameters of the database also need to be adjusted to make the database adapt to different usage scenarios and meet different usage requirements. Therefore, how to set appropriate parameters for the database system is a problem that needs to be solved in the field of database technology. Summary of the invention
[0004] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, the present disclosure provides a method for optimizing database query parameters, the method comprising: Obtaining a first database query parameter; Determine a first query execution result according to the first database query parameter, the first query execution result including first query status information, the first query status information being used to indicate whether the first database query operation can be successfully executed according to the first database query parameter and the preset query plan information; When the first query state information indicates success, the first database query parameter is updated according to the first query execution result.
[0006] In a second aspect, the present disclosure provides a database query parameter optimization device, the device comprising: A first acquisition module, used to acquire a first database query parameter; A first determination module, configured to determine a first query execution result according to the first database query parameter, wherein the first query execution result includes first query status information, wherein the first query status information is used to indicate whether the first database query operation is predicted to be successful if it is executed according to the first database query parameter and preset query plan information; An updating module is used to update the first database query parameter according to the first query execution result when the first query state information indicates that the query is successful.
[0007] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the database query parameter optimization method provided in the first aspect of the present disclosure.
[0008] In a fourth aspect, the present disclosure provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the database query parameter optimization method provided in the first aspect of the present disclosure.
[0009] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the database query parameter optimization method provided in the first aspect of the present disclosure.
[0010] Through the above technical scheme, the first query execution result is determined according to the first database query parameters, and the first query execution result includes first query status information. The first query status information is used to characterize the prediction of whether the first database query operation can be successfully executed according to the first database query parameters and preset query plan information. In the process of updating the first database query parameters, it is predicted whether the first database query parameters can make the query operation execute successfully. When the first query status information characterizes that it can be successful, the obtained first query execution result is accurate and complete. The first database query parameters are updated according to the first query execution result, and the updating basis is accurate, so that the first database query parameters are accurately updated, thereby achieving the purpose of optimizing the first database query parameters.
[0011] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 The figure is a flow chart of a method for optimizing database query parameters according to an exemplary embodiment.
[0013] Figure 2 The figure is a flowchart of a method for optimizing database query parameters according to another exemplary embodiment.
[0014] Figure 3 The diagram is a schematic diagram showing a method of determining a first query execution result according to an exemplary embodiment.
[0015] Figure 4 The diagram is a schematic diagram showing a method of determining a first query execution result according to an exemplary embodiment.
[0016] Figure 5 The invention is a flowchart showing a method for determining query characteristic information according to second query performance characteristic information and second query state characteristic information according to an exemplary embodiment.
[0017] Figure 6 The figure is a flow chart of a method for optimizing database query parameters according to an exemplary embodiment.
[0018] Figure 7 The figure is a block diagram of a database query parameter optimization device according to an exemplary embodiment.
[0019] Figure 8 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0020] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0021] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0022] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0023] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0024] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0025] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0026] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0027] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously 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.
[0028] As an optional but non-limiting implementation, in response to receiving an active request from the user, 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.
[0029] 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 the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0030] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0031] Figure 1 FIG. 1 is a flowchart of a method for optimizing database query parameters according to an exemplary embodiment. The method can be applied to electronic devices with processing capabilities, such as servers, personal computers, and other devices. Figure 1 As shown, the method may include steps 11 to 13.
[0032] In step 11, a first database query parameter is obtained.
[0033] The database query parameters include parameters related to the database query operation, such as parameters related to the amount of resources used for the query, etc. During the use of the database, in order to adapt the database to different usage scenarios and meet different usage requirements, or to optimize the performance of the database, the database query parameters need to be adjusted.
[0034] In the present disclosure, the first database query parameter may be a database query parameter that needs to be adjusted. For example, the first database query parameter may be a query parameter that needs to be adjusted and is actually used in the database, or may be a parameter randomly generated within the value range corresponding to the query parameter actually used in the database. In addition, in the present disclosure, the first database query parameter may be updated through multiple iterations, and in this iteration, the first database query parameter may be the first database query parameter after the update in the previous iteration. In one embodiment, the first database query parameter may be a single query parameter to be adjusted. In another embodiment, since there are usually multiple database query parameters, and multiple database query parameters act together on the query operation of the database, preferably, the first database query parameter may be a group of parameters, i.e., including multiple database query parameters. In the present disclosure, these multiple database query parameters may be updated.
[0035] In step 12, a first query execution result is determined according to the first database query parameter.
[0036] Among them, the first query execution result includes first query status information, and the first query status information is used to characterize whether the first database query operation can be successfully executed according to the first database query parameters and the preset query plan information. The preset query plan information may include query execution steps set to complete the query operation. For example, the first database query parameters and query plan information can be input into a neural network model, and the neural network model can be used to predict the query execution result to obtain the first query execution result output by the neural network model, or the database query operation can be simulated according to the first database query parameters to obtain the first query execution result.
[0037] By way of example, the first query execution result may also include a predicted first query performance parameter corresponding to the first database query operation. The query performance parameter may include parameters used to characterize database query performance and query efficiency. The first query performance parameter may, for example, include a first query duration, a first query throughput, etc. corresponding to the first database query operation.
[0038] In step 13, when the first query state information indicates that the query is successful, the first database query parameter is updated according to the first query execution result.
[0039] Taking the analytical query engine as an example, the analytical query engine needs to consume a lot of resources to scan and calculate data for SQL query. If the query parameters are not appropriate, the query may fail due to improper resource consumption. If the first query status information represents a query failure, it means that the prediction that executing the first database query operation according to the first database query parameters will cause the query to fail, then the first query execution results such as query duration, query throughput, etc. are often inaccurate or missing. In this case, if the first database query parameters are updated according to the first query execution results, the accuracy of the updated query parameters will be reduced.
[0040] Therefore, in the process of updating the first data query parameters, if there is no prediction of whether the query can be successful, directly updating the first database query parameters may lead to inaccurate parameter updates. In the present disclosure, when the first query status information characterizes that it can be successful, the first query performance parameters obtained are accurate and complete. Therefore, the first database query parameters are updated based on the first query execution result, and the update basis is accurate. For example, the first database query parameters are updated for the purpose of making the query performance better (such as shorter query time) to optimize the first database query parameters, and the updated first database query parameters are within the value range to ensure the validity of the updated parameters. It should be noted that the above example of an analytical query engine is for explanation only, and the present disclosure is also applicable to parameter adjustments of other types of database query engines.
[0041] In the present disclosure, the first database query parameter can be updated once according to the first query execution result, and the updated first database query parameter can optimize the database query performance, which can achieve the purpose of optimizing the first database query parameter. Preferably, the first database query parameter can also be updated multiple times, so that the iteratively updated first database query parameter can further optimize the database query performance.
[0042] Through the above technical scheme, the first query execution result is determined according to the first database query parameters, and the first query execution result includes first query status information. The first query status information is used to characterize the prediction of whether the first database query operation can be successfully executed according to the first database query parameters and preset query plan information. In the process of updating the first database query parameters, it is predicted whether the first database query parameters can make the query operation execute successfully. When the first query status information characterizes that it can be successful, the obtained first query execution result is accurate and complete. The first database query parameters are updated according to the first query execution result, and the updating basis is accurate, so that the first database query parameters are accurately updated, thereby achieving the purpose of optimizing the first database query parameters.
[0043] Figure 2 is a flowchart of a method for optimizing database query parameters according to another exemplary embodiment. Figure 2 As shown, the database query parameter optimization method may further include steps 14 and 15, and the implementation of step 12 may be the same as step 121. Figure 2 There is no restriction on the execution order of the steps, for example, step 14 may be executed before step 11, or step 14 and step 11 may be executed in parallel.
[0044] In step 14, sample data is obtained.
[0045] The sample data may include second database query parameters, query plan information, pre-marked second query status information and second query performance parameters. The second query status information is used to characterize whether the second database query operation executed according to the second database query parameters and query plan information is successful. The second query performance parameters are query performance parameters corresponding to the second database query operation.
[0046] Among them, the second database query parameter can be a query parameter actually used in the database system, or a sample parameter generated by a method in the relevant technology, and the second database query parameter can be the same as or different from the first database query parameter. The second query performance parameter includes, for example, the second query duration and the second query throughput corresponding to the second database query operation. The pre-annotated second query status information and second query performance parameters can be the actual query status information and query performance parameters obtained by the database system based on the second database query parameters, or can be manually annotated query status information and query performance parameters, or can be any method in the relevant technology, such as query status information and query performance parameters obtained by a neural network model used to determine the query execution result. The present disclosure does not limit the method for obtaining the pre-annotated second query status information and second query performance parameters.
[0047] For example, the second database query parameters may be M groups, M ≥ 1, M is a positive integer, and each group of second database query parameters may include multiple query parameters. If the second database query parameters are a group, the second query performance parameter is the query performance parameter obtained according to the group of second database query parameters, and the second query status information is the query status information obtained according to the group of second database query parameters. Preferably, in order to enrich the sample data, the second database query parameters may be multiple groups, and the second database query parameters included in different groups may be different. For example, the second database query parameters may be 3 groups. For example, the second database query parameters of the first group correspond to the second query performance parameter Y. 1 t and the second query status information Y 1 e , the second database query parameter of the second group corresponds to the second query performance parameter Y 2 t and the second query status information Y 2 e , the third group of second database query parameters corresponds to the second query performance parameter Y 3 t and the second query status information Y 3 e .
[0048] In step 15, query feature information is determined based on the fusion of the second query performance parameter and the second query state information.
[0049] Among them, the second query performance parameter characterizes the query performance of the database, and the second query status information characterizes whether the query operation is successful. Information fusion is performed based on the second query performance parameter and the second query status information, and the obtained query feature information includes both features characterizing the query performance and features characterizing whether the query operation is successful.
[0050] In step 121, a first query execution result is determined according to the query characteristic information and the first database query parameter.
[0051] In this way, the first query performance parameter and the first query status information are determined according to the query characteristic information obtained by fusion of the query parameter and information of the first database. When predicting the query performance, the characteristics of the query status information that characterizes whether the query operation is successful can be simultaneously referred to, so as to improve the accuracy of the determined first query performance parameter. When predicting whether the query operation is successful, the characteristics of the query performance parameter can be simultaneously referred to, so as to improve the accuracy of the determined first query status information.
[0052] In the present disclosure, the second database query parameter may be M groups, M≥1, and M is a positive integer. Accordingly, in step 15, the implementation method of determining the query feature information by fusing the second query performance parameter and the second query state information may be: For each group of second database query parameters, feature extraction is performed according to the second query performance parameters corresponding to the group of second database query parameters and the first vector representation corresponding to the group of second database query parameters to obtain first query performance feature information corresponding to the group of second database query parameters, and feature extraction is performed according to the second query state information corresponding to the group of second database query parameters and the first vector representation corresponding to the group of second database query parameters to obtain first query state feature information corresponding to the group of second database query parameters, wherein the first vector representation corresponding to the group of second database query parameters is a vector representation generated according to the query plan information and the group of second database query parameters; The query characteristic information is determined according to the first query performance characteristic information respectively corresponding to each group of second database query parameters and the first query state characteristic information respectively corresponding to each group of second database query parameters.
[0053] Figure 3 The diagram is a schematic diagram showing a method of determining a first query execution result according to an exemplary embodiment. Figure 3 Take three groups of second database query parameters as an example. For example, the first group of second database query parameters includes parameters a 1 and a2 , can be based ona 1. a 2 and the query plan information generate the first vector representation x1 corresponding to the first group of second database query parameters, for example, the vector representation can be generated by a vector encoder. Similarly, the second group of second database query parameters corresponds to the first vector representation x2, and the third group of second database query parameters corresponds to the first vector representation x3.
[0054] The present disclosure does not limit the feature extraction method. For example, the first vector representation and the second query performance parameter can be input into the performance feature extraction model to obtain the first query performance feature information, and the first vector representation and the second query state information can be input into the state feature extraction model to obtain the first query state feature information. Figure 3 As shown, for the first group of second database query parameters, according to the first vector representation x1 and the second query performance parameter Y 1 t By performing feature extraction, the first query performance feature information F can be obtained. 1 t , based on the first vector representation x1 and the second query state information Y 1 e By performing feature extraction, the first query state feature information F can be obtained. 1 e For the second group of second database query parameters, according to the first vector representation x2 and the second query performance parameter Y 2 t By performing feature extraction, the first query performance feature information F can be obtained. 2 t , based on the first vector representation x2 and the second query state information Y 2 e By performing feature extraction, the first query state feature information F can be obtained. 2 e For the third group of second database query parameters, according to the first vector representation x3 and the second query performance parameter Y 3 t By performing feature extraction, the first query performance feature information F can be obtained. 3 t , based on the first vector representation x3 and the second query state information Y 3 e By performing feature extraction, the first query state feature information F can be obtained. 3 e .
[0055] In one embodiment, the first query performance characteristic information corresponding to each group of second database query parameters and the first query state characteristic information corresponding to each group of second database query parameters may be directly fused to obtain query characteristic information.
[0056] Through the above technical solution, there can be M groups of second database query parameters, each group can correspond to different first query performance characteristic information and first query state characteristic information, so that the query characteristic information obtained after fusion covers richer query performance characteristic information and query state characteristic information.
[0057] In another embodiment, determining the query characteristic information according to the first query performance characteristic information respectively corresponding to each group of second database query parameters and the first query state characteristic information respectively corresponding to each group of second database query parameters may include: Performing an aggregation operation on the first query performance characteristic information respectively corresponding to each group of second database query parameters to obtain second query performance characteristic information; Performing an aggregation operation on the first query state characteristic information corresponding to each group of second database query parameters to obtain second query state characteristic information; The query characteristic information is determined according to the second query performance characteristic information and the second query state characteristic information.
[0058] like Figure 3 As shown, the first query performance characteristic information F 1 t , first query performance characteristic information F 2 t and the first query performance characteristic information F 3 t Perform aggregation operation to obtain the aggregated second query performance characteristic information F t . The first query state feature information F 1 e , first query state characteristic information F 2 e and the first query state feature information F 3 e Perform aggregation operation to obtain the aggregated second query state feature information F e。 For example, the second query performance characteristic information F t and the second query state feature information F e Information fusion is performed to obtain query feature information. Then, a first query execution result is obtained according to the query feature information and the first database query parameter, for example, the query feature information and the first database query parameter are input into a neural network model for predicting the query execution result to obtain the first query execution result output by the neural network model.
[0059] Through the above technical scheme, the aggregated second query performance characteristic information may include the characteristics of the query performance corresponding to each group of second database query parameters, and the aggregated second query state characteristic information may include the characteristics of the query state corresponding to each group of second database query parameters. Information fusion is performed based on the second query performance characteristic information and the second query state characteristic information, so that the query performance characteristic information and the query state characteristic information covered by the fused query characteristic information are richer.
[0060] In the related art, the Bayesian optimization method based on Gaussian Processes (GP) is mainly used to adjust the database parameters. Considering that when dealing with problems, Gaussian processes generally obtain prior information through the key path of parameterized kernel functions, however, in actual application scenarios, it is very difficult to design a suitable kernel function, and the computational complexity of Gaussian processes is relatively high. Moreover, Gaussian processes are not built based on deep learning and cannot integrate deep encoders. Therefore, in the present disclosure, the query execution results are predicted based on neural processes (NP), thereby updating the first database query parameters. Among them, the neural process has high computing efficiency that the Gaussian process does not have. When facing large-scale data and complex computing tasks, the advantage of high computing efficiency is particularly important, which can improve the operating speed and responsiveness of the system. In addition, the neural process has probabilistic modeling capabilities, which can better handle the uncertainty in the data and provide a more reliable and accurate basis for updating the database query parameters.
[0061] Among them, when processing data based on neural processes, it is divided into deterministic paths and potential paths, and the potential path can also be called an uncertain path. The sample data can be regarded as a context set in the neural process, and the context set can include input and output pairs corresponding to each set of second database query parameters ( x C, y C1) and ( x C, y C2), x C is the first vector representation, y C1 may be the corresponding second query performance parameter, y C2 can be the corresponding second query state information. The neural process defines the conditional distribution p ( y D| x D, C), where C represents the context set, x D represents the vector representation generated according to the first database query parameter, which can be , yD represents the predicted first query execution result. The deterministic path can abstractly express the context set as deterministic feature information, which characterizes the deterministic and stable features in the context set. The latent path can model a global latent variable from the context set, and the global latent variable can reflect the global uncertainty in the context set, such as data noise.
[0062] In the present disclosure, feature information may include deterministic feature information and latent feature information. The deterministic feature information is used to characterize the deterministic features in the sample data, and the latent feature information is used to characterize the latent features in the sample data. Figure 4 The diagram is a schematic diagram showing a method of determining a first query execution result according to an exemplary embodiment. Figure 4 The model shown can be viewed as a dual-task neural process model. The dual-task refers to two prediction tasks: predicting the first query performance parameter and predicting the first query state information. The information processing in each task can be divided into a deterministic path and a potential path.
[0063] For example, the first vector representation and the second query performance parameter are input to the first encoder in the neural process model, and the first encoder can generate the first query performance deterministic feature information based on the deterministic path and the first query performance potential feature information based on the potential path according to the first vector representation and the second query performance parameter. The first vector representation and the second query state information are input to the second encoder in the neural process model, and the second encoder can generate the first query state deterministic feature information based on the deterministic path and the first query state potential feature information based on the potential path according to the first vector representation and the second query state information. The first encoder and the second encoder can both be in the form of a multilayer perceptron (MLP), for example.
[0064] like Figure 4 As shown, for the first group of second database query parameters, according to the first vector representation x1 and the second query performance parameter Y 1 t By performing feature extraction, the first query performance deterministic feature information r can be obtained. 1 t and the first query performance potential feature information s 1 t , that is, the first query performance characteristic information F 1 t May include first query performance deterministic feature information r 1 t and the first query performance potential feature information s 1 t , based on the first vector representation x1 and the second query state information Y 1 eBy performing feature extraction, the deterministic feature information r of the first query state can be obtained. 1 e and the first query state potential feature information s 1 e , i.e. the first query state feature information F 1 e Including the first query state deterministic feature information r 1 e and the first query state potential feature information s 1 e .
[0065] For the second group of second database query parameters, according to the first vector representation x2 and the second query performance parameter Y 2 t By performing feature extraction, the first query performance deterministic feature information r can be obtained. 2 t and the first query performance potential feature information s 2 t , that is, the first query performance characteristic information F 2 t May include first query performance deterministic feature information r 2 t and the first query performance potential feature information s 2 t , based on the first vector representation x2 and the second query state information Y 2 e By performing feature extraction, the deterministic feature information r of the first query state can be obtained. 2 e and the first query state potential feature information s 2 e , i.e. the first query state feature information F 2 e Including the first query state deterministic feature information r 2 e and the first query state potential feature information s 2 e .
[0066] For the third group of second database query parameters, according to the first vector representation x3 and the second query performance parameter Y 3 t By performing feature extraction, the first query performance deterministic feature information r can be obtained. 3 t and the first query performance potential feature information s 3 t , that is, the first query performance characteristic information F 3 tMay include first query performance deterministic feature information r 3 t and the first query performance potential feature information s 3 t , based on the first vector representation x3 and the second query state information Y 3 e By performing feature extraction, the deterministic feature information r of the first query state can be obtained. 3 e and the first query state potential feature information s 3 e , i.e. the first query state feature information F 3 e Including the first query state deterministic feature information r 3 e and the first query state potential feature information s 3 e .
[0067] Among them, the second query performance characteristic information F t The second query performance deterministic feature information may include t and the second query performance potential feature information s t , the second query state feature information F e The second query state deterministic feature information r may be included e and the second query state potential feature information s e .
[0068] In one embodiment, the first query performance deterministic characteristic information corresponding to each group of second database query parameters can be mean-aggregated to obtain second query performance deterministic characteristic information, and the first query state deterministic characteristic information corresponding to each group of second database query parameters can be mean-aggregated to obtain second query state deterministic characteristic information.
[0069] In another embodiment, the second query performance deterministic characteristic information and the second query state deterministic characteristic information are obtained in the following manner: By using an attention mechanism, the second vector representation, the first vector representation corresponding to each set of second database query parameters, and the first query deterministic feature information corresponding to each set of second database query parameters are aggregated to obtain second query deterministic feature information, where the second vector representation is a vector representation generated according to the first database query parameters and the query plan information. The second query deterministic feature information includes second query performance deterministic feature information and second query state deterministic feature information.
[0070] Among them, through the attention mechanism, the second vector representation, the first vector representation corresponding to each group of second database query parameters, and the first query performance deterministic feature information corresponding to each group of second database query parameters are aggregated to obtain the second query performance deterministic feature information. For example, taking the cross attention mechanism as an example, the second query performance deterministic feature information r can be obtained by the following formula (1): t : (1) in, Cross - Attention () represents the cross attention mechanism function, matrix W q represents the query vector in the cross-attention mechanism, W k represents the key vector in the cross-attention mechanism, W v represents the value vector in the cross-attention mechanism, represents the second vector representation, x represents the first vector representation corresponding to each set of second database query parameters, r t´ Indicates the first query performance deterministic characteristic information corresponding to each group of second database query parameters.
[0071] like Figure 4 As shown, the first query performance deterministic feature information r 1 t、 First query performance deterministic feature information r 2 t , the first query performance deterministic feature information r 3 t , the first vector represents x1, the first vector represents x2, the first vector represents x3, the second vector represents , through the attention mechanism, the aggregation operation is performed to obtain the second query performance deterministic feature information r t .
[0072] Among them, through the attention mechanism, the second vector representation, the first vector representation corresponding to each group of second database query parameters, and the first query state deterministic feature information corresponding to each group of second database query parameters are aggregated to obtain the second query state deterministic feature information. For example, taking the cross attention mechanism as an example, the second query state deterministic feature information r can be obtained by the following formula (2): e : (2) Among them, r e´ Indicates the first query state deterministic feature information corresponding to each group of second database query parameters. Figure 4As shown, the first query state deterministic feature information r 1 e、 First query state deterministic feature information r 2 e , the first query state deterministic feature information r 3 e , the first vector represents x1, the first vector represents x2, the first vector represents x3, the second vector represents , through the attention mechanism, the aggregation operation is performed to obtain the second query state deterministic feature information r e It should be noted that the aggregation operation can also be performed through other attention mechanisms, and the above aggregation operation through the cross attention mechanism is only an example.
[0073] Through the above technical solution, the second query performance deterministic feature information is obtained through the attention mechanism aggregation, which can make the second vector representation generated according to the first database query parameter pay more attention to the data related to the predicted query performance in the sample data, thereby improving the accuracy of the predicted first query performance parameter. The second query state deterministic feature information is obtained through the attention mechanism aggregation, which can make the second vector representation pay more attention to the data related to the predicted query state in the sample data, thereby improving the accuracy of the predicted first query state information.
[0074] For example, the second query performance potential feature information and the second query state potential feature information may be obtained by performing mean aggregation on the first query potential feature information corresponding to each group of second database query parameters to obtain the second query potential feature information. The second query potential feature information includes the second query performance potential feature information and the second query state potential feature information.
[0075] The first query performance potential feature information corresponding to each group of second database query parameters can be averaged and aggregated to obtain the second query performance potential feature information, and the first query state potential feature information corresponding to each group of second database query parameters can be averaged and aggregated to obtain the second query state potential feature information. The second query performance potential feature information can be regarded as a task-internal latent variable for predicting the first query performance parameter, which can reflect information about data distribution and hardware configuration related to query performance, and the second query state potential feature information can be regarded as a task-internal latent variable for predicting the first query state information, which can reflect information such as memory usage threshold and CPU usage threshold related to query status.
[0076] like Figure 4 As shown, for the first query performance potential feature information s 1 t , first query performance potential feature information s 2t and the first query performance potential feature information s 3 t Perform mean aggregation to obtain the second query performance potential feature information s t , for the first query state potential feature information s 1 e , the first query state potential feature information s 2 e and the first query state potential feature information s 3 e Perform mean aggregation to obtain the potential feature information s of the second query state e .
[0077] In this way, by aggregating the potential feature information in the mean aggregation manner, the aggregated second query performance potential feature information can reflect the overall characteristics of the first query performance potential feature information, and the aggregated second query status potential feature information can reflect the overall characteristics of the first query status potential feature information.
[0078] In the present disclosure, the query feature information obtained by fusion may include the third query performance feature information and the third query state feature information. Figure 4 As shown, the query characteristic information may include third query performance deterministic characteristic information 3. Query performance potential feature information , Third query state deterministic feature information , Third query state potential feature information .
[0079] Among them, the feature information from the same path can be fused, that is, the feature information from the same deterministic path can be fused, and the feature information from the same potential path can be fused. In the present disclosure, information fusion can be performed based on the gating mechanism, that is, four complementary pairs are constructed, namely (s t , z)、(r t , r e )、(s e , z)、(r e , r t ), where z represents the global latent variable. The first element in each complementary pair can represent the initial element, and the second element can represent the complementary element. Based on the gating mechanism, the initial element can be used as one of the inputs, and the complementary element can be used as the input of the other complementary pair for information fusion.
[0080] Based on this, the implementation method of determining the query characteristic information according to the second query performance characteristic information and the second query state characteristic information can be as follows: Figure 5 As shown, it includes step 51 and step 52.
[0081] In step 51, information fusion is performed based on the second query performance deterministic characteristic information and the second query state deterministic characteristic information to determine third query performance deterministic characteristic information and third query state deterministic characteristic information.
[0082] The step 51 may include: using one of the second query performance deterministic feature information and the second query state deterministic feature information as the first initial information and the other as the first supplementary information to perform information fusion to obtain third query deterministic feature information corresponding to the first initial information. The third query deterministic feature information includes third query performance deterministic feature information and third query state deterministic feature information.
[0083] For example, information fusion can be performed in the following ways: The first information is obtained by adding the product of the first weight matrix and the supplementary information to the first bias item corresponding to the first weight matrix, wherein the first weight matrix is the weight matrix corresponding to the deterministic feature information; the second information is obtained by adding the product of the second weight matrix and the supplementary information to the second bias item corresponding to the second weight matrix, wherein the second weight matrix is the weight matrix corresponding to the potential feature information; the product of the first preset function value of the first information and the second preset function value of the second information is added to the initial information as the fused information.
[0084] Among them, when processing data, the neural process model is divided into a deterministic path and a potential path. The deterministic path is used to extract deterministic feature information, and the potential path is used to extract potential feature information. The first weight matrix and the second weight matrix can be weight matrices corresponding to different paths, that is, the first weight matrix is a weight matrix corresponding to the deterministic feature information, that is, the deterministic path, and the second weight matrix is a weight matrix corresponding to the potential feature information, that is, the potential path. The first bias term can be a bias vector corresponding to the first weight matrix, and the second bias term can be a bias vector corresponding to the second weight matrix. The first preset function value of the first information can be, for example, tanh () function value, the second preset function value of the second information can be, for example, sigmoid Function value, sigmoid The function can be written as function σ().
[0085] It should be noted that the first weight matrix, the second weight matrix, the first bias item and the second bias item can all be pre-set with initial values. If the first database query parameters are updated in an iterative manner, the first weight matrix, the second weight matrix, the first bias item and the second bias item can all be updated during each iteration to learn more accurate weight matrices and bias items.
[0086] like Figure 4As shown, the second query performance deterministic feature information r t As initial information, the second query state deterministic feature information r e As supplementary information, information fusion is performed to obtain the third query performance deterministic feature information . Corresponding to the above supplementary pair (r t , r e ), for example, the third query performance deterministic characteristic information is obtained by the following formula (3): : (3) in, W 1 is the first weight matrix, W 2 is the second weight matrix, is the first bias term, b e is the second bias term.
[0087] The second query state determines the characteristic information r e As initial information, the second query performance deterministic feature information r t As supplementary information, information fusion is performed to obtain the third query state deterministic feature information . Corresponding to the above complementary pair (r e , r t ), for example, the third query state deterministic feature information is obtained by the following formula (4): : (4) In step 52, information fusion is performed based on the second query performance potential feature information and the second query state potential feature information to determine the third query performance potential feature information and the third query state potential feature information.
[0088] This step 52 may include: The second query performance potential feature information and the second query state potential feature information are sampled and processed to obtain a global potential variable; the second query performance potential feature information and the second query state potential feature information are used as the second initial information and the global potential variable is used as the second supplementary information to perform information fusion to obtain the third query potential feature information corresponding to the second initial information. The third query potential feature information includes the third query performance potential feature information and the third query state potential feature information.
[0089] like Figure 4 As shown, the second query performance potential feature information s t and the second query state potential feature information s eSampling processing, such as ancestor sampling processing, is performed to obtain a global latent variable z. The global latent variable z can be used to characterize the association between the latent features of the query duration and the latent features of the query state. The global latent variable z can also characterize the overall latent features in the sample data. This is also the reason why the latent feature information is aggregated by using mean aggregation instead of attention aggregation. The global latent variable z obtained in this way can reflect the overall global latent features, and can also reflect the association and dependency between the latent features of the query duration and the query state.
[0090] Among them, the second query performance potential feature information s t As the initial information, the global latent variable z is used as supplementary information for information fusion to obtain the third query performance potential feature information . Corresponding to the above supplementary pair (s t , z), for example, the third query performance potential feature information is obtained by the following formula (5): : (5) The second query state potential feature information s e As the initial information, the global latent variable z is used as the supplementary information to perform information fusion to obtain the third query state potential feature information . Corresponding to the above supplementary pair (s e , z), for example, the third query state potential feature information is obtained by the following formula (6): : (6) like Figure 4 As shown, according to the first database query parameter and the third query performance deterministic characteristic information and third query performance potential feature information , the first query performance parameter can be determined. For example, the second vector can be represented by , Third query performance deterministic feature information and third query performance potential feature information , is input to the first decoder in the neural process model, the first decoder is used to predict the database query performance, and the first query performance parameter output by the first decoder is obtained. According to the first database query parameter, the third query state deterministic feature information and the third query state potential feature information , the first query state information can be determined. For example, the second vector can be represented by , Third query state deterministic feature information and the third query state potential feature information , input to the second decoder in the neural process model, the second decoder is used to predict whether the database query can be successful, and obtain the first query state information output by the second decoder.
[0091] It should be noted that for Figure 5 The execution order of step 51 and step 52 shown in the figure is not limited by the present disclosure. Figure 5 The execution order shown is only an example. For example, step 51 may be executed after step 52, or step 51 and step 52 may be executed in parallel.
[0092] Through the above technical solution, the second query performance deterministic feature information and the second query state deterministic feature information can be fused because they both represent deterministic features, and the second query performance potential feature information and the second query state potential feature information can be fused because they both represent potential features. In this way, the fused query feature information obtained includes both features that represent query performance and features that represent whether the query operation is successful. When predicting query performance, the features of the query state information that represent whether the query operation is successful can be referenced at the same time to improve the accuracy of the determined first query performance parameters. When predicting whether the query operation is successful, the features of the query performance parameters can be referenced at the same time to improve the accuracy of the determined first query state information.
[0093] It should be noted that Figure 3 and Figure 4 Taking the second database query parameter as 3 groups as an example is only for explanation and does not constitute a limitation on the implementation mode of the present disclosure. The present disclosure does not limit the value of M.
[0094] Figure 6 is a flow chart of a method for optimizing database query parameters according to an exemplary embodiment. Figure 6 As shown, the method may include steps 61 to 67.
[0095] In step 61, a first database query parameter is obtained.
[0096] In step 62, a first query execution result is determined according to the first database query parameter.
[0097] The implementation of step 61 and step 62 has been described in detail above, and the first query execution result includes first query state information.
[0098] In step 63, it is determined whether the first query status information can be successfully characterized. If the characterization fails, step 64 is executed; if the characterization is successful, step 65 is executed.
[0099] In step 64, the first database query parameter corresponding to the last iteration is used as the first database query parameter finally obtained.
[0100] Among them, if the first query state information indicates that the predicted query failed, the first database query parameter used in this iteration is unsafe and inappropriate, and cannot be used as the final parameter. If it is possible to enter this iteration, the query state information predicted in the previous iteration is successful, and the first database query parameter corresponding to the previous iteration can be used as the final first database query parameter. The first database query parameter corresponding to the previous iteration is the first database query parameter used in the previous iteration before being updated. In addition, since the first query state information indicates a failure, the first query performance parameter obtained is inaccurate and cannot be used as a basis for parameter update, so the iteration process can be exited.
[0101] In step 65, it is determined whether the iteration stop condition is satisfied. If satisfied, step 66 is executed; if not satisfied, step 67 is executed. For example, the iteration stop condition may be that the number of iterations reaches a preset number.
[0102] In step 66, the first database query parameter after the iteration is completed is used as the first database query parameter finally obtained.
[0103] In step 67, the first database query parameter is updated according to the first query execution result, and then steps 62 to 65 are re-executed.
[0104] If the iteration stop condition is not met, the iteration process may continue. Wherein, updating the first database query parameter according to the first query execution result may include: According to the first query execution result and the preset expectation function, the loss value is determined, and the first database query parameter is updated according to the loss value, wherein the expectation function is a function of difference information, a first probability distribution, and a second probability distribution, the difference information is the difference between the optimal performance parameter and the first query performance parameter, the first probability distribution is the probability distribution that the first query state information representation can be successful when the query parameter is the first database query parameter, the second probability distribution is the probability distribution that the query performance parameter is the first query performance parameter when the query parameter is the first database query parameter and the first query state information representation can be successful, the optimal performance parameter is a preset value, or the optimal performance parameter is the optimal value of the first query performance parameters obtained in this iteration and previous iterations respectively.
[0105] The preset expectation function can be shown as the following formula (7): (7) EIC (x ) represents the expected function, max() represents the maximum value function, p ( g ( x )=0| x ) represents the first probability distribution, x represents the first database query parameter, g ( x )=0 means that the first query status information representation can be successful, p ( y | x , g ( x )=0) represents the second probability distribution, y represents the first query performance parameter, represents the optimal performance parameter.
[0106] The optimal performance parameter may be the optimal value of the first query performance parameter obtained in the current iteration and in previous iterations. For example, if the first query performance parameter is the query duration, the optimal performance parameter is the minimum value of the first query performance parameter obtained in the current iteration and in previous iterations. In the present disclosure, the expected function is a function of expected improvement with constraints. Constraints refer to constraints. g ( x )=0, the expectation function incorporates the probability distribution that satisfies the constraints into the expected improvement. Based on the expectation function, the optimal solution can be converged faster during the iteration process, and the iteration stop condition can be to maximize the expectation function, that is, to optimize the query performance while satisfying the requirement of successful query execution.
[0107] It should be noted that if Figure 4 As shown in , if the attention mechanism is used to aggregate the deterministic feature information, after the first database query parameter is updated, the second vector representation The aggregated second query performance deterministic feature information r t and the second query state deterministic feature information r e In addition, the first weight matrix, the second weight matrix, the first bias term and the second bias term mentioned above can also be updated according to the loss value.
[0108] Through the above technical solution, the first database query parameters can be updated in an iterative manner. The preset expected function is a constrained expected improvement function, that is, the first query state information is constrained to represent the success of the query. In this way, the first database query parameters that optimize the query performance can be determined while satisfying the requirement of successful query execution.
[0109] Based on the same inventive concept, the present disclosure also provides a database query parameter optimization device, Figure 7 is a block diagram of a database query parameter optimization device according to an exemplary embodiment. Figure 7 As shown, the device 70 may include: A first acquisition module 71, used to acquire a first database query parameter; A first determination module 72, configured to determine a first query execution result according to the first database query parameter, wherein the first query execution result includes first query status information, wherein the first query status information is used to indicate whether the first database query operation is predicted to be successful if it is executed according to the first database query parameter and the preset query plan information; The updating module 73 is configured to update the first database query parameter according to the first query execution result when the first query status information indicates that the query is successful.
[0110] Optionally, the device 70 further includes: a second acquisition module, used to acquire sample data, wherein the sample data includes a second database query parameter, the query plan information, pre-marked second query state information, and a second query performance parameter, the second query state information is used to characterize whether the second database query operation executed according to the second database query parameter and the query plan information is successful, and the second query performance parameter is a query performance parameter corresponding to the second database query operation; a fusion module, used to fuse the second query performance parameter and the second query state information to determine the query feature information; The first determination module 72 includes: a result determination submodule, which is used to determine the first query execution result according to the query feature information and the first database query parameter.
[0111] Optionally, the second database query parameters are M groups, M≥1; the fusion module includes: a feature extraction submodule, used to perform feature extraction for each group of the second database query parameters according to the second query performance parameters corresponding to the group of the second database query parameters and the first vector representation corresponding to the group of the second database query parameters, so as to obtain the first query performance characteristic information corresponding to the group of the second database query parameters; and perform feature extraction according to the second query status information corresponding to the group of the second database query parameters and the first vector representation corresponding to the group of the second database query parameters, so as to obtain the first query status characteristic information corresponding to the group of the second database query parameters, wherein the first vector representation corresponding to the group of the second database query parameters is a vector representation generated according to the query plan information and the group of the second database query parameters; a first determination submodule, used to determine the query characteristic information according to the first query performance characteristic information corresponding to each group of the second database query parameters and the first query status characteristic information corresponding to each group of the second database query parameters.
[0112] Optionally, the first determination submodule includes: a first aggregation submodule, used to perform aggregation operations according to the first query performance characteristic information corresponding to each group of the second database query parameters, so as to obtain second query performance characteristic information; a second aggregation submodule, used to perform aggregation operations according to the first query status characteristic information corresponding to each group of the second database query parameters, so as to obtain second query status characteristic information; and a second determination submodule, used to determine the query characteristic information according to the second query performance characteristic information and the second query status characteristic information.
[0113] Optionally, the feature information includes deterministic feature information and potential feature information, the deterministic feature information is used to characterize the deterministic features in the sample data, and the potential feature information is used to characterize the potential features in the sample data; wherein, the second query performance deterministic feature information and the second query status deterministic feature information are obtained in the following manner: through an attention mechanism, the second vector representation, the first vector representation corresponding to each group of the second database query parameters, and the first query deterministic feature information corresponding to each group of the second database query parameters are aggregated to obtain the second query deterministic feature information, the second vector representation is a vector representation generated according to the first database query parameters and the query plan information; wherein, the second query performance potential feature information and the second query status potential feature information are obtained in the following manner: the first query potential feature information corresponding to each group of the second database query parameters is mean aggregated to obtain the second query potential feature information.
[0114] Optionally, the query feature information includes third query performance feature information and third query state feature information, the feature information includes deterministic feature information and potential feature information, the deterministic feature information is used to characterize the deterministic features in the sample data, and the potential feature information is used to characterize the potential features in the sample data; the second determination submodule includes: a third determination submodule, used to perform information fusion based on the second query performance deterministic feature information and the second query state deterministic feature information, to determine the third query performance deterministic feature information and the third query state deterministic feature information; a fourth determination submodule, used to perform information fusion based on the second query performance potential feature information and the second query state potential feature information, to determine the third query performance potential feature information and the third query state potential feature information.
[0115] Optionally, the third determination submodule is used to: use one of the second query performance deterministic characteristic information and the second query status deterministic characteristic information as the first initial information and the other as the first supplementary information to perform information fusion to obtain third query deterministic characteristic information corresponding to the first initial information.
[0116] Optionally, the fourth determination submodule includes: a sampling and processing submodule, used to sample and process the second query performance potential feature information and the second query state potential feature information to obtain a global latent variable, and the global latent variable is used to characterize the association between the query duration potential feature and the query state potential feature; a fifth determination submodule, used to perform information fusion using the second query performance potential feature information and the second query state potential feature information as the second initial information and the global latent variable as the second supplementary information to obtain the third query potential feature information corresponding to the second initial information.
[0117] Optionally, information fusion is performed through the following sub-modules: a first information determination sub-module, used to add the product of the first weight matrix and the supplementary information plus the first bias item corresponding to the first weight matrix to obtain first information, wherein the first weight matrix is the weight matrix corresponding to the deterministic feature information; a second information determination sub-module, used to add the product of the second weight matrix and the supplementary information plus the second bias item corresponding to the second weight matrix to obtain second information, wherein the second weight matrix is the weight matrix corresponding to the potential feature information; a calculation sub-module, used to add the product of the first preset function value of the first information and the second preset function value of the second information to the initial information as the fused information.
[0118] Optionally, the device 70 also includes: a second determination module, used to determine whether the iteration stop condition is met when the first query status information representation can be successful; the update module 73 is used to respond to the iteration stop condition not being met, and then update the first database query parameter according to the first query execution result, and trigger the first determination module 72 to re-execute the first query execution result according to the first database query parameter until the iteration stop condition is met.
[0119] Optionally, the first query execution result also includes a predicted first query performance parameter corresponding to the first database query operation; the update module 73 includes: an update submodule, used to determine a loss value according to the first query execution result and a preset expectation function, and update the first database query parameter according to the loss value, wherein the expectation function is a function of difference information, a first probability distribution, and a second probability distribution, the difference information is the difference between the optimal performance parameter and the first query performance parameter, the first probability distribution is the probability distribution that the first query state information representation can be successful when the query parameter is the first database query parameter, the second probability distribution is the probability distribution that the query performance parameter is the first query performance parameter when the query parameter is the first database query parameter and the first query state information representation can be successful, the optimal performance parameter is a preset value, or the optimal performance parameter is the optimal value of the first query performance parameters obtained in this iteration and previous iterations respectively.
[0120] Reference below Figure 8 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing an embodiment of the present disclosure. Figure 8 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure. Figure 8 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0121] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0122] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0123] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0124] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0125] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0126] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains a first database query parameter; determines a first query execution result based on the first database query parameter, and the first query execution result includes first query status information, and the first query status information is used to characterize whether the prediction of whether the first database query operation can be successfully executed according to the first database query parameter and preset query plan information; when the first query status information indicates that it can be successful, the first database query parameter is updated according to the first query execution result.
[0127] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0129] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module does not limit the module itself in some cases. For example, the first acquisition module may also be described as a "module for acquiring a first database query parameter".
[0130] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0131] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0132] According to one or more embodiments of the present disclosure, Example 1 provides a database query parameter optimization method, the method comprising: obtaining a first database query parameter; determining a first query execution result based on the first database query parameter, the first query execution result comprising first query status information, the first query status information being used to characterize whether a prediction of whether the first database query operation can be successfully executed based on the first database query parameter and preset query plan information; and updating the first database query parameter based on the first query execution result when the first query status information characterizes success.
[0133] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, which further includes: obtaining sample data, wherein the sample data includes a second database query parameter, the query plan information, pre-marked second query status information, and a second query performance parameter, the second query status information is used to characterize whether the second database query operation executed according to the second database query parameter and the query plan information is successful, and the second query performance parameter is a query performance parameter corresponding to the second database query operation; determining query feature information based on the fusion of the second query performance parameter and the second query status information; determining the first query execution result based on the first database query parameter, including: determining the first query execution result based on the query feature information and the first database query parameter.
[0134] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein the second database query parameters are M groups, M≥1; the query feature information is determined by fusing the second query performance parameters and the second query status information, including: for each group of the second database query parameters, feature extraction is performed according to the second query performance parameters corresponding to the group of the second database query parameters and the first vector representation corresponding to the group of the second database query parameters to obtain the first query performance feature information corresponding to the group of the second database query parameters, feature extraction is performed according to the second query status information corresponding to the group of the second database query parameters and the first vector representation corresponding to the group of the second database query parameters to obtain the first query status feature information corresponding to the group of the second database query parameters, wherein the first vector representation corresponding to the group of the second database query parameters is a vector representation generated according to the query plan information and the group of the second database query parameters; the query feature information is determined according to the first query performance feature information corresponding to each group of the second database query parameters and the first query status feature information corresponding to each group of the second database query parameters.
[0135] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, which determines the query characteristic information based on the first query performance characteristic information corresponding to each group of the second database query parameters and the first query status characteristic information corresponding to each group of the second database query parameters, including: performing an aggregation operation based on the first query performance characteristic information corresponding to each group of the second database query parameters to obtain the second query performance characteristic information; performing an aggregation operation based on the first query status characteristic information corresponding to each group of the second database query parameters to obtain the second query status characteristic information; and determining the query characteristic information based on the second query performance characteristic information and the second query status characteristic information.
[0136] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 4, wherein the feature information includes deterministic feature information and potential feature information, wherein the deterministic feature information is used to characterize the deterministic features in the sample data, and the potential feature information is used to characterize the potential features in the sample data; wherein the second query performance deterministic feature information and the second query state deterministic feature information are obtained in the following manner: through an attention mechanism, the second vector representation, the first vector representation corresponding to each group of the second database query parameters, and the first query deterministic feature information corresponding to each group of the second database query parameters are aggregated to obtain the second query deterministic feature information, wherein the second vector representation is a vector representation generated according to the first database query parameters and the query plan information; wherein the second query performance potential feature information and the second query state potential feature information are obtained in the following manner: the first query potential feature information corresponding to each group of the second database query parameters is mean aggregated to obtain the second query potential feature information.
[0137] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 4, wherein the query feature information includes third query performance feature information and third query state feature information, the feature information includes deterministic feature information and potential feature information, the deterministic feature information is used to characterize the deterministic features in the sample data, and the potential feature information is used to characterize the potential features in the sample data; determining the query feature information based on the second query performance feature information and the second query state feature information includes: fusing information based on the second query performance deterministic feature information and the second query state deterministic feature information to determine the third query performance deterministic feature information and the third query state deterministic feature information; fusing information based on the second query performance potential feature information and the second query state potential feature information to determine the third query performance potential feature information and the third query state potential feature information.
[0138] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, which performs information fusion based on the second query performance deterministic characteristic information and the second query state deterministic characteristic information to determine the third query performance deterministic characteristic information and the third query state deterministic characteristic information, including: performing information fusion with one of the second query performance deterministic characteristic information and the second query state deterministic characteristic information as the first initial information and the other as the first supplementary information to obtain the third query deterministic characteristic information corresponding to the first initial information.
[0139] According to one or more embodiments of the present disclosure, Example 8 provides the method of Example 6, which performs information fusion based on the second query performance potential feature information and the second query state potential feature information to determine the third query performance potential feature information and the third query state potential feature information, including: sampling and processing the second query performance potential feature information and the second query state potential feature information to obtain a global latent variable, and the global latent variable is used to characterize the association between the query duration potential feature and the query state potential feature; using the second query performance potential feature information and the second query state potential feature information as the second initial information and the global latent variable as the second supplementary information to perform information fusion to obtain the third query potential feature information corresponding to the second initial information.
[0140] According to one or more embodiments of the present disclosure, Example 9 provides the method of Example 7 or Example 8, and performs information fusion in the following manner: adding the product of the first weight matrix and the supplementary information to the first bias item corresponding to the first weight matrix to obtain the first information, wherein the first weight matrix is the weight matrix corresponding to the deterministic feature information; adding the product of the second weight matrix and the supplementary information to the second bias item corresponding to the second weight matrix to obtain the second information, wherein the second weight matrix is the weight matrix corresponding to the potential feature information; adding the product of the first preset function value of the first information and the second preset function value of the second information to the initial information as the fused information.
[0141] According to one or more embodiments of the present disclosure, Example 10 provides the method of Example 1, and when the first query status information characterization can be successful, the method also includes: determining whether an iteration stop condition is met; in response to not meeting the iteration stop condition, updating the first database query parameter according to the first query execution result, and re-executing the step of determining the first query execution result according to the first database query parameter until the iteration stop condition is met.
[0142] According to one or more embodiments of the present disclosure, Example 11 provides the method of Example 1, wherein the first query execution result also includes a predicted first query performance parameter corresponding to the first database query operation; the updating of the first database query parameter according to the first query execution result includes: determining a loss value according to the first query execution result and a preset expectation function, and updating the first database query parameter according to the loss value, wherein the expectation function is a function of difference information, a first probability distribution, and a second probability distribution, the difference information is the difference between the optimal performance parameter and the first query performance parameter, the first probability distribution is the probability distribution that the first query state information representation can be successful when the query parameter is the first database query parameter, the second probability distribution is the probability distribution that the query performance parameter is the first query performance parameter when the query parameter is the first database query parameter and the first query state information representation can be successful, the optimal performance parameter is a preset value, or the optimal performance parameter is the optimal value of the first query performance parameters obtained in this iteration and previous iterations respectively.
[0143] According to one or more embodiments of the present disclosure, Example 12 provides a database query parameter optimization device, the device comprising: a first acquisition module, used to acquire a first database query parameter; a first determination module, used to determine a first query execution result based on the first database query parameter, the first query execution result comprising first query status information, the first query status information being used to characterize whether a prediction of whether the first database query operation can be successfully executed based on the first database query parameter and preset query plan information; an update module, used to update the first database query parameter according to the first query execution result when the first query status information indicates that it can be successful.
[0144] According to one or more embodiments of the present disclosure, Example 13 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any of the methods described in Examples 1-11 when executed by a processing device.
[0145] According to one or more embodiments of the present disclosure, Example 14 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-11.
[0146] According to one or more embodiments of the present disclosure, Example 15 provides a computer program product, including a computer program, which implements the steps of any one of the methods described in Examples 1 to 11 when executed by a processor.
[0147] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0148] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0149] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A method for optimizing database query parameters, characterized in that: The method comprises: Obtaining a first database query parameter; Determine a first query execution result according to the first database query parameter, the first query execution result including first query status information, the first query status information being used to indicate whether the first database query operation can be successfully executed according to the first database query parameter and the preset query plan information; When the first query state information indicates success, the first database query parameter is updated according to the first query execution result.
2. The method according to claim 1, characterized in that The method further comprises: Acquire sample data, wherein the sample data includes a second database query parameter, the query plan information, pre-marked second query state information, and a second query performance parameter, wherein the second query state information is used to indicate whether a second database query operation executed according to the second database query parameter and the query plan information is successful, and the second query performance parameter is a query performance parameter corresponding to the second database query operation; Determine query feature information by fusing the second query performance parameter and the second query state information; The determining the first query execution result according to the first database query parameter includes: The first query execution result is determined according to the query characteristic information and the first database query parameter.
3. The method according to claim 2, characterized in that The second database query parameter is M groups, M≥1; The step of fusing the second query performance parameter and the second query state information to determine the query feature information includes: For each group of the second database query parameters, feature extraction is performed based on the second query performance parameters corresponding to the group of the second database query parameters and the first vector representation corresponding to the group of the second database query parameters to obtain first query performance feature information corresponding to the group of the second database query parameters, and feature extraction is performed based on the second query state information corresponding to the group of the second database query parameters and the first vector representation corresponding to the group of the second database query parameters to obtain first query state feature information corresponding to the group of the second database query parameters, wherein the first vector representation corresponding to the group of the second database query parameters is a vector representation generated based on the query plan information and the group of the second database query parameters; The query characteristic information is determined according to the first query performance characteristic information respectively corresponding to each group of the second database query parameters and the first query state characteristic information respectively corresponding to each group of the second database query parameters.
4. The method according to claim 3, characterized in that The determining the query characteristic information according to the first query performance characteristic information respectively corresponding to each group of the second database query parameters and the first query state characteristic information respectively corresponding to each group of the second database query parameters includes: Performing an aggregation operation on the first query performance characteristic information respectively corresponding to each group of the second database query parameters to obtain second query performance characteristic information; Performing an aggregation operation on the first query state characteristic information respectively corresponding to each group of the second database query parameters to obtain second query state characteristic information; The query characteristic information is determined according to the second query performance characteristic information and the second query state characteristic information.
5. The method according to claim 4, characterized in that The feature information includes deterministic feature information and potential feature information, wherein the deterministic feature information is used to characterize the deterministic features in the sample data, and the potential feature information is used to characterize the potential features in the sample data; The second query performance deterministic characteristic information and the second query state deterministic characteristic information are obtained in the following manner: aggregating, by an attention mechanism, a second vector representation, the first vector representation corresponding to each group of the second database query parameters, and the first query deterministic feature information corresponding to each group of the second database query parameters to obtain second query deterministic feature information, wherein the second vector representation is a vector representation generated according to the first database query parameters and the query plan information; The second query performance potential feature information and the second query status potential feature information are obtained in the following manner: Mean aggregation is performed on the first query potential feature information corresponding to each group of the second database query parameters to obtain the second query potential feature information.
6. The method according to claim 4, characterized in that The query feature information includes third query performance feature information and third query state feature information, and the feature information includes deterministic feature information and potential feature information, the deterministic feature information is used to characterize the deterministic features in the sample data, and the potential feature information is used to characterize the potential features in the sample data; The determining the query characteristic information according to the second query performance characteristic information and the second query state characteristic information includes: Performing information fusion according to the second query performance deterministic characteristic information and the second query state deterministic characteristic information to determine third query performance deterministic characteristic information and third query state deterministic characteristic information; Information fusion is performed based on the second query performance potential feature information and the second query state potential feature information to determine the third query performance potential feature information and the third query state potential feature information.
7. The method according to claim 6, characterized in that The step of fusing the second query performance deterministic feature information and the second query state deterministic feature information to determine the third query performance deterministic feature information and the third query state deterministic feature information includes: Information fusion is performed using one of the second query performance deterministic characteristic information and the second query state deterministic characteristic information as the first initial information and the other as the first supplementary information to obtain third query deterministic characteristic information corresponding to the first initial information.
8. The method according to claim 6, characterized in that The step of fusing the second query performance potential feature information and the second query status potential feature information to determine the third query performance potential feature information and the third query status potential feature information includes: Sampling the second query performance potential feature information and the second query state potential feature information to obtain a global potential variable, where the global potential variable is used to characterize the association between the query duration potential feature and the query state potential feature; The second query performance potential feature information and the second query state potential feature information are respectively used as the second initial information, and the global potential variable is used as the second supplementary information to perform information fusion to obtain the third query potential feature information corresponding to the second initial information.
9. The method according to claim 7 or 8, characterized in that: Information fusion is performed in the following ways: Adding a first bias item corresponding to the first weight matrix to the product of the first weight matrix and the supplementary information to obtain first information, wherein the first weight matrix is a weight matrix corresponding to the deterministic feature information; The product of a second weight matrix and the supplementary information is added to a second bias item corresponding to the second weight matrix to obtain second information, wherein the second weight matrix is a weight matrix corresponding to the potential feature information; The product of the first preset function value of the first information and the second preset function value of the second information is added to the initial information to obtain the fused information.
10. The method according to claim 1, characterized in that In the case where the first query status information representation is successful, the method further includes: Determine whether the iteration stop condition is met; In response to the iteration stop condition not being met, the first database query parameter is updated according to the first query execution result, and the step of determining the first query execution result according to the first database query parameter is re-executed until the iteration stop condition is met.
11. The method according to claim 1, characterized in that: The first query execution result also includes a predicted first query performance parameter corresponding to the first database query operation; and updating the first database query parameter according to the first query execution result includes: According to the first query execution result and a preset expectation function, a loss value is determined, and the first database query parameter is updated according to the loss value, wherein the expectation function is a function of difference information, a first probability distribution, and a second probability distribution, the difference information is the difference between the optimal performance parameter and the first query performance parameter, the first probability distribution is the probability distribution that the first query status information representation can be successful when the query parameter is the first database query parameter, the second probability distribution is the probability distribution that the query performance parameter is the first query performance parameter when the query parameter is the first database query parameter and the first query status information representation can be successful, the optimal performance parameter is a preset value, or the optimal performance parameter is the optimal value of the first query performance parameters obtained in this iteration and previous iterations respectively.
12. A database query parameter optimization device, characterized in that: The device comprises: A first acquisition module, used to acquire a first database query parameter; A first determination module, configured to determine a first query execution result according to the first database query parameter, wherein the first query execution result includes first query status information, wherein the first query status information is used to indicate whether the first database query operation is predicted to be successful if it is executed according to the first database query parameter and preset query plan information; An updating module is used to update the first database query parameter according to the first query execution result when the first query state information indicates that the query is successful.
13. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method described in any one of claims 1 to 11 are implemented.
14. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 11.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.