Sample generation method and device, medium, equipment and program product
The training sample is generated by optimizing the algorithm of the particle cluster, and the database query parameters are updated to iterate, and the problem of insufficient training samples in the existing technologies has been solved, and the accuracy of the database parameter adjustment model is improved.
Patent Information
- Application Number
- CN202411596143.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-01-24
AI Technical Summary
In the prior art, when adjusting database parameters through machine learning, the model output results obtained by training are not accurate enough, mainly due to insufficient number and diversity of training samples.
Use particle group optimization algorithms to generate training samples, and to update the database query parameters until it meets the iterative stop conditions and generates enough and diverse training samples.
It improves the reliability of the database query parameter adjustment model and the accuracy of the output results, ensuring that the model is fully trained.
Smart Images

Figure CN119357240A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data query technology, and in particular, to a sample generation method, apparatus, medium, device and program 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 the process of using the database, in order to adapt the database to different usage scenarios and meet different usage requirements, the database parameters need to be adjusted. For example, there are millions of database instances on the cloud database, and the number of database parameters that need to be adjusted is large. Manual parameter adjustment is not only inefficient, but also inaccurate. At present, the database parameters can be adjusted by machine learning to replace manual adjustment of database parameters. The database parameters are adjusted by machine learning, that is, by training a database parameter adjustment model, and the database parameter adjustment model outputs the adjusted database parameters. However, the results output by the database parameter adjustment model trained in the related art may not be accurate enough. 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 sample generation method, the method comprising: Get M database query parameter groups, M≥1; For each of the database query parameter groups, a database query operation is performed according to preset query plan information and database query parameters currently included in the database query parameter group to obtain a query execution result corresponding to the database query parameter group; and a training sample corresponding to the database query parameter group is generated according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, and the training sample is used as a training sample of a database query parameter adjustment model; In response to not meeting the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, the database query parameters in each of the database query parameter groups are updated, and the database query operation is re-executed for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, a training sample corresponding to the database query parameter group is generated until the iteration stop condition is met.
[0006] In a second aspect, the present disclosure provides a sample generation device, the device comprising: An acquisition module is used to acquire M database query parameter groups, where M≥1; a generating module, configured to execute a database query operation for each of the database query parameter groups according to preset query plan information and the database query parameters currently included in the database query parameter group, and obtain a query execution result corresponding to the database query parameter group; and to generate a training sample corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group, and the database query parameters currently included in the database query parameter group, wherein the training sample is used as a training sample of a database query parameter adjustment model; An updating module is used to update the database query parameters in each of the database query parameter groups in response to failure to meet the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, and trigger the generation module to re-execute the database query operation for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and generate training samples corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group until the iteration stop condition is met.
[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 sample generation 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 sample generation 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 sample generation method provided in the first aspect of the present disclosure.
[0010] Through the above technical solution, for each database query parameter group, according to the preset query plan information and the database query parameters currently included in the database query parameter group, the database query operation is executed to obtain the corresponding query execution result, and according to the query plan information, the query execution result and the database query parameters, the training samples corresponding to the database query parameter group obtained in this iteration are generated. If the iteration stop condition is not met, the database query parameters are updated according to the query execution result, and the next iteration is performed until the iteration stop condition is met. In this way, for each database query parameter group, through iteration, multiple training samples corresponding to the database query parameter group can be generated, and in one iteration process, the database query operation can be executed in parallel according to the database query parameters respectively included in different database query parameter groups to obtain the query execution results respectively corresponding to each database query parameter group. In this way, the training samples respectively corresponding to each database query parameter group can be generated simultaneously in one iteration process, the sample generation efficiency is improved, and a sufficient number of training samples can be obtained. In addition, the database query parameters can be updated and optimized according to the query execution results. Since the database query parameters are continuously updated iteratively, it is possible to find database query parameters that make the query execution results better during the iteration process. Therefore, the obtained training samples cover the database query parameters corresponding to different query execution results, thereby improving the diversity of the training samples. The database query parameter adjustment model obtained by training the training samples can fully train the model, improve the reliability of the trained database query parameter adjustment model, and thus improve the accuracy of the results output by the database query parameter adjustment model.
[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 sample generating method according to an exemplary embodiment.
[0013] Figure 2 It is a flowchart showing a method for determining an optimal parameter group after the current iteration is completed according to a query duration corresponding to a first database query parameter group according to an exemplary embodiment.
[0014] Figure 3 The invention is a flowchart showing a method for updating database query parameters in a first database query parameter group according to an optimal parameter group according to an exemplary embodiment.
[0015] Figure 4 The invention is a flowchart showing a method for updating database query parameters in a first database query parameter group according to an optimal parameter group according to an exemplary embodiment.
[0016] Figure 5 It is a block diagram of a sample generating device according to an exemplary embodiment.
[0017] Figure 6 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0018] 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.
[0019] 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.
[0020] 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.
[0021] 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.
[0022] 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".
[0023] 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.
[0024] 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.
[0025] 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.
[0026] 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.
[0027] 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.
[0028] 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.
[0029] As described in the background technology, at present, the adjustment of database parameters is performed by machine learning, that is, by training a database parameter adjustment model, and the database parameter adjustment model outputs the adjusted database parameters. The training of the database parameter adjustment model depends on the number and diversity of training samples. If the number of training samples is insufficient, the model cannot be fully trained, which directly affects the reliability of the trained model, resulting in inaccurate results of the model output. Among them, in addition to the training samples required in the actual training stage of the model, in the initial stage of model training, training samples are also required to perform hot start of the model. Hot start refers to giving certain initial conditions to the model in advance so that the model is close to the actual state from the beginning. In machine learning, hot start is a learning rate preheating method, which can make the model more stable in the early stage of training and accelerate the convergence speed. In the related art, the acquisition of training samples generally comes from the historical usage parameters and historical performance data of the database. However, in order not to affect the normal use of the database, the database cannot update its parameters at any time during operation. Therefore, the training samples that can be obtained from the historical usage parameters of the database are limited, resulting in insufficient training samples for hot start and training of the database parameter adjustment model. In addition to directly using Bayesian optimization and deep reinforcement learning to generate training samples, related technologies can also use heuristic methods to solve sample problems, such as using genetic algorithms to select high-quality samples in the initial stage of the model. However, this type of algorithm is designed to adjust the system-level parameters of the database and only allows one system-level parameter to be evaluated at a time, and is not suitable for adjusting the query parameters of the database.
[0030] In view of this, the present disclosure generates training samples for training a database query parameter adjustment model based on a particle swarm optimization algorithm, wherein a group of database query parameters can be regarded as a particle, and the value range of the database query parameters can be regarded as a search space of the particle swarm. The particles can continuously move in the search space and approach the optimal solution by adjusting their own positions and speeds. The database query parameters can be effectively explored, so that training sample data can be collected. Different particles can be executed in parallel, which can improve the sample generation efficiency and provide enough training samples for the training of the database query parameter adjustment model, thereby improving the reliability of the trained database query parameter adjustment model.
[0031] The sample generation method provided by the present disclosure is introduced in detail below.
[0032] Figure 1 is a flow chart of a sample generation method according to an exemplary embodiment, which can be applied to electronic devices with processing capabilities, such as servers, personal computers, etc. Figure 1 As shown, the method may include steps 11 to 13.
[0033] In step 11, M database query parameter groups are obtained. M≥1.
[0034] Among them, the number of database query parameter groups can be one or more, the number of database query parameters included in the database query parameter group can be set according to the query plan, and can be one or more, and the number of database query parameters included in each database query parameter group can be the same or different.
[0035] For example, the initial database query parameter in the database query parameter group may be randomly generated within the value range of the original query parameter corresponding to the database query parameter, and the original query parameter may be, for example, a parameter actually used when the database is running. For example, database query parameter group 1 includes initial database query parameters X1 and X2, where X1 may be the value of the original query parameter. a 1 is a randomly generated parameter within the value range of X2, and X2 can be the original query parameter a 2. For example, database query parameter group 2 includes initial database query parameters X3 and X4, where X3 can be a random parameter in the original query parameter a 3 is a randomly generated parameter within the value range of X4, which can be the original query parameter a 4. It should be noted that the above examples of database query parameter group 1 and database query parameter group 2, the number of database query parameter groups in the examples, and the number of database query parameters in each database query parameter group are only for illustration and do not constitute a limitation on the embodiments of the present disclosure.
[0036] In step 12, for each database query parameter group, a database query operation is performed according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain a query execution result corresponding to the database query parameter group; and a training sample corresponding to the database query parameter group is generated according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group. The training sample is used as a training sample for the database query parameter adjustment model.
[0037] The preset query plan information may include query execution steps set to complete the query operation. The preset query plan information and the database query parameters currently included in the database query parameter group are sent to the database, the database query operation is performed, and the query execution result corresponding to the database query parameter group is obtained. Taking database query parameter group 1 as an example, the database query parameters X1 and X2 currently included in the database query parameter group 1 and the preset query plan information Q can be sent to the database, the database query operation is performed, and the query execution result corresponding to the database query parameter group 1 is obtained.
[0038] After obtaining the query execution result corresponding to the database query parameter group, a training sample corresponding to the database query parameter group obtained in this iteration can be generated. For example, the training sample is (Q, X i , R i ), where Q represents the preset query plan information, X i Indicates the database query parameters currently included in the database query parameter group. i Indicates the query execution result corresponding to the database query parameter group. In the present disclosure, when there are multiple database query parameter groups, in one iteration, database query operations can be executed in parallel according to the database query parameters respectively included in different database query parameter groups to obtain the query execution results respectively corresponding to each database query parameter group. In this way, training samples respectively corresponding to each database query parameter group can be generated in one iteration, thereby improving sample generation efficiency.
[0039] In step 13, in response to not meeting the iteration stop condition, the database query parameters in each database query parameter group are updated according to the query execution result corresponding to each database query parameter group. Then, step 12 is re-executed until the iteration stop condition is met.
[0040] Among them, failure to meet the iteration stop condition may indicate that the number of training samples currently generated is insufficient. By way of example, the iteration stop condition may include that the number of generated training samples meets a set threshold. For example, when the number of database query parameter groups is one, the iteration stop condition may include that the number of training samples corresponding to the generated database query parameter group is greater than a first quantity threshold. When the number of database query parameter groups is multiple, the iteration stop condition may include that the number of training samples corresponding to each generated database query parameter group is greater than a second quantity threshold, or the sum of the number of training samples corresponding to each database query parameter group is greater than a third quantity threshold. By way of another example, the iteration stop condition may also be that the number of iterations is greater than a preset number threshold.
[0041] If the iteration stop condition is not met, the database query parameters in each database query parameter group may be updated according to the query execution result corresponding to each database query parameter group. After the database query parameters are updated, the database query parameter group currently includes the updated database query parameters, and then step 12 may be repeated until the iteration stop condition is met. When the iteration stop condition is met, the final training sample may be obtained.
[0042] Through the above technical solution, for each database query parameter group, according to the preset query plan information and the database query parameters currently included in the database query parameter group, the database query operation is executed to obtain the corresponding query execution result, and according to the query plan information, the query execution result and the database query parameters, the training samples corresponding to the database query parameter group obtained in this iteration are generated. If the iteration stop condition is not met, the database query parameters are updated according to the query execution result, and the next iteration is performed until the iteration stop condition is met. In this way, for each database query parameter group, through iteration, multiple training samples corresponding to the database query parameter group can be generated, and in one iteration process, the database query operation can be executed in parallel according to the database query parameters respectively included in different database query parameter groups to obtain the query execution results respectively corresponding to each database query parameter group. In this way, the training samples respectively corresponding to each database query parameter group can be generated simultaneously in one iteration process, the sample generation efficiency is improved, and a sufficient number of training samples can be obtained. In addition, the database query parameters can be updated and optimized according to the query execution results. Since the database query parameters are continuously updated iteratively, it is possible to find database query parameters that make the query execution results better during the iteration process. Therefore, the obtained training samples cover the database query parameters corresponding to different query execution results, thereby improving the diversity of the training samples. The database query parameter adjustment model obtained by training the training samples can fully train the model, improve the reliability of the trained database query parameter adjustment model, and thus improve the accuracy of the results output by the database query parameter adjustment model.
[0043] In one embodiment, the query execution result may include query duration and query status information used to indicate whether the query is successful. The query duration is the time taken to execute the database query operation according to the preset query plan information and the database query parameters currently included in the database query parameter group, and the query status information indicates whether the database query operation is successful. Accordingly, in step 13, the database query parameters in each database query parameter group are updated according to the query execution result corresponding to each database query parameter group, which may include: If the first database query parameter group exists, the optimal parameter group after the current iteration is determined according to the query duration corresponding to the first database query parameter group, and the database query parameters in the first database query parameter group are updated according to the optimal parameter group.
[0044] Among them, the first database query parameter group is a database query parameter group whose corresponding query status information in the M database query parameter groups represents a successful query. Since the query duration can reflect the performance of the database, the shorter the query duration is, the better the database performance is. Therefore, the optimal parameter group can be determined according to the query duration corresponding to the first database query parameter group, and the database query parameters can be updated according to the optimal parameter group, so that the database query parameters that make the query execution result better can be found. The training samples generated in this way can cover the database query parameters corresponding to different query execution results, thereby improving the diversity of the training samples.
[0045] For example, if the number of database query parameter groups is one and the database query parameter group is successfully queried in this iteration, the database query parameter group is used as the first database query parameter group. The optimal parameter group after the completion of this iteration can be determined according to the query duration corresponding to the first database query parameter group. The optimal parameter group can be the database query parameter group corresponding to the shortest query duration, and the shortest query duration can be the shortest duration of the query durations of the corresponding query status information obtained in this iteration and previous iterations that indicate successful queries. If the database query parameter group is unsuccessful in this iteration, the optimal parameter group after the previous iteration can continue to be used as the optimal parameter group after the completion of this iteration.
[0046] Taking database query parameter group 1 as an example, the first iteration query is successful, and the query time is L1. Then, the database query parameters X1 and X2 included in the database query parameter group 1 are updated. The updated database query parameter group 1 currently includes database query parameters X1´ and X2´. Then, the second iteration is performed. The second iteration query is successful, and the query time is L1´. If L1´ is less than L1, then the optimal parameter group after the second iteration is the parameter group including X1´ and X2´. If L1 is less than L1´, then the optimal parameter group after the second iteration is the parameter group including X1´ and X2´.
[0047] For example, the number of database query parameter groups is multiple, and the number of first database query parameter groups whose query status information corresponding to this iteration represents a successful query may be one or more. If the number of first database query parameter groups is one, the optimal parameter group after the completion of this iteration may be determined based on the query duration corresponding to the first database query parameter group. If the number of first database query parameter groups is multiple, the optimal parameter group after the completion of this iteration may be determined based on the query durations respectively corresponding to the multiple first database query parameter groups. Wherein, in the case where the number of database query parameter groups is multiple, the optimal parameter group may include a global optimal parameter group and a local optimal parameter group corresponding to each first database query parameter group. Accordingly, the implementation method for determining the optimal parameter group after the completion of this iteration based on the query duration corresponding to the first database query parameter group may be as follows: Figure 2 As shown, the process includes step 21 and step 22.
[0048] In step 21, the first minimum query duration is determined from the query duration corresponding to each first database query parameter group and the query duration corresponding to the global optimal parameter group determined after the previous iteration is completed, and the parameter group corresponding to the first minimum query duration is determined as the global optimal parameter group after the completion of this iteration.
[0049] In step 22, for each first database query parameter group, the second minimum query duration is determined from the query duration corresponding to the first database query parameter group and the query duration corresponding to the local optimal parameter group corresponding to the first database query parameter group determined after the previous iteration is completed, and the parameter group corresponding to the second minimum query duration is determined as the local optimal parameter group corresponding to the first database query parameter group after the completion of this iteration.
[0050] Among them, since the shorter the query time is, the better the database performance is, the parameter group corresponding to the first minimum query time can be determined as the global optimal parameter group after the completion of this iteration. For the first database query parameter, the parameter group corresponding to the second minimum query time can currently optimize the database performance, and the parameter group corresponding to the second minimum query time can be determined as the local optimal parameter group corresponding to the first database query parameter group after the completion of this iteration.
[0051] Using the above example of database query parameter group, for example, in addition to database query parameter group 1 and database query parameter group 2, database query parameter group 3 is also included, and database query parameter group 3 includes initial database query parameters X5 and X6, where X5 can be the original query parameter a 5 is a randomly generated parameter within the value range of 5. X6 can be a parameter in the original query. a Randomly generated parameters within the range of 6.
[0052] As an example, during the first iteration, the query status information corresponding to database query parameter group 1 indicates that the query is successful, and the query duration is L1, the query status information corresponding to database query parameter group 2 indicates that the query is successful, and the query duration is L2, and the query status information corresponding to database query parameter group 3 indicates that the query is successful, and the query duration is L3, and the first database query parameter group whose query status information indicates that the query is successful includes database query parameter group 1, database query parameter group 2, and database query parameter group 3. For example, the query duration corresponding to the global optimal parameter group determined after the previous iteration corresponding to the first iteration is pre-set to 0, and if L2 is the smallest among L1, L2, and L3, then the global optimal parameter group completed in the first iteration is the parameter group including database query parameters X3 and X4. For example, the query duration corresponding to the local optimal parameter group determined after the previous iteration corresponding to the first iteration is pre-set to 0, then the local optimal parameter group corresponding to database query parameter group 1 is the parameter group including database query parameters X1 and X2, the local optimal parameter group corresponding to database query parameter group 2 is the parameter group including database query parameters X3 and X4, and the local optimal parameter group corresponding to database query parameter group 3 is the parameter group including database query parameters X5 and X6.
[0053] After determining the local optimal parameter groups corresponding to the global optimal parameter group and each first database query parameter group, if it is determined that the iteration stop condition is not satisfied, the database query parameters included in each first database query parameter group can be updated respectively. For example, according to the local optimal parameter group corresponding to the global optimal parameter group and database parameter group 1, X1 is updated to obtain X1´, X2 is updated to obtain X2´, according to the local optimal parameter group corresponding to the global optimal parameter group and database parameter group 2, X3 is updated to obtain X3´, X4 is updated to obtain X4´, according to the local optimal parameter group corresponding to the global optimal parameter group and database parameter group 3, X5 is updated to obtain X5´, and X6 is updated to obtain X6´. In this way, the updated database query parameter group 1 currently includes database query parameters X1´ and X2´, the updated database query parameter group 2 currently includes database query parameters X3´ and X4´, and the updated database query parameter group 3 currently includes database query parameters X5´ and X6´.
[0054] Then the next round of iteration is performed. During the second iteration, for example, the query status information corresponding to database query parameter group 1 indicates that the query is successful and the query duration is L1´, the query status information corresponding to database query parameter group 2 indicates that the query is successful and the query duration is L2´, and the query status information corresponding to database query parameter group 3 indicates that the query fails. The first database query parameter group whose query status information indicates that the query is successful includes database query parameter group 1 and database query parameter group 2. If L1´ is the smallest among L1´, L2´, and L2, the global optimal parameter group after the second iteration is completed is the parameter group including database query parameters X1´ and X2´. If L2 is the smallest among L1´, L2´, and L2, the global optimal parameter group determined after the previous iteration is completed continues to be used as the global optimal parameter group after the current iteration is completed, that is, the global optimal parameter group after the second iteration is completed is the parameter group including database query parameters X3 and X4.
[0055] For database query parameter group 1, if L1´ is less than L1, then after the second iteration, the local optimal parameter group corresponding to database query parameter group 1 is the parameter group including database query parameters X1´ and X2´; if L1 is less than L1´, then the local optimal parameter group corresponding to database query parameter group 1 remains unchanged, and after the second iteration, the local optimal parameter group corresponding to database query parameter group 1 is the parameter group including database query parameters X1 and X2. The local optimal parameter group of database query parameter group 2 is similar. For database query parameter group 3, since this iteration query fails, the local optimal parameter group corresponding to database query parameter group 3 obtained after the previous iteration is continued to be used as the local optimal parameter group corresponding to database query parameter group 3 after this iteration.
[0056] Through the above technical scheme, the optimal parameter group may include a global optimal parameter group and a local optimal parameter group corresponding to each first database query parameter group. According to the global optimal parameter group and the local optimal parameter group corresponding to the first database query parameter, the database query parameters in the first database query parameter group are updated, so that the updated database query parameters can be close to both the global optimum and the local optimum at the same time, thereby realizing the search for database query parameters that make the query execution results better. Therefore, the generated training samples can cover database query parameters corresponding to different query execution results, thereby improving the diversity of training samples.
[0057] Figure 3 is a flowchart showing a method for updating database query parameters in a first database query parameter group according to an optimal parameter group according to an exemplary embodiment. Figure 3 As shown, the method may include steps 31 to 33.
[0058] In step 31 , the distance between the database query parameters in the optimal parameter group and the database query parameters in the first database query parameter group is determined.
[0059] In step 32, the parameter update step length corresponding to the first database query parameter group after the current iteration is completed is determined according to the distance and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed.
[0060] For example, there are multiple database query parameter groups, and the optimal parameter group may include a global optimal parameter group and a local optimal parameter group corresponding to each first database query parameter group. Figure 4 As shown, the implementation of step 31 may include step 311 and step 312 , and the implementation of step 32 may be step 321 .
[0061] In step 311 , a first distance between the database query parameters in the global optimal parameter group and the database query parameters in the first database query parameter group is determined.
[0062] In step 312, a second distance between the database query parameters in the local optimal parameter group corresponding to the first database query parameter group and the database query parameters in the first database query parameter group is determined.
[0063] For example, after the second iteration is completed, the global optimal parameter group is a parameter group including database query parameters X3 and X4, and the local optimal parameter group corresponding to database query parameter group 1 is a parameter group including database query parameters X1 and X2. Then, for database query parameter group 1, a first distance between X3 and X4 included in the global optimal parameter group and X1´ and X2´ currently included in database query parameter group 1 can be determined, and a second distance between X1 and X2 included in the local optimal parameter group and X1´ and X2´ currently included in database query parameter group 1 can be determined. The first distance and the second distance are, for example, Euclidean distances.
[0064] In step 321, the parameter update step length corresponding to the first database query parameter group after the current iteration is completed is determined according to the first distance, the second distance and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed.
[0065] For example, for each database query parameter group, an initial parameter update step corresponding to the database query parameter group may be generated in advance, for example, the initial parameter update step may be randomly generated in a search space corresponding to the database query parameter group, the search space being a set of value ranges corresponding to each database query parameter in the database query parameter group. During the first iteration, the initial parameter update step may be used as the parameter update step corresponding to the database query parameter group determined after the previous iteration is completed.
[0066] The implementation method of step 321 may be: Generate a first random number and a second random number within a first value range; Determine the product of the parameter update step corresponding to the first database query parameter group determined after the last iteration and the inertia weight as the first information; determining the product of the first distance, the first random number and the first acceleration constant as second information; determining the product of the second distance, the second random number and the second acceleration constant as third information; The sum of the first information, the second information and the third information is determined as the parameter update step corresponding to the first database query parameter group after the iteration is completed.
[0067] The first value range may be [0, 1]. For example, the parameter update step corresponding to the first database query parameter group after the iteration is completed is determined by the following formula: V i ´= μ·V i + c 1. rand 1()·( PBest i - X i )+ c 2. rand 2()·( GBest - X i ) in, V i ' represents the parameter update step size corresponding to the first database query parameter group after the iteration is completed. V i represents the parameter update step corresponding to the first database query parameter group determined after the last iteration is completed, μ represents the inertia weight, c 1 represents the first acceleration constant, c 2 represents the second acceleration constant, rand 1() represents the first random number, rand2() represents the second random number, X i represents the database query parameters currently included in the first database query parameter group, PBest i represents the database query parameters in the local optimal parameter group corresponding to the first database query parameter group after the current iteration is completed, GBest Represents the database query parameters in the global optimal parameter group after this iteration is completed. PBest i - X i represents the first distance, GBest - X i Indicates the second distance. Wherein, for different database query parameter groups, the preset inertia weights may be the same or different, the preset first acceleration constants may be the same or different, and the preset second acceleration constants may be the same or different.
[0068] For example, the number of database query parameter groups is one. Taking database query parameter group 1 as an example, if the second iteration query is successful, and the optimal parameter group after the second iteration is completed is a parameter group including X1 and X2, then the distance between X1 and X2 included in the optimal parameter group and X1´ and X2´ currently included in database query parameter group 1 can be determined, and the distance can be, for example, the Euclidean distance. The method for determining the parameter update step corresponding to database query parameter group 1 can be to generate a third random number within the first value range, determine the product of the distance, the third random number and the third acceleration constant as fourth information, determine the product of the parameter update step corresponding to database query parameter group 1 determined after the previous iteration is completed and the inertia weight as fifth information, and use the sum of the fourth information and the fifth information as the parameter update step corresponding to database query parameter group 1 after the completion of this iteration.
[0069] In step 33, the database query parameters in the first database query parameter group are updated according to the parameter update step corresponding to the first database query parameter group after the current iteration is completed.
[0070] Among them, for each database query parameter in the first database query parameter group, determine the sum of the database query parameter and the parameter update step corresponding to the first database query parameter group after the current iteration is completed; if the sum is greater than the upper limit of the value range corresponding to the database query parameter, the upper limit is used as the updated database query parameter of the first database query parameter group; if the sum is less than the lower limit of the value range corresponding to the database query parameter, the lower limit is used as the updated database query parameter of the first database query parameter group; if the sum does not exceed the value range corresponding to the database query parameter, the sum is used as the updated database query parameter of the first database query parameter group.
[0071] Among them, if the parameter update step is a positive number, the sum value is greater than the database query parameters currently included in the first database query parameter group, and if the parameter update step is a negative number, the sum value is less than the database query parameters currently included in the first database query parameter group. When updating the database query parameters, considering the value range can avoid the situation where the updated parameters exceed the value range and cause the parameters to be invalid. In addition, the database query parameters are updated according to the parameter update step, so that the updated database query parameters have a certain distance from the database query parameters in the previous iteration process, thereby improving the diversity of the database query parameters.
[0072] Through the above technical solution, the parameter group corresponding to the first minimum query duration is determined as the global optimal parameter group, and the parameter group corresponding to the second minimum query duration is determined as the local optimal parameter group corresponding to the first database query parameter group. The first distance can reflect the difference between the database query parameters in the global optimal parameter group and the database query parameters currently included in the first database query parameter group, and the second distance can reflect the difference between the database query parameters in the local optimal parameter group and the database query parameters currently included in the first database query parameter group. The database query parameters are updated according to the first distance and the second distance, so that the updated database query parameters can be close to the global optimum and the local optimum at the same time. In this way, the training samples obtained in the initial stage may not be the samples that make the database performance optimal. As the iterative process proceeds, the database query parameters are continuously updated and optimized, and the training samples obtained subsequently make the database performance more optimized, so as to find the database query parameters that make the query execution results better. Therefore, the generated training samples can cover the database query parameters corresponding to different query execution results, thereby improving the diversity of training samples.
[0073] The above details the process of updating the database query parameters in the database query parameter group when the query status information indicates that the query is successful. If the query status information indicates that the query fails, a random number can be generated to update the database query parameters. In the present disclosure, in step 13, the database query parameters in each database query parameter group are updated according to the query execution result corresponding to each database query parameter group, and also include: If there is a second database query parameter group, a third random number is generated within the value range corresponding to each database query parameter in the second database query parameter group, and the generated third random number is used as the updated database query parameter of the second database query parameter group, wherein the second database query parameter group is the database query parameter group in which the corresponding query status information among the M database query parameter groups represents a failed query.
[0074] For example, during the second iteration, the query status information corresponding to database query parameter group 3 indicates query failure, then a random number X5´´ can be generated within the value range corresponding to X5´, and a random number X6´´ can be generated within the value range corresponding to X6´. The updated database query parameter group 3 currently includes database query parameters X5´´ and X6´´.
[0075] Through the above technical solution, for each database query parameter group, multiple training samples corresponding to the database query parameters can be generated through iteration, and a sufficient number of training samples can be obtained. Since the database query parameters are continuously iteratively updated, it is possible to find database query parameters that reduce the query time during the iteration process, so the obtained training samples cover different database query parameters, thereby improving the diversity of training samples. The database parameter adjustment model obtained by training according to the generated training samples is suitable for adjusting the query parameters of the database, so that the model can be fully trained and the reliability of the trained query parameter adjustment model can be improved.
[0076] It should be noted that the above embodiment takes two iterative processes as an example, which 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 number of iterations.
[0077] Based on the same inventive concept, the present disclosure also provides a sample generating device, Figure 5 is a block diagram of a sample generating device according to an exemplary embodiment. Figure 5 As shown, the device 50 may include: An acquisition module 51 is used to acquire M database query parameter groups, where M≥1; A generating module 52 is used to execute a database query operation for each of the database query parameter groups according to preset query plan information and the database query parameters currently included in the database query parameter group, and obtain a query execution result corresponding to the database query parameter group; and to generate a training sample corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group, and the database query parameters currently included in the database query parameter group, wherein the training sample is used as a training sample of a database query parameter adjustment model; The updating module 53 is used to update the database query parameters in each of the database query parameter groups in response to the failure to meet the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, and trigger the generating module 52 to re-execute the database query operation for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and generate training samples corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group until the iteration stop condition is met.
[0078] Optionally, the query execution result includes query duration and query status information used to indicate whether the query is successful; the updating module 53 includes: The first updating submodule is used to determine the optimal parameter group after the current iteration is completed according to the query duration corresponding to the first database query parameter group if there is a first database query parameter group, and update the database query parameters in the first database query parameter group according to the optimal parameter group, wherein the first database query parameter group is a database query parameter group corresponding to the query status information among the M database query parameter groups, and the query is successful.
[0079] Optionally, the optimal parameter group includes a global optimal parameter group and a local optimal parameter group corresponding to each of the first database query parameter groups; The first updating submodule includes: A first determination submodule, configured to determine a first minimum query duration from the query duration corresponding to each of the first database query parameter groups and the query duration corresponding to the global optimal parameter group determined after the previous iteration is completed, and determine the parameter group corresponding to the first minimum query duration as the global optimal parameter group after the current iteration is completed; The second determination submodule is used to determine, for each of the first database query parameter groups, a second minimum query duration from the query duration corresponding to the first database query parameter group and the query duration corresponding to the local optimal parameter group corresponding to the first database query parameter group determined after the previous iteration is completed, and determine the parameter group corresponding to the second minimum query duration as the local optimal parameter group corresponding to the first database query parameter group after the current iteration is completed.
[0080] Optionally, the first updating submodule includes: A third determination submodule, configured to determine a distance between the database query parameter in the optimal parameter group and the database query parameter in the first database query parameter group; A fourth determination submodule, configured to determine a parameter update step length corresponding to the first database query parameter group after the current iteration is completed according to the distance and a parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed; The second updating submodule is configured to update the database query parameters in the first database query parameter group according to the parameter update step corresponding to the first database query parameter group after the current iteration is completed.
[0081] Optionally, the optimal parameter group includes a global optimal parameter group and a local optimal parameter group corresponding to each of the first database query parameter groups; The third determining submodule includes: a fifth determining submodule, configured to determine a first distance between the database query parameter in the global optimal parameter group and the database query parameter in the first database query parameter group; a sixth determining submodule, configured to determine a second distance between the database query parameter in the local optimal parameter group corresponding to the first database query parameter group and the database query parameter in the first database query parameter group; The fourth determining submodule includes: The seventh determination submodule is used to determine the parameter update step size corresponding to the first database query parameter group after the current iteration is completed according to the first distance, the second distance and the parameter update step size corresponding to the first database query parameter group determined after the previous iteration is completed.
[0082] Optionally, the seventh determining submodule includes: A generating submodule, used for generating a first random number and a second random number within a first value range; A first information determination submodule, configured to determine the product of the parameter update step corresponding to the first database query parameter group determined after the last iteration and the inertia weight as the first information; a second information determination submodule, configured to determine the product of the first distance, the first random number and a first acceleration constant as second information; a third information determination submodule, configured to determine the product of the second distance, the second random number and a second acceleration constant as third information; The step size determination submodule is used to determine the sum of the first information, the second information and the third information as the parameter update step size corresponding to the first database query parameter group after the current iteration is completed.
[0083] Optionally, the second updating submodule is used to: For each of the database query parameters in the first database query parameter group, determine the sum of the database query parameter and the parameter update step corresponding to the first database query parameter group after the current iteration is completed; if the sum is greater than the upper limit of the value range corresponding to the database query parameter, use the upper limit as the updated database query parameter of the first database query parameter group; if the sum is less than the lower limit of the value range corresponding to the database query parameter, use the lower limit as the updated database query parameter of the first database query parameter group; if the sum does not exceed the value range corresponding to the database query parameter, use the sum as the updated database query parameter of the first database query parameter group.
[0084] Optionally, the first updating submodule further includes: A third updating submodule is configured to generate a third random number within a value range corresponding to each of the database query parameters in the second database query parameter group if there is a second database query parameter group, and use the generated third random number as the updated database query parameter of the second database query parameter group, wherein the second database query parameter group is a database query parameter group corresponding to the query status information representing a query failure among the M database query parameter groups.
[0085] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure. Figure 6As 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.
[0086] 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 6 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.
[0087] 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.
[0088] 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.
[0089] In some embodiments, the electronic devices 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.
[0090] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0091] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains M database query parameter groups, where M≥1; For each of the database query parameter groups, a database query operation is performed according to preset query plan information and database query parameters currently included in the database query parameter group to obtain a query execution result corresponding to the database query parameter group; and a training sample corresponding to the database query parameter group is generated according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, and the training sample is used as a training sample of a database query parameter adjustment model; In response to not meeting the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, the database query parameters in each of the database query parameter groups are updated, and the database query operation is re-executed for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, a training sample corresponding to the database query parameter group is generated until the iteration stop condition is met.
[0092] 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).
[0093] 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.
[0094] 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, an acquisition module may also be described as a "module for acquiring a database query parameter group".
[0095] 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.
[0096] 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.
[0097] According to one or more embodiments of the present disclosure, Example 1 provides a sample generation method, the method comprising: Get M database query parameter groups, M≥1; For each of the database query parameter groups, a database query operation is performed according to preset query plan information and database query parameters currently included in the database query parameter group to obtain a query execution result corresponding to the database query parameter group; and a training sample corresponding to the database query parameter group is generated according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, and the training sample is used as a training sample of a database query parameter adjustment model; In response to not meeting the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, the database query parameters in each of the database query parameter groups are updated, and the database query operation is re-executed for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, a training sample corresponding to the database query parameter group is generated until the iteration stop condition is met.
[0098] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the query execution result includes query duration and query status information used to characterize whether the query is successful; and updating the database query parameters in each database query parameter group according to the query execution result corresponding to each database query parameter group includes: If there is a first database query parameter group, the optimal parameter group after the iteration is completed is determined according to the query duration corresponding to the first database query parameter group, and the database query parameters in the first database query parameter group are updated according to the optimal parameter group, wherein the first database query parameter group is a database query parameter group corresponding to the query status information among the M database query parameter groups, indicating that the query is successful.
[0099] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein the optimal parameter group includes a global optimal parameter group and a local optimal parameter group corresponding to each of the first database query parameter groups; The determining, according to the query duration corresponding to the first database query parameter group, the optimal parameter group after the current iteration is completed, includes: Determine a first minimum query duration from the query duration corresponding to each of the first database query parameter groups and the query duration corresponding to the global optimal parameter group determined after the previous iteration is completed, and determine the parameter group corresponding to the first minimum query duration as the global optimal parameter group after the current iteration is completed; For each of the first database query parameter groups, a second minimum query duration is determined from the query duration corresponding to the first database query parameter group and the query duration corresponding to the local optimal parameter group corresponding to the first database query parameter group determined after the previous iteration is completed, and the parameter group corresponding to the second minimum query duration is determined as the local optimal parameter group corresponding to the first database query parameter group after the completion of this iteration.
[0100] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 2, wherein updating the database query parameters in the first database query parameter group according to the optimal parameter group includes: determining a distance between the database query parameter in the optimal parameter group and the database query parameter in the first database query parameter group; Determine, according to the distance and the parameter update step corresponding to the first database query parameter group determined after the previous iteration, the parameter update step corresponding to the first database query parameter group after the current iteration; The database query parameters in the first database query parameter group are updated according to the parameter update step corresponding to the first database query parameter group after the current iteration is completed.
[0101] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 4, wherein the optimal parameter group includes a global optimal parameter group and a local optimal parameter group corresponding to each of the first database query parameter groups; The determining the distance between the database query parameter in the optimal parameter group and the database query parameter in the first database query parameter group comprises: determining a first distance between the database query parameter in the global optimal parameter group and the database query parameter in the first database query parameter group; determining a second distance between the database query parameter in the local optimal parameter group corresponding to the first database query parameter group and the database query parameter in the first database query parameter group; Determining the parameter update step length corresponding to the first database query parameter group after the current iteration is completed according to the distance and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed includes: The parameter update step length corresponding to the first database query parameter group after the current iteration is completed is determined according to the first distance, the second distance, and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed.
[0102] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 5, wherein determining the parameter update step size corresponding to the first database query parameter group after the current iteration is completed according to the first distance, the second distance, and the parameter update step size corresponding to the first database query parameter group determined after the previous iteration is completed includes: Generate a first random number and a second random number within a first value range; Determine the product of the parameter update step corresponding to the first database query parameter group determined after the last iteration and the inertia weight as the first information; determining a product of the first distance, the first random number and a first acceleration constant as second information; determining a product of the second distance, the second random number and a second acceleration constant as third information; The sum of the first information, the second information and the third information is determined as the parameter update step corresponding to the first database query parameter group after the current iteration is completed.
[0103] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 4, wherein updating the database query parameters in the first database query parameter group according to the parameter update step corresponding to the first database query parameter group after the current iteration is completed includes: For each of the database query parameters in the first database query parameter group, determine the sum of the database query parameter and the parameter update step corresponding to the first database query parameter group after the current iteration is completed; if the sum is greater than the upper limit of the value range corresponding to the database query parameter, use the upper limit as the updated database query parameter of the first database query parameter group; if the sum is less than the lower limit of the value range corresponding to the database query parameter, use the lower limit as the updated database query parameter of the first database query parameter group; if the sum does not exceed the value range corresponding to the database query parameter, use the sum as the updated database query parameter of the first database query parameter group.
[0104] According to one or more embodiments of the present disclosure, Example 8 provides the method of Example 2, wherein updating the database query parameters in each of the database query parameter groups according to the query execution result corresponding to each of the database query parameter groups further includes: If there is a second database query parameter group, a third random number is generated within the value range corresponding to each database query parameter in the second database query parameter group, and the generated third random number is used as the updated database query parameter of the second database query parameter group, wherein the second database query parameter group is the database query parameter group corresponding to the query status information representing the query failure among the M database query parameter groups.
[0105] According to one or more embodiments of the present disclosure, Example 9 provides a sample generating device, the device comprising: An acquisition module is used to acquire M database query parameter groups, where M≥1; a generating module, configured to execute a database query operation for each of the database query parameter groups according to preset query plan information and the database query parameters currently included in the database query parameter group, and obtain a query execution result corresponding to the database query parameter group; and to generate a training sample corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group, and the database query parameters currently included in the database query parameter group, wherein the training sample is used as a training sample of a database query parameter adjustment model; An updating module is used to update the database query parameters in each of the database query parameter groups in response to failure to meet the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, and trigger the generation module to re-execute the database query operation for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and generate training samples corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group until the iteration stop condition is met.
[0106] According to one or more embodiments of the present disclosure, Example 10 provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processing device, the steps of the method described in any one of Examples 1-8 are performed.
[0107] According to one or more embodiments of the present disclosure, Example 11 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 any one of the methods described in Examples 1-8.
[0108] According to one or more embodiments of the present disclosure, Example 12 provides a computer program product, including a computer program, which implements the steps of any one of the methods of Examples 1-8 when executed by a processor.
[0109] 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.
[0110] 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.
[0111] 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 sample generation method, characterized in that: The method comprises: Get M database query parameter groups, M≥1; For each of the database query parameter groups, a database query operation is performed according to preset query plan information and database query parameters currently included in the database query parameter group to obtain a query execution result corresponding to the database query parameter group; and a training sample corresponding to the database query parameter group is generated according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, and the training sample is used as a training sample of a database query parameter adjustment model; In response to not meeting the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, the database query parameters in each of the database query parameter groups are updated, and the database query operation is re-executed for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group, a training sample corresponding to the database query parameter group is generated until the iteration stop condition is met.
2. The method according to claim 1, characterized in that The query execution result includes query duration and query status information used to indicate whether the query is successful; and updating the database query parameters in each database query parameter group according to the query execution result corresponding to each database query parameter group includes: If there is a first database query parameter group, the optimal parameter group after the iteration is completed is determined according to the query duration corresponding to the first database query parameter group, and the database query parameters in the first database query parameter group are updated according to the optimal parameter group, wherein the first database query parameter group is a database query parameter group corresponding to the query status information among the M database query parameter groups, indicating that the query is successful.
3. The method according to claim 2, characterized in that The optimal parameter group includes a global optimal parameter group and a local optimal parameter group corresponding to each of the first database query parameter groups; The determining, according to the query duration corresponding to the first database query parameter group, the optimal parameter group after the current iteration is completed, includes: Determine a first minimum query duration from the query duration corresponding to each of the first database query parameter groups and the query duration corresponding to the global optimal parameter group determined after the previous iteration is completed, and determine the parameter group corresponding to the first minimum query duration as the global optimal parameter group after the current iteration is completed; For each of the first database query parameter groups, a second minimum query duration is determined from the query duration corresponding to the first database query parameter group and the query duration corresponding to the local optimal parameter group corresponding to the first database query parameter group determined after the previous iteration is completed, and the parameter group corresponding to the second minimum query duration is determined as the local optimal parameter group corresponding to the first database query parameter group after the completion of this iteration.
4. The method according to claim 2, characterized in that: The updating of the database query parameters in the first database query parameter group according to the optimal parameter group includes: determining a distance between the database query parameter in the optimal parameter group and the database query parameter in the first database query parameter group; Determine, according to the distance and the parameter update step corresponding to the first database query parameter group determined after the previous iteration, the parameter update step corresponding to the first database query parameter group after the current iteration; The database query parameters in the first database query parameter group are updated according to the parameter update step corresponding to the first database query parameter group after the current iteration is completed.
5. The method according to claim 4, characterized in that The optimal parameter group includes a global optimal parameter group and a local optimal parameter group corresponding to each of the first database query parameter groups; The determining the distance between the database query parameter in the optimal parameter group and the database query parameter in the first database query parameter group comprises: determining a first distance between the database query parameter in the global optimal parameter group and the database query parameter in the first database query parameter group; determining a second distance between the database query parameter in the local optimal parameter group corresponding to the first database query parameter group and the database query parameter in the first database query parameter group; Determining the parameter update step length corresponding to the first database query parameter group after the current iteration is completed according to the distance and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed includes: The parameter update step length corresponding to the first database query parameter group after the current iteration is completed is determined according to the first distance, the second distance, and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed.
6. The method according to claim 5, characterized in that Determining the parameter update step length corresponding to the first database query parameter group after the current iteration is completed according to the first distance, the second distance, and the parameter update step length corresponding to the first database query parameter group determined after the previous iteration is completed includes: Generate a first random number and a second random number within a first value range; Determine the product of the parameter update step corresponding to the first database query parameter group determined after the last iteration and the inertia weight as the first information; determining a product of the first distance, the first random number and a first acceleration constant as second information; determining a product of the second distance, the second random number and a second acceleration constant as third information; The sum of the first information, the second information and the third information is determined as the parameter update step corresponding to the first database query parameter group after the current iteration is completed.
7. The method according to claim 4, characterized in that The updating of the database query parameters in the first database query parameter group according to the parameter update step corresponding to the first database query parameter group after the current iteration is completed includes: For each of the database query parameters in the first database query parameter group, determine the sum of the database query parameter and the parameter update step corresponding to the first database query parameter group after the current iteration is completed; if the sum is greater than the upper limit of the value range corresponding to the database query parameter, use the upper limit as the updated database query parameter of the first database query parameter group; if the sum is less than the lower limit of the value range corresponding to the database query parameter, use the lower limit as the updated database query parameter of the first database query parameter group; if the sum does not exceed the value range corresponding to the database query parameter, use the sum as the updated database query parameter of the first database query parameter group.
8. The method according to claim 2, characterized in that: The updating of the database query parameters in each of the database query parameter groups according to the query execution result corresponding to each of the database query parameter groups further includes: If there is a second database query parameter group, a third random number is generated within the value range corresponding to each database query parameter in the second database query parameter group, and the generated third random number is used as the updated database query parameter of the second database query parameter group, wherein the second database query parameter group is the database query parameter group corresponding to the query status information representing the query failure among the M database query parameter groups.
9. A sample generating device, characterized in that: The device comprises: An acquisition module is used to acquire M database query parameter groups, where M≥1; a generating module, configured to execute a database query operation for each of the database query parameter groups according to preset query plan information and the database query parameters currently included in the database query parameter group, and obtain a query execution result corresponding to the database query parameter group; and to generate a training sample corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group, and the database query parameters currently included in the database query parameter group, wherein the training sample is used as a training sample of a database query parameter adjustment model; An updating module is used to update the database query parameters in each of the database query parameter groups in response to failure to meet the iteration stop condition, according to the query execution result corresponding to each of the database query parameter groups, and trigger the generation module to re-execute the database query operation for each of the database query parameter groups according to the preset query plan information and the database query parameters currently included in the database query parameter group to obtain the query execution result corresponding to the database query parameter group; and generate training samples corresponding to the database query parameter group according to the query plan information, the query execution result corresponding to the database query parameter group and the database query parameters currently included in the database query parameter group until the iteration stop condition is met.
10. 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 according to any one of claims 1 to 8 are implemented.
11. 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 8.
12. 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 8 are implemented.