Proxy model-oriented reasoning query re-optimization method, device and equipment and medium
By monitoring and retraining proxy models with historical data when necessary, the method addresses computational overhead issues in traditional query methods, ensuring efficient adaptation to dynamic data and resource changes.
Patent Information
- Application Number
- CN202411639951.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-11-18
AI Technical Summary
Traditional reasoning query methods for proxy models suffer from large computational overhead due to the need for retraining lightweight proxy models in response to dynamic changes in data distribution and system resources, leading to performance degradation.
A method that monitors statistical information during query execution, retraining the proxy model using historical data when changes exceed a threshold, thereby adapting to data distribution and system resource fluctuations without the need for full re-labeling, reducing computational overhead.
The method effectively reduces computational overhead by reusing historical data for proxy model retraining, ensuring the query plan adapts to dynamic changes, thus improving retraining efficiency and maintaining performance.
Smart Images

Figure CN119149588A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method, device, equipment and medium for reasoning query re-optimization oriented to a proxy model. Background Art
[0002] In recent years, with the rapid development of big data and artificial intelligence technologies, the scale of data has continued to grow, and the process of data analysis has become more and more complex, usually involving complex machine learning and deep learning technologies to mine knowledge from massive data. The data analysis process is reflected in the form of queries, and complex machine learning and deep learning models are encapsulated in user-defined functions (UDFs).
[0003] Traditional reasoning query methods often only plan a query plan once. The fixed query plan generated before the query starts is likely to have performance degradation over time. For this reason, a re-optimization mechanism needs to be introduced. On large-scale data, processing complex machine learning UDF queries is usually very time-consuming, so traditional query optimization methods can usually only optimize the execution of UDF filtering queries to a limited extent. For example, the predicate pushdown method can only push the query predicate down to the machine learning UDF that generates the corresponding label column. The machine learning UDF still needs to process all input data because the filter requires the machine learning UDF to generate the corresponding category label and select the corresponding category. The reordering technology finds the optimal order based on the execution cost (Cost) and selectivity (Selectivity) of the machine learning UDF, but the first UDF still needs to process all input data.
[0004] In recent years, in order to optimize the execution of UDF filtering queries, related technologies have cascaded two lightweight models before the time-consuming UDF, called proxy models, to reduce the amount of data that the subsequent time-consuming UDF needs to process and reduce the processing time of the entire query. In order to reduce the processing time of the entire query, a lightweight proxy model is trained for each UDF filter in a more fine-grained manner, and these lightweight proxy models are cascaded before the first UDF. In order to fully utilize the correlation between different UDF filters, the proxy model is retrained. However, retraining the proxy model will bring a large computational overhead.
[0005] At present, in the related technologies, the reasoning query re-optimization method for the proxy model has the problem of large computational overhead, and no effective solution has been proposed. Summary of the invention
[0006] Based on this, it is necessary to provide a method, device, equipment and medium for reasoning query re-optimization for a proxy model that can reduce computing overhead in response to the above technical problems.
[0007] In a first aspect, the present application provides a method for re-optimizing reasoning queries based on a proxy model, comprising: Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data required for query; wherein the inference model includes a proxy model and a machine learning model; During the execution of the first query plan, monitoring statistical information; wherein the statistical information includes system resources or query plan selection rate; When it is monitored that the change of the statistical information exceeds a threshold, based on the second query plan, historical data is input into the proxy model for retraining; wherein the historical data includes data carrying labels after being input into the inference model before the current batch of data.
[0008] In one embodiment, when it is detected that the change of the statistical information exceeds a threshold, based on the second query plan, inputting the historical data into the proxy model for retraining includes: When it is monitored that the change of the system resources exceeds a threshold, the historical data is input into the agent model for retraining.
[0009] In one embodiment, when it is detected that the change of the statistical information exceeds a threshold, based on the second query plan, inputting the historical data into the proxy model for retraining includes: In the case where it is monitored that the change of the query plan selection rate exceeds a threshold, selecting target data similar to the current batch data in the historical data; The target data is input into the proxy model for retraining.
[0010] In one embodiment, inputting the target data into the proxy model for retraining includes: If the data volume of the target data is smaller than the data volume of the current batch data, part of the data in the current batch data is read into the target data, so that the data volume of the target data is not less than the data volume of the current batch data.
[0011] In one embodiment, when it is detected that the change of the system resources exceeds a threshold, the historical data is input into the agent model for retraining, including: Determine a plurality of precision combinations based on the target accuracy in the second query plan; wherein each of the precision combinations includes precision values of a plurality of the proxy models; Obtain a first precision combination obtained by combining the precision values of multiple first proxy models to be retrained, and determine whether there is a second precision combination having a common prefix with the first precision combination; wherein the second precision combination is obtained by combining the precision values of multiple second proxy models that have been retrained, and the common prefix includes at least one identical precision; When it is determined that there is a second precision combination having a common prefix with the first precision combination, the first proxy model corresponding to the common prefix part is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.
[0012] In one of the embodiments, when it is monitored that the change of the statistical information exceeds a threshold, the method further includes: Multiple candidate query plans are input into a deep learning model, and the execution time of each candidate query plan on the current batch of data is estimated based on the deep learning model, and the candidate query plan with the shortest execution time is determined as the second query plan.
[0013] In one embodiment, before inputting the current batch of data into the inference model, the method further includes: Determine multiple preset query plans based on different search paths, different batches of data, and different system resources; Execute the preset query plan to obtain an execution result; wherein the execution result includes at least one of the following: accuracy rate, selection rate, screening rate, and time cost; Generate training data based on the preset query plan and the execution result; The deep learning model is trained based on the training data.
[0014] In a second aspect, the present application further provides a proxy model-oriented reasoning query re-optimization device, the device comprising: A query module, used to input the current batch of data into the inference model for processing based on the first query plan to obtain the data required for query; wherein the inference model includes a proxy model and a machine learning model; A monitoring module, used for monitoring statistical information during the execution of the first query plan; wherein the statistical information includes system resources or a query plan selection rate; A re-optimization module is used to input historical data into the proxy model for retraining based on a second query plan when it is monitored that the change of the statistical information exceeds a threshold; wherein the historical data includes data with labels that are input into the inference model before the current batch of data and processed.
[0015] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in the first aspect when executing the computer program.
[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0017] The above-mentioned inference query re-optimization method, device, equipment and medium for proxy models use system resources or query plan selection rate as statistical information and monitor the statistical information during the execution of the query plan. When a sudden change in the statistical information is detected, the proxy model is retrained based on the new query plan, so that the query plan can be adjusted as the data distribution, system resources and other factors involved in the query change, thereby avoiding the drawbacks of the method of only planning the query plan once in traditional technology; at the same time, historical data is reused in the process of retraining the proxy model, which can avoid the re-optimization overhead caused by re-labeling the data using a machine learning model, thereby reducing the computational overhead generated by retraining the proxy model and improving the retraining efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A hardware structure block diagram of a terminal of a proxy model-oriented reasoning query re-optimization method in one embodiment; Figure 2 A flowchart of a proxy model-oriented reasoning query re-optimization method in one embodiment; Figure 3 is a flow chart of a method for reusing historical data in different situations in an embodiment; Figure 4 A flowchart of a proxy model reuse method in one embodiment; Figure 5 It is a structural block diagram of a proxy model-oriented reasoning query re-optimization device in one embodiment; Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0020] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0021] Assume that the UDF filter query q contains user-defined functions UDFs{F 1 ,···F n}, and their corresponding filters are {σ 1 ,···σ n}, and the target accuracy A.
[0022] In the related art, the rearrangement technology and optimization method for UDF filtering query include the following steps: S1, build a search tree (including all permutations of UDFs involved in the query): if the query contains F 1 , F 2 These two UDFs, the search space contains F 1 F 2 and F 2 F 1 ; S2, explores different paths to find the fastest path under a given accuracy target; S2 can be further divided into: S2.1, use UDF to process the data to be processed and generate labeled data for subsequent training of the proxy model; S2.2, use the labeled data generated by S2.1 to train the proxy model under different precision combinations, calculate the corresponding cost, and find the precision combination and path with the lowest cost, which is the approximately optimal query plan.
[0023] When the above method calls the inference model based on the query plan (obtained by cascading the proxy model with the machine learning model), in order to retrain the proxy model, it is necessary to use the machine learning model to label the data, and then use the labeled data to train the proxy model. However, this method will cause the re-optimization overhead to be as large as the overhead of the initial optimization. Moreover, the above method ignores the problem of dynamic environmental changes in queries. In stream processing scenarios, data distribution and system resources may change continuously, and the fixed execution plan generated before the query starts is likely to cause performance degradation. Based on the analysis of the above situation, the present application provides a proxy model-oriented inference query re-optimization method, device, equipment and medium that can reduce computing overhead.
[0024] In one embodiment, the proxy model-oriented reasoning query re-optimization method can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 1 is a hardware structure block diagram of a terminal of a proxy model-oriented reasoning query re-optimization method according to an embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 101 and memory 102 for storing data, wherein processor 101 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 103 and an input and output device 104 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0025] The memory 102 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the agent model-oriented reasoning query re-optimization method in this embodiment. The processor 101 executes various functional applications and data processing by running the computer program stored in the memory 102, that is, to implement the above method. The memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 102 may further include a memory remotely arranged relative to the processor 101, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0026] The transmission device 103 is used to receive or send data via a network. The above network includes a wireless network provided by a communication provider of the terminal. In one example, the transmission device 103 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 103 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0027] In one embodiment, Figure 2 As shown in FIG. 1 , a flowchart of a method for reasoning query re-optimization oriented to a proxy model is provided. The method is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps: Step S101, based on the first query plan, input the current batch data into the inference model for processing to obtain the required query data; wherein the inference model includes a proxy model and a machine learning model.
[0028] The first query plan mainly includes: target accuracy, search path, and selection of proxy model. Optionally, on this basis, the query plan can also include the data to be processed (i.e., the data to be queried) and system resources. Based on the first query plan, the current batch of data is input into the inference model for processing, which is to execute the query plan. Specifically, under the conditions of given target accuracy and system resources, the search path is used to perform filtering queries in the current batch of data to obtain the required query data. Among them, the search path specifically refers to the arrangement order of the machine learning model. The machine learning model can be encapsulated in a user-defined function (UDFs) to filter the current batch of data and generate corresponding category labels. The proxy model is cascaded before the machine learning model to select the corresponding category data for the machine learning model to process, thereby accelerating the execution of the machine learning model and reducing the filtering query time.
[0029] Specifically, in step S101, by receiving the query request and predicate input by the user, the batch data and system resources to be processed can be determined, and then a query plan can be generated. Based on the query plan, the inference model is called to process the current batch data to obtain the data to be queried.
[0030] Step S102, monitoring statistical information during the execution of the first query plan; wherein the statistical information includes system resources or a query plan selection rate.
[0031] System resources include but are not limited to hardware resources such as the number of available CPUs, memory, disk I / O, and software resources such as database connections. The query plan selection rate refers to the selection rate of the machine learning model for multiple possible query plans. Monitoring statistical information can be to monitor whether the change of statistical information exceeds the threshold. If the change of statistical information exceeds the threshold, it means that the current data distribution or system resources have changed, which causes a sudden change in the execution time of the query plan per unit of data. If the proxy model is not adjusted, the inference model will not be able to adapt to the current data distribution or system resources.
[0032] Step S103, when it is monitored that the change of statistical information exceeds a threshold, based on the second query plan, the historical data is input into the proxy model for retraining; wherein the historical data includes the data with labels that are input into the inference model before the current batch of data and processed.
[0033] When the change of the monitored statistical information exceeds the threshold, it means that the current data distribution or system resources have mutated, and the proxy model needs to be retrained to adapt the inference model to the current data distribution or system resources. When retraining the proxy model, multiple search paths can be determined based on the given second query plan, and different search paths can be explored in the multiple search paths to find the fastest search path under the given target accuracy. Among them, the second query plan is a new query plan. Specifically, it is originally necessary to use a machine learning model to process the data to be processed, generate labeled data, and then use the labeled data to retrain the proxy model. Specifically, the proxy model is trained with labeled data under different precision combinations, and the corresponding cost is calculated to find the precision combination and search path with the lowest cost, and obtain an approximately optimal query plan. Now, this embodiment directly skips the step of labeling the machine learning model, and directly inputs the historical data into the proxy model for retraining, because the historical data is the data that has been input into the inference model for processing before, and is labeled with a category label after processing, and does not need to be labeled repeatedly.
[0034] In the above steps S101 to S103, during the execution of the query plan, system resources or query plan selection rate are used as statistical information, and the statistical information is monitored. When a sudden change in the statistical information is detected, the proxy model is retrained based on the new query plan, so that the query plan can be adjusted as the data distribution, system resources and other factors involved in the query change, thereby avoiding the disadvantage of the method of only planning the query plan once in the traditional technology; at the same time, historical data is reused in the process of retraining the proxy model, which can avoid the re-optimization overhead caused by re-labeling the data using the machine learning model, thereby reducing the computational overhead generated by retraining the proxy model and improving the retraining efficiency.
[0035] In one embodiment, Figure 3 A flowchart of the historical data reuse method in different situations is provided, such as Figure 3 As shown, the process includes the following steps: Step S201, monitor statistical information during the execution of the current query plan; if it is monitored that the change of system resources exceeds the threshold, execute step S202; otherwise, if it is monitored that the change of the query plan selection rate exceeds the threshold, execute step S203.
[0036] Step S202: input the historical data into the proxy model for retraining. In this step, if the processing cost of the inference model changes due to changes in system resources (such as the number of available CPUs, memory, disk I / O and other hardware resources, and software resources such as database connections, etc.), the previously processed historical data can be reused without filtering to achieve retraining of the proxy model.
[0037] Step S203, select target data similar to the current batch data from the historical data; input the target data into the proxy model for retraining. In this step, if the processing cost of the inference model changes due to a change in the query plan selection rate, it is necessary to filter the historical data and select historical data similar to the current batch data. Specifically, the similarity between the current batch data and the previously processed batch data can be compared one by one. If the similarity exceeds a threshold, it is reused, otherwise it is not reused. Because if the historical data is not similar to the current batch data, directly reusing the historical data will cause the newly generated query plan to be inappropriate for the current batch data. By re-optimizing the proxy model using historical data similar to the current batch data, the retrained proxy model can be made applicable to the current batch data.
[0038] In this embodiment, by reusing historical data in different situations, on the one hand, the computational overhead of using machine learning models to generate labeled data can be reduced, and on the other hand, the effect of retraining the proxy model can be improved. The historical data reuse strategies in the above two different situations are introduced below.
[0039] Furthermore, in the above step S203, if the data volume of the target data is less than the data volume of the current batch data, part of the data in the current batch data is read into the target data, so that the data volume of the target data is not less than the data volume of the current batch data. This is set up because it is considered that the retraining of the proxy model requires a certain amount of data support. If the historical data is not sufficient to retrain the proxy model after similarity judgment, it is necessary to read new input data. Therefore, a feasible method is to make the target data equivalent to the data volume required for the current query optimization. If the amount of reusable historical data is insufficient, it is supplemented by reading new data. This setting can improve the reliability of the retraining process of the proxy model.
[0040] In one embodiment, when it is detected that the change of system resources exceeds a threshold, historical data is input into the proxy model for retraining. In order to further improve the efficiency of retraining, the proxy model that has been retrained before can be reused under certain circumstances. Figure 4 A flowchart of a proxy model reuse method is provided, such as Figure 4 As shown, the process includes the following steps: Step S301, determining a plurality of precision combinations based on the target accuracy in the second query plan; wherein each precision combination includes precision values of a plurality of proxy models.
[0041] While the proxy model speeds up the query progress, it will incur an execution cost, that is, it will lose some accuracy. Each proxy model has a different accuracy value. A query plan involves the use of multiple proxy models. The actual accuracy of the query plan is obtained by multiplying the accuracy values of multiple proxy models. The target accuracy is set to ensure a certain query quality. In this step, based on the target accuracy given by the second query plan, multiple accuracy values can be determined, and the multiple accuracy values can be arranged and combined to obtain multiple accuracy combinations, where the value obtained by multiplying the accuracy values in each accuracy combination is equal to or close to the target accuracy. The second query plan then determines the search path. Based on the search path, the proxy model is retrained using labeled data under different accuracy combinations, and the corresponding cost is calculated to find the accuracy combination with the lowest cost.
[0042] Step S302, obtain a first precision combination obtained by combining the precision values of multiple first proxy models to be retrained, and determine whether there is a second precision combination having a common prefix with the first precision combination; wherein the second precision combination is obtained by combining the precision values of multiple second proxy models that have been retrained, and the common prefix includes at least one identical precision.
[0043] In this step, the precision combinations that have been retrained or tried (defined as the second precision combination) can be recorded, and before trying a new precision combination (defined as the first precision combination), it is necessary to find out whether there is a tried second precision combination that has a common prefix with the first precision combination. If so, the proxy model corresponding to the precision value of the common prefix (i.e., the second proxy model) can be reused when retraining the first proxy model to avoid repeated training.
[0044] Step S303, when it is determined that there is a second precision combination having a common prefix with the first precision combination, the first proxy model corresponding to the common prefix portion is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.
[0045] Exemplarily, assume that the precision values of the first precision combination currently being tried are 0.98, 0.95, and 0.97, respectively, and the precision values of the second precision combinations that have been tried are 0.98, 0.97, and 0.95, respectively. It can be found that the first precision combination and the second precision combination have a common prefix of 0.98, so the first precision combination does not need to be retrained to obtain the first proxy model corresponding to the first precision value, but can directly reuse the second proxy model corresponding to the first precision value in the second precision combination. Of course, it is not necessarily only the first second proxy model that can be directly reused, but there can also be multiple ones, depending on how long the common prefix is and how many common prefixes there are, and how many second proxy models are reused. This setting reduces the redundancy in the retraining proxy model method and further accelerates the optimization process.
[0046] In one embodiment, when it is detected that the change of the statistical information exceeds a threshold, the method further includes: Multiple candidate query plans are input into the deep learning model, and the execution time of the candidate query plans on the current batch of data is estimated based on the deep learning model, and the candidate query plan with the shortest execution time is determined as the second query plan.
[0047] In this embodiment, the multiple candidate query plans are all possible query plans. The candidate query plan with the shortest execution time can be determined by the deep learning model from the multiple candidate query plans, and the proxy model can be retrained as the second query plan, thereby limiting the size of the search space and accelerating the optimization process. The search space refers to the machine learning model required for the query, and multiple machine learning models are arranged and combined to obtain multiple search paths, and the multiple search paths constitute the search space. The training process of the deep learning model is as follows: Based on different search paths, different batches of data, and different system resources, multiple preset query plans are determined; the preset query plans are executed to obtain execution results; wherein the execution results include at least one of the following: accuracy, selection rate, screening rate, and time cost; based on the preset query plans and execution results, training data is generated; and a deep learning model is trained based on the training data.
[0048] Among them, the accuracy may include the accuracy of the proxy model and / or the accuracy of the query plan as a whole; the selection rate may include the selection rate of the proxy model; the screening rate may include the screening rate of the proxy model; the time cost may include one or more of the time cost spent by the proxy model to process each piece of data, the time cost spent by the machine learning model to process each piece of data, or the time cost of the query plan as a whole.
[0049] Specifically, this embodiment can receive a query request input by a user, determine the data stream, system resources and search space to be processed based on the query request, encode the data stream, system resources and different search paths in the search space to be processed, respectively, and input them into the trained deep learning model to obtain the estimated execution time under different search paths. Since the second query plan is the query plan with the shortest execution time among all possible candidate query plans, the arrangement order of the machine learning models determined by the second query plan is approximately the optimal order, thus reducing the size of the search space and accelerating the re-optimization process of the proxy model.
[0050] In this embodiment, a proxy model-oriented reasoning query re-optimization device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware for predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0051] Figure 5 is a structural block diagram of the proxy model-oriented reasoning query re-optimization device of this embodiment, such as Figure 5 As shown, the device comprises: A query module, for inputting the current batch of data into the inference model for processing based on the first query plan to obtain the data required for query; wherein the inference model includes a proxy model and a machine learning model; A monitoring module, used for monitoring statistical information during the execution of the first query plan; wherein the statistical information includes system resources or a query plan selection rate; The re-optimization module is used to input historical data into the proxy model for retraining based on the second query plan when it is monitored that the change of statistical information exceeds a threshold; wherein the historical data includes the data with labels that are input into the inference model before the current batch of data and processed.
[0052] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0053] In one embodiment, the monitoring module is used to input historical data into the agent model for retraining when it is detected that the change of system resources exceeds a threshold.
[0054] In one embodiment, the re-optimization module is used to select target data similar to the current batch data from the historical data when a change in the query plan selection rate is detected to exceed a threshold; Input the target data into the proxy model for retraining.
[0055] In one embodiment, the re-optimization module is used to: if the data volume of the target data is smaller than the data volume of the current batch data, read part of the data in the current batch data into the target data, so that the data volume of the target data is not less than the data volume of the current batch data.
[0056] In one embodiment, the re-optimization module is used to determine a plurality of precision combinations based on the target accuracy in the second query plan; wherein each precision combination includes precision values of a plurality of proxy models; Obtain a first precision combination obtained by combining the precision values of multiple first proxy models to be retrained, and determine whether there is a second precision combination having a common prefix with the first precision combination; wherein the second precision combination is obtained by combining the precision values of multiple second proxy models that have been retrained, and the common prefix includes at least one identical precision; When it is determined that there is a second precision combination having a common prefix with the first precision combination, the first proxy model corresponding to the common prefix portion is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.
[0057] In one embodiment, the device also includes a second query plan determination module, which is used to input multiple candidate query plans into a deep learning model, estimate the execution time of each candidate query plan on the current batch of data based on the deep learning model, and determine the candidate query plan with the shortest execution time as the second query plan.
[0058] In one embodiment, the device further includes a deep learning model training module, which is used to determine a plurality of preset query plans based on different search paths, different batches of data, and different system resources; wherein the preset query plans are used to filter the corresponding batches of data; Execute the preset query plan and obtain the execution result; wherein the execution result includes at least one of the following: accuracy, selection rate, screening rate, and time cost; Generate training data based on the preset query plan and execution results; Train a deep learning model based on the training data.
[0059] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0060] In addition, in combination with the proxy model-oriented reasoning query re-optimization method provided in the above embodiment, a storage medium can also be provided in this embodiment for implementation. The storage medium stores a computer program; when the computer program is executed by a processor, the following steps are implemented: Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data required for query; wherein the inference model includes a proxy model and a machine learning model; During the execution of the first query plan, monitoring statistical information; wherein the statistical information includes system resources or a query plan selection rate; When it is monitored that the change of statistical information exceeds a threshold, historical data is input into the proxy model for retraining based on the second query plan; wherein the historical data includes data with labels that are input into the inference model before the current batch of data and processed.
[0061] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: when it is detected that the change of statistical information exceeds a threshold, based on the second query plan, inputting historical data into the proxy model for retraining, including: When it is detected that the change of system resources exceeds the threshold, the historical data is input into the agent model for retraining.
[0062] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: when it is detected that the change of statistical information exceeds a threshold, based on the second query plan, inputting historical data into the proxy model for retraining, including: When it is detected that the change of the query plan selection rate exceeds a threshold, target data similar to the current batch data is selected from the historical data; Input the target data into the proxy model for retraining.
[0063] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: inputting target data into the proxy model for retraining, including: If the data volume of the target data is smaller than the data volume of the current batch data, part of the data in the current batch data is read into the target data so that the data volume of the target data is not less than the data volume of the current batch data.
[0064] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: when it is detected that the change of system resources exceeds a threshold, inputting historical data into the agent model for retraining, including: Determine multiple precision combinations based on the target accuracy in the second query plan; wherein each precision combination includes precision values of multiple proxy models; Obtain a first precision combination obtained by combining the precision values of multiple first proxy models to be retrained, and determine whether there is a second precision combination having a common prefix with the first precision combination; wherein the second precision combination is obtained by combining the precision values of multiple second proxy models that have been retrained, and the common prefix includes at least one identical precision; When it is determined that there is a second precision combination having a common prefix with the first precision combination, the first proxy model corresponding to the common prefix portion is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.
[0065] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: when it is detected that the change of the statistical information exceeds the threshold, the method further includes: Multiple candidate query plans are input into the deep learning model, and the execution time of each candidate query plan on the current batch of data is estimated based on the deep learning model, and the candidate query plan with the shortest execution time is determined as the second query plan.
[0066] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: before inputting the current batch of data into the inference model, the method further includes: Based on different search paths, different batches of data, and different system resources, multiple preset query plans are determined; wherein the preset query plans are used to filter the corresponding batches of data; Execute the preset query plan and obtain the execution result; wherein the execution result includes at least one of the following: accuracy, selection rate, screening rate, and time cost; Generate training data based on the preset query plan and execution results; Train a deep learning model based on the training data.
[0067] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for reasoning query re-optimization oriented to an agent model is implemented.
[0068] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0069] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0070] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0071] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0072] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for re-optimizing reasoning queries based on a proxy model, characterized in that: include: Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data required for query; wherein the inference model includes a proxy model and a machine learning model; During the execution of the first query plan, monitoring statistical information; wherein the statistical information includes system resources or query plan selection rate; When it is monitored that the change of the statistical information exceeds a threshold, based on the second query plan, historical data is input into the proxy model for retraining; wherein the historical data includes data carrying labels after being input into the inference model before the current batch of data.
2. The method for reasoning query re-optimization based on proxy model according to claim 1, characterized in that: When it is detected that the change of the statistical information exceeds a threshold, based on the second query plan, inputting the historical data into the proxy model for retraining, including: When it is monitored that the change of the system resources exceeds a threshold, the historical data is input into the agent model for retraining.
3. The method for reasoning query re-optimization based on proxy model according to claim 1, characterized in that: When it is detected that the change of the statistical information exceeds a threshold, based on the second query plan, inputting the historical data into the proxy model for retraining, including: In the case where it is monitored that the change of the query plan selection rate exceeds a threshold, selecting target data similar to the current batch data in the historical data; The target data is input into the proxy model for retraining.
4. The method for reasoning query re-optimization based on proxy model according to claim 3, characterized in that: Inputting the target data into the proxy model for retraining includes: If the data volume of the target data is smaller than the data volume of the current batch data, part of the data in the current batch data is read into the target data, so that the data volume of the target data is not less than the data volume of the current batch data.
5. The method for reasoning query re-optimization based on proxy model according to claim 1, characterized in that: When it is detected that the change of the system resources exceeds a threshold, the historical data is input into the agent model for retraining, including: Determine a plurality of precision combinations based on the target accuracy in the second query plan; wherein each of the precision combinations includes precision values of a plurality of the proxy models; Obtain a first precision combination obtained by combining the precision values of multiple first proxy models to be retrained, and determine whether there is a second precision combination having a common prefix with the first precision combination; wherein the second precision combination is obtained by combining the precision values of multiple second proxy models that have been retrained, and the common prefix includes at least one identical precision; When it is determined that there is a second precision combination having a common prefix with the first precision combination, the first proxy model corresponding to the common prefix part is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.
6. The method for reasoning query re-optimization based on proxy model according to claim 1, characterized in that: In the case where it is monitored that the change of the statistical information exceeds a threshold, the method further includes: Multiple candidate query plans are input into a deep learning model, and the execution time of each candidate query plan on the current batch of data is estimated based on the deep learning model, and the candidate query plan with the shortest execution time is determined as the second query plan.
7. The method for reasoning query re-optimization based on proxy model according to claim 6, characterized in that: Before inputting the current batch of data into the inference model, the method further includes: Determine multiple preset query plans based on different search paths, different batches of data, and different system resources; Execute the preset query plan to obtain an execution result; wherein the execution result includes at least one of the following: accuracy rate, selection rate, screening rate, and time cost; Generate training data based on the preset query plan and the execution result; The deep learning model is trained based on the training data.
8. A proxy model-oriented reasoning query re-optimization device, characterized in that: The device comprises: A query module, used to input the current batch of data into the inference model for processing based on the first query plan to obtain the data required for query; wherein the inference model includes a proxy model and a machine learning model; A monitoring module, used for monitoring statistical information during the execution of the first query plan; wherein the statistical information includes system resources or a query plan selection rate; A re-optimization module is used to input historical data into the proxy model for retraining based on a second query plan when it is monitored that the change of the statistical information exceeds a threshold; wherein the historical data includes data with labels that are input into the inference model before the current batch of data and processed.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, 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 7 are implemented.
Citation Information
Patent Citations
Database management system, related device, method and medium
CN114443680A
Database query optimization method and system, electronic equipment and storage medium
CN116028528A
Public query method based on batch historical task fuzzification
CN116701429A
Inference query optimization method and device based on proxy model rearrangement technology
CN116842060A
Scheduling execution method and device for database query optimization, equipment and medium
CN117520380A
