Prediction query method and device

By storing data in a cache and inputting it into the prediction model for prediction when the target amount is reached, the data volume is optimized to match the efficient inference requirements of the prediction model. This solves the problem of low prediction query efficiency in existing technologies and achieves efficient utilization of computing resources and efficient operation of the prediction model.

CN120910066APending Publication Date: 2025-11-07EAST CHINA NORMAL UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510787947.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

In existing predictive query solutions, machine learning models have low inference efficiency and high cost, and the computational resource utilization of predictive models is not high, resulting in low predictive query efficiency.

Method used

By storing data in a cache and inputting it into the prediction model when the target amount is reached, the amount of data is optimized to match the efficient inference requirements of the prediction model. The amount of data is also adjusted by combining the runtime information of the prediction model to improve prediction efficiency.

Benefits of technology

This improves the utilization of computational resources and the efficiency of prediction models, thereby enhancing the overall efficiency of prediction queries and ensuring the stability and efficiency of prediction models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910066A_ABST
    Figure CN120910066A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a prediction query method and device.The method comprises the steps that a query plan for a target database is obtained, and the query plan at least comprises a first operator and a second operator; the query plan is executed, the second operator is called through the first operator, a calculation result returned by the second operator is stored in a preset cache space, if the data volume of the data stored in the cache space reaches a predetermined target volume, target data of the target volume is read from the cache space, and if the data volume of the data stored in the cache space reaches the predetermined target volume, the query plan is executed. Inputting the target data into a preset prediction model to obtain a prediction result; and determining a query result of the query plan according to the prediction result.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] One or more embodiments of the present specification relate to the technical field of database, and in particular, to a prediction query method and device. BACKGROUND

[0002] In recent years, with the development of machine learning technology, a new database query technology combined with machine learning has been generated. Among them, prediction query is a database query method that loads data from a database system and then generates a prediction result according to the loaded data through a machine learning model. However, the existing prediction query scheme still has the problem of low inference efficiency and high inference cost of the machine learning model. SUMMARY

[0003] Embodiments in the present specification aim to provide a prediction query method and device, which can make the data amount input to the prediction model in the process of prediction query conform to the data amount for efficient inference of the prediction model. In turn, the utilization rate of the computing resources allocated to the prediction model and the prediction efficiency of the prediction model in the process of prediction query are improved, solving the deficiencies of the prior art.

[0004] According to a first aspect, a prediction query method is provided, comprising:

[0005] obtaining a query plan for a target database, the query plan comprising at least a first operator and a second operator;

[0006] starting the query plan, invoking the second operator through the first operator, saving the calculation result returned by the second operator to a preset cache space; if the data amount of the saved data in the cache space reaches a predetermined target amount, extracting the target data of the target amount from the cache space, inputting the target data to a preset prediction model, and obtaining a prediction result;

[0007] determining a query result of the query plan according to the prediction result.

[0008] In a possible implementation, the query plan further comprises a third operator that invokes the first operator;

[0009] determining a query result of the query plan according to the prediction result, comprising:

[0010] determining the calculation result returned by the first operator to the third operator according to the prediction result, and determining the query result of the query plan according to the calculation result.

[0011] In a possible implementation, the method further includes, after inputting the target data into the preset prediction model, deleting the target data from the preset cache space.

[0012] In a possible implementation, the second operator is called by the first operator, and the calculation result returned by the second operator is saved to a preset cache space; if the data amount of the saved data in the cache space reaches a predetermined target amount, the target data of the target amount is extracted from the cache space, the target data is input into a preset prediction model, and a prediction result is obtained, including:

[0013] The second operator is called multiple times by the first operator, and after the second operator is called in any round, the calculation result returned by the second operator in the round is saved to a preset cache space; if the data amount of the saved data in the cache space reaches a predetermined target amount, the target data of the target amount is extracted from the cache space, the target data is input into the prediction model, and the prediction result is obtained.

[0014] In a possible implementation, the method further includes:

[0015] After the target data is input into the prediction model, a prediction efficiency value of the current input into the prediction model is determined according to runtime information of the prediction model, and whether the value of the target amount is modified is determined at least according to the prediction efficiency value of the current input into the prediction model.

[0016] In a possible implementation, the target amount is determined by increasing an iteration amount on the data amount of the last input into the prediction model;

[0017] Whether the value of the target amount is modified is determined at least according to the prediction efficiency value of the current input into the prediction model, including:

[0018] If the growth rate of the prediction efficiency value of the current input into the prediction model relative to the prediction efficiency value of the last input into the prediction model exceeds a preset threshold, the value of the target amount is retained.

[0019] If the growth rate of the prediction efficiency value of the current input into the prediction model relative to the prediction efficiency value of the last input into the prediction model does not exceed the preset threshold, the value of the target amount is rolled back to the data amount of the last input into the prediction model.

[0020] In a possible implementation, the runtime information includes an inference time length of the prediction model and an input data amount of the prediction model, the prediction efficiency value is negatively correlated with the inference time length and positively correlated with the input data amount.

[0021] In a possible implementation, the first query plan is obtained, including:

[0022] obtaining a structured query statement, and generating a first query plan according to the structured query statement.

[0023] In a possible implementation, the second operator is configured to read data from a database.

[0024] The method further includes saving the calculation result returned by the second operator to a preset cache space.

[0025] In a possible implementation, the method further includes inputting the target data into a preset prediction model.

[0026] In a possible implementation, the method further includes saving the calculation result returned by the second operator to a preset cache space.

[0027] If the data amount of the calculation result returned by the second operator is greater than the upper limit of the capacity of the cache space, the capacity of the cache space is expanded, and the calculation result returned by the second operator is saved to the cache space after expansion.

[0028] According to a second aspect, a prediction query device is provided, and the device includes:

[0029] an obtaining unit configured to obtain a query plan for a target database, the query plan including at least a first operator and a second operator;

[0030] a calling unit configured to start the query plan, call the second operator through the first operator, save a calculation result returned by the second operator to a preset cache space, and if the data amount of the saved data in the cache space reaches a predetermined target amount, extract target data of the target amount from the cache space, input the target data into a preset prediction model, and obtain a prediction result.

[0031] a determining unit configured to determine a query result of the query plan according to the prediction result.

[0032] According to a third aspect, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. When the computer program is executed in a computer, the computer program causes the computer to execute the method of the first aspect.

[0033] According to a fourth aspect, a computing device is provided, and the computing device includes a memory and a processor. The memory stores executable code, and the processor executes the executable code to implement the method of the first aspect.

[0034] By using one or more of the methods, devices, computing devices, and storage media in the various aspects above, the amount of data input into the prediction model each time during the process of predicting the query can be made to conform to the amount of data for efficient inference of the prediction model. In turn, the utilization of the computing resources allocated to the prediction model and the prediction efficiency of the prediction model during the process of predicting the query are improved. BRIEF DESCRIPTION OF DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.

[0036] Figure 1 A schematic diagram of a query scheme based on a vectorized volcano model is shown.

[0037] Figure 2 A schematic diagram of a prediction query scheme based on a vectorized volcano model is shown.

[0038] Figure 3 A schematic diagram of a prediction query method according to an embodiment of the present specification is shown.

[0039] Figure 4 A flowchart of a prediction query method according to an embodiment of the present specification is shown.

[0040] Figure 5 A schematic diagram of determining a target amount according to another embodiment of the present specification is shown.

[0041] Figure 6 A structural diagram of a prediction query device according to an embodiment of the present specification is shown. DETAILED DESCRIPTION

[0042] In order to enable those skilled in the art to better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be described clearly and completely in conjunction with the drawings in the embodiments of the present specification. Obviously, the described embodiments are only some of the embodiments of the present specification, but not all the embodiments. Based on the embodiments in the present specification, all other embodiments obtained by those skilled in the art without any creative effort should be within the scope of protection of the present specification.

[0043] As described previously, in recent years, with the development of machine learning technology, a new database query technology combined with machine learning has been generated. Among them, prediction query is a database query way that loads data from a database system and then generates a prediction result according to the loaded data through a machine learning model. The existing execution process of the prediction query is often based on a volcano model, which usually includes a classic volcano model and a vectorized volcano model. Among them, the classic volcano model (also known as the iterator model) is a database computing model. This computing model abstracts the operations in the relational algebra into operators, and when executing a query, the upper layer operator recursively calls the lower layer operator to pull data from the database, and each time the data is pulled to process it in units of rows. The vectorized volcano model (also known as the batch processing model) is a computing model extended on the basis of the classic volcano model. Unlike the classic volcano model, each time the lower layer operator is called, a batch of data is returned, thereby reducing the number of calls to the lower layer operator, reducing the call cost, and thereby speeding up the query execution process. Figure 1 A schematic diagram of a query scheme based on a vectorized volcano model is shown. As shown in Figure 1 For example, the upstream select operator can call the downstream scan operator multiple times, each time calling the scan operator to pull a batch (multiple rows) of data from the database, and after multiple calls, the select operator obtains all the data required for the calculation of the operator.

[0044] Figure 2 A schematic diagram of a prediction query scheme based on a vectorized volcano model is shown. As shown in Figure 2As shown, for example, the upstream select operator can call the downstream scan operator multiple times, each time the scan operator pulls a batch (multiple rows) of data from the database, and inputs the pulled data into a pre-set prediction model to get the prediction result and returns to the select operator. Through the prediction model, new data can be predicted according to the existing data in the database. For example, a user wants to obtain the churn rate of each customer. The database already has a customer data table, from which the customer purchase frequency and the city to which each customer belongs can be extracted, and the extracted customer purchase frequency and city are input into the prediction model to obtain the churn rate of each customer. Thus, the user can be output the identification of each customer and the predicted churn rate. In one example, the select operator can call the downstream scan operator multiple times, each time the scan operator can pull the customer purchase frequency and the city to which the customer belongs from the database, and input the customer purchase frequency and the city to which the customer belongs of multiple customers into a pre-set prediction model to get the churn rate of the multiple customers predicted this time, and return to the select operator. Finally, the select operator returns the identification (ID) and the predicted churn rate of all customers to the upper operator (e.g., the Output operator).

[0045] However, the problem of this scheme is that the amount of data read by the operator (e.g., scan operator) for extracting data from the data table is usually preset based on the database storage structure and the efficiency of reading data, rather than determined by the upper operator (e.g., select operator). When a user makes a prediction query through a prediction model, the main calculation process is usually to call the matrix calculation of the underlying high-performance computing through the machine learning framework to complete the inference process. The batch processing method can significantly speed up the operation process of the underlying calculation library by using high-performance computing technology, which makes the model inference operation performance sensitive to the inference batch size, that is, different prediction models often have different batch sizes for optimizing inference speed. That is, the amount of data input into the prediction model each time is usually determined according to the type of the prediction model. These two data amounts are often mismatched, and thus the computing power and video memory (e.g., GPU) allocated for the prediction model cannot be fully utilized due to the lack of sufficient batch data amount, and small batch data leads to a decrease in video memory utilization, reducing the prediction efficiency of the prediction model. For example, the amount of data (SN) that can be input into the prediction model each time is 800 rows, and the batch data amount (SD) that can be extracted from the database each time is 400. The amount of data input into the prediction model each time is only 400 rows. Since conditional filtering is often performed in, for example, a scan operator in actual production scenarios, the amount of filtered data can be further reduced, and the amount of data filtered each time can be different, that is, the amount of data input into the prediction model each time is further reduced. For example, the actual amount of data (SF) input into the prediction model in one round of inference is 200 rows. Thus, part of the prediction capability of the prediction model is wasted, the prediction efficiency of the prediction model is reduced, and the overall query efficiency of the prediction query is low.

[0046] In order to reduce the waste of prediction capability of the prediction model and improve the query efficiency of the prediction query, some existing prediction query schemes hope to match the batch data amount (SD) read from the database and the batch data amount (SN) input into the prediction model, and set the batch data amount (SD) extracted from the database to be the same as the amount of data (SN) input into the prediction model each time, for example, both are set to 800 for a specific prediction model. However, this scheme still has the following problems: As described above, in actual production scenarios, the operator (e.g., scan operator) for reading data often performs data filtering operations (e.g., filtering the read data according to the condition "city = 'Shanghai'"), so that the amount of filtered data is often less than the amount of read data, that is, although SD is equal to SN, the actual amount of data input into the prediction model is still less than SD. Moreover, the amount of data obtained by filtering the extracted data in different batches according to the same filtering condition is often different, which makes the actual amount of data input into the prediction model in different batches not only less than SD, but also variable. Thus, the prediction efficiency of the prediction model is low and unstable.

[0047] To address the aforementioned technical problems, this specification provides a predictive query method in its embodiments. Figure 3 A schematic diagram of a predictive query method according to an embodiment of this specification is shown. Figure 3 As shown, for example, the upstream `select` operator can call the downstream `scan` operator multiple times. Each call to the `scan` operator retrieves a batch (multiple rows) of data from the database and saves the retrieved data in a preset cache. When the amount of data stored in the preset cache reaches the target amount for input into the prediction model, the target amount of target data is read from the cache and input into the preset prediction model to obtain the prediction result, which is then returned to the `select` operator. Furthermore, after inputting the target data into the preset prediction model, the target data can be deleted from the cache. For example, a user wants to obtain the churn rate of each customer in Shanghai. The database already has a customer data table. In one example, the `select` operator can call the downstream `scan` operator multiple times. Each call to the `scan` operator retrieves the purchase frequency and city of multiple customers from the customer data table in the database, filters the retrieved customers, and saves the purchase frequency and city of customers belonging to Shanghai into a preset cache. When the amount of data stored in the cache reaches the target amount, it is input into the preset prediction model to obtain a prediction result (the churn rate of each of the target Shanghai customers), which is then returned to the `select` operator. For example, the first three calls to the `scan` operator each read 400 rows of data from the customer data table. After filtering by the condition "city = 'Shanghai'", the amount of data saved to the cache after each call is 300, 350, and 150 rows respectively, resulting in 800 rows of data in the cache (corresponding to 800 customers belonging to Shanghai). The target amount for a batch input to the prediction model is 800 rows. After three calls to the `scan` operator, the amount of data saved in the cache reaches the target amount, allowing 800 rows to be read from the cache and input into the prediction model to predict the churn rate of each of the 800 customers belonging to Shanghai, returning to the `select` operator. The `scan` operator can then be called again until all rows in the customer data table have been read. The processing of data saved to the cache by subsequent calls to the `scan` operator is similar to the first three calls: whenever the amount of data saved in the cache reaches the target amount, the target amount of data is read from the cache and input into the prediction model for a batch prediction, and then this portion of data is deleted from the cache after being input into the prediction model.

[0048] The method has the following advantages: first, in the process of predicting the query, the amount of data input into the prediction model each time meets the amount of data required for efficient inference of the prediction model. Compared with existing prediction query schemes, the utilization rate of computing resources allocated to the prediction model can be improved, and the prediction efficiency of the prediction model can be improved. The improvement of the prediction efficiency of the prediction model also improves the efficiency of the prediction query. Second, in some embodiments, the amount of data input into the prediction model thereafter can also be updated according to the prediction efficiency of the prediction model. In essence, the amount of data input into the prediction model can be optimized according to the actual running effect of the prediction model, and the prediction efficiency of the prediction model can be further improved.

[0049] The detailed process of the method is further described below. Figure 4 According to an embodiment of the present specification, a flowchart of a prediction query method is shown in FIG. 4. As shown in FIG. 4, the method comprises the following steps: Figure 4 The method comprises the following steps:

[0050] In step S401, a query plan for a target database is obtained, and the query plan comprises at least a first operator and a second operator.

[0051] In step S403, the query plan is started, the second operator is called through the first operator, the calculation result returned by the second operator is saved to a preset cache space, if the amount of data saved in the cache space reaches a predetermined target amount, the target amount of target data is read from the cache space, the target data is input into a preset prediction model, and a prediction result is obtained.

[0052] In step S405, the prediction result is used to determine the query result of the query plan.

[0053] First, in step S401, a query plan for a target database can be obtained. The query plan can comprise at least a first operator and a second operator. The second operator can be called in the execution of the first operator. The query plan (Query Plan) is a detailed execution plan generated by a database management system (DBMS) for executing a database query (for example, a query described by an SQL statement). In different embodiments, the target database can be a database of different specific types, and the present specification does not limit this. The operator (Operator) is a logical unit in the query plan of the database, and each operator can correspond to a specific data processing behavior.

[0054] In different embodiments, the specific way of obtaining the query plan for the target database can be different, and the first operator and the second operator contained therein can also be different specific operators respectively. In one embodiment, a structured query statement can be obtained, and the first query plan can be generated according to the structured query statement. In one example, for example, a structured query statement such as "SELECT customer_id, PYTHON_UDF('churn_model', city, purchase_frequency) AS churn_risk FROM new_customers where city='Shanghai';" can be obtained. The query plan can be generated according to the structured query statement, and the generated query plan can contain, for example, a select operator (for determining the query result set) and a scan operator (for reading batch data from the database). The select operator can call the scan operator.

[0055] Then, in step S403, the query plan can be executed, the second operator is called by the first operator, and the calculation result returned by the second operator is saved to the preset cache space. If the amount of data saved in the cache space reaches a predetermined target amount, the target data of the target amount is read from the cache space, the target data is input into the preset prediction model, and the prediction result is obtained.

[0056] Specifically, in one embodiment, the second operator can be called by the first operator for multiple rounds, and after calling the second operator in any round, the calculation result returned by the second operator is saved to the preset cache space. If the amount of data saved in the cache space reaches a predetermined target amount, the target data of the target amount is read from the cache space, the target data is input into the prediction model, and the prediction result is obtained.

[0057] In another embodiment, if the amount of data of the calculation result returned by the second operator is greater than the upper limit of the capacity of the cache space, the capacity of the cache space is expanded, and the calculation result returned by the second operator is saved to the expanded cache space. In yet another embodiment, after the target data is input into the preset prediction model, the target data can be deleted from the cache space.

[0058] In different embodiments, the target amount can be determined in different ways. For example, in one embodiment, the target amount can be determined by increasing the amount of data input into the prediction model last time by an iteration amount. In different embodiments, the prediction model to which the target data is input can also be a model for predicting different targets or having a different neural network structure, which is not limited in the present specification.

[0059] In different embodiments, the specific method of inputting the target data into the prediction model can also differ. For example, in one embodiment, the target data can be input into the prediction model by calling a Python user-defined function. In different specific embodiments, the Python user-defined function called can be different specific functions.

[0060] In one embodiment, after the target data is input into the prediction model, the prediction efficiency value of the current input prediction model can be determined based on the prediction model's runtime information. At least based on the prediction efficiency value of the current input prediction model, it can be determined whether to modify the target value. In different specific embodiments, the specific content of the runtime information may differ. In one specific embodiment, the runtime information may include the running time of the prediction model in this round and the amount of input data for the prediction model in this round. The prediction efficiency value may be negatively correlated with the running time and positively correlated with the amount of input data.

[0061] In different specific embodiments, the specific methods for determining whether to modify the target value can differ. In the embodiment described above, where the target value is determined by adding an iteration amount to the data amount of the previous input prediction model, the method for determining whether to modify the value of the target value can be as follows: if the growth rate of the prediction efficiency value of the current input prediction model relative to the predetermined growth rate of the prediction efficiency value of the previous input prediction model exceeds a preset threshold, then the value of the target value is retained; if the growth rate of the prediction efficiency value of the current input prediction model relative to the predetermined growth rate of the prediction efficiency value of the previous input prediction model does not exceed the preset threshold, then the value of the target value is rolled back to the data amount of the previous input prediction model.

[0062] For example, in Figure 5 In the example shown, the target quantity (Y) is the sum of the amount of data input to the prediction model in the previous iteration (Yl) and the iteration quantity Inc, i.e., Y = Yl. l +Inc. The decision to modify the target value can be based on the prediction efficiency value of the current input prediction model. Specifically, it can be based on... Whether it is greater than T determines whether to modify the target value. Here, E is the prediction efficiency value of the input prediction model. l This represents the prediction efficiency value of the prediction model from the previous input. This represents the growth rate of the prediction efficiency value of the current input prediction model relative to the prediction efficiency value of the previous input prediction model, where T is a preset threshold. If... If the value is greater than T, then retain the value of Y; otherwise, roll back Y to Y'. l The value of .

[0063] Thereafter, in step S305, a query result of the query plan can be determined according to the prediction result. In different embodiments, the query plan can comprise other operators in addition to the first operator and the second operator. In one embodiment, the query plan further comprises a third operator which invokes the first operator. Thus, the first operator can be determined to return a calculation result of the third operator according to the prediction result, and the query result of the query plan can be determined according to the calculation result.

[0064] In the embodiment in which the query plan comprises the select operator and the scan operator, the query plan can further comprise an Output operator, for example, for outputting the query result set confirmed by the select operator to a user.

[0065] According to yet another aspect, embodiments further provide a query predicting apparatus. Figure 6 A structure diagram of a query predicting apparatus according to an embodiment of the present specification is shown in FIG. 6, which comprises: Figure 6 As shown in FIG. 6, the apparatus 600 comprises:

[0066] An obtaining unit 602 is configured to obtain a query plan for a target database, the query plan comprising at least a first operator and a second operator;

[0067] An invoking unit 604 is configured to execute the query plan, invoke the second operator through the first operator, save a calculation result returned by the second operator to a preset cache space, read a target amount of target data from the cache space if a data amount of the saved data in the cache space reaches a predetermined target amount, input the target data to a preset prediction model, and obtain a prediction result.

[0068] A determining unit 606 is configured to determine a query result of the query plan according to the prediction result.

[0069] According to yet another aspect, embodiments of the present specification further provide a computer readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform any of the above methods.

[0070] According to still another aspect, embodiments of the present specification further provide a computing device comprising a memory and a processor, the memory having executable code stored therein, and the processor implementing any of the above methods when executing the executable code.

[0071] It should be understood that the terms “first”, “second” and the like in the present specification are merely used for the purpose of description of similar concepts for the sake of simplicity, and do not have other limiting effects.

[0072] In the 1990s, it was quite obvious to distinguish whether an improvement in a technology was in hardware (e.g., improvement in circuit structures of diodes, transistors, switches, etc.) or in software (improvement in method flow). However, as technology has evolved, many improvements in method flow today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flow into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented by hardware entity modules. For example, a programmable logic device (PLD) (e.g., a field programmable gate array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming it, rather than by ordering a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented by "logic compiler" software, which is similar to software compilers used in program development, and the original code before compilation is also written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit that implements the logical method flow can be easily obtained.

[0073] The controller can be implemented in any suitable way, for example, the controller can take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code, such as software or firmware, executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91 SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that, in addition to being implemented in pure computer readable program code form, the controller can perfectly well be implemented to perform the same functions in the form of logic gates, switches, an application specific integrated circuit, a programmable logic controller and an embedded microcontroller, etc. by means of logical programming of the method steps. Such a controller can thus be considered a hardware component, and the means comprised therein for performing the various functions can also be considered structures within the hardware component. Alternatively, or even, the means for performing the various functions can be considered both software modules implementing the method and structures within the hardware component.

[0074] The systems, apparatuses, modules or units illustrated by the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, the present application does not exclude that with the development of computer technology in the future, computers implementing the functions of the above embodiments can be personal computers, laptop computers, vehicle-mounted human-computer interaction devices, cellular phones, camera phones, smart phones, personal digital assistants, media players, navigation devices, electronic mail devices, game consoles, tablet computers, wearable devices, or combinations of any of these devices.

[0075] Although the method operations of the embodiments of the present disclosure are described in a particular, sequential order, one or more of the method operations can be omitted, or the method operations can be performed in an order other than the described order. Additionally, one or more of the method operations can be performed concurrently, or with partial concurrence. Furthermore, one or more of the method operations can be performed by different entities, or over different time periods. The term "including" as used herein is intended to mean "comprising," such that the process, method, article, or apparatus that includes elements in addition to those specified. As used in this description, the term "coupled" means a direct or indirect connection, which can be physical or logical. The term "coupled" does not relate to a direct connection or wiring.

[0076] For the sake of description, the above-described apparatus is described as various modules to describe the functions of the apparatus. Of course, when implementing one or more embodiments of the present disclosure, the functions of the modules can be implemented in one or more software and / or hardware, or the modules implementing the same functions can be combined into a plurality of sub-modules or sub-units. The apparatus embodiments described above are merely illustrative, for example, the division of the units is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.

[0077] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each flow and / or block in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus generate a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions of one or more flows and / or blocks Figure 1 The apparatus that implements the functions specified in one or more flows and / or blocks.

[0078] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.

[0079] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.

[0080] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0081] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory. The memory is an example of computer-readable media.

[0082] Computer-readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage, graphene storage, or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.

[0083] Those skilled in the art will appreciate that the one or more embodiments described herein can be provided as a method, a system or a computer program product. Accordingly, the one or more embodiments described herein can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the one or more embodiments described herein can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable code.

[0084] The one or more embodiments described herein can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform particular tasks or implement particular abstract data types. The one or more embodiments described herein can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including memory storage devices.

[0085] The various embodiments described in this specification can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform particular tasks or implement particular abstract data types. The various embodiments described in this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including memory storage devices.

[0086] The above description is only some embodiments of the one or more embodiments described in this specification and is not intended to limit the one or more embodiments described in this specification. Those skilled in the art can make various modifications and changes to the one or more embodiments described in this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the one or more embodiments described in this specification shall be included in the scope of the claims.

Claims

1. A method for predicting a query, comprising: obtaining a query plan for a target database, the query plan comprising at least a first operator and a second operator; starting the query plan, invoking the second operator through the first operator, and saving a calculation result returned by the second operator to a preset cache space; if a data volume of data saved in the cache space reaches a predetermined target volume, extracting target data of the target volume from the cache space, inputting the target data into a preset prediction model, and obtaining a prediction result; determining a query result of the query plan according to the prediction result.

2. The method of claim 1, wherein, the query plan further comprises a third operator that invokes the first operator; determining the query result of the query plan according to the prediction result comprises: determining a calculation result returned by the first operator to the third operator according to the prediction result, and determining the query result of the query plan according to the calculation result.

3. The method of claim 1, further comprising, after inputting the target data into the preset prediction model, deleting the target data from the cache space.

4. The method of claim 1, wherein, starting the query plan, invoking the second operator through the first operator, and saving a calculation result returned by the second operator to a preset cache space; if a data volume of data saved in the cache space reaches a predetermined target volume, extracting target data of the target volume from the cache space, inputting the target data into a preset prediction model, and obtaining a prediction result, comprises: the first operator invokes the second operator for multiple rounds, and after invoking the second operator in any round, saving a calculation result returned by the second operator in the round to a preset cache space; if a data volume of data saved in the cache space reaches a predetermined target volume, extracting target data of the target volume from the cache space, inputting the target data into the prediction model, and obtaining the prediction result.

5. The method of claim 1, further comprising: after inputting the target data into the prediction model, determining a prediction efficiency value of this time of inputting the prediction model according to runtime information of the prediction model, and determining whether to modify a value of the target volume according to at least the prediction efficiency value of this time of inputting the prediction model.

6. The method of claim 5, wherein, the target volume is determined by increasing an iteration volume on a data volume of a last time of inputting the prediction model; determining whether to modify the value of the target volume according to at least the prediction efficiency value of this time of inputting the prediction model, comprises: if a growth rate of the prediction efficiency value of this time of inputting the prediction model relative to a prediction efficiency value of a last time of inputting the prediction model exceeds a preset threshold, retaining the value of the target volume; if the growth rate of the prediction efficiency value of this time of inputting the prediction model relative to the prediction efficiency value of the last time of inputting the prediction model does not exceed the preset threshold, rolling back the value of the target volume to the data volume of the last time of inputting the prediction model.

7. The method of claim 5, wherein, the runtime information comprises an inference duration of the prediction model and an input data volume of the prediction model, the prediction efficiency value is negatively correlated with the inference duration and positively correlated with the input data volume.

8. The method of claim 1, wherein, obtaining a first query plan, comprises: The structured query statement is obtained, and a first query plan is generated according to the structured query statement.

9. The method of claim 1, wherein, The second operator is used to read data from the database; The calculation result returned by the second operator is saved to the preset cache space, including saving the data read by the second operator from the database to the preset cache space.

10. The method of claim 1, wherein, The target data is input into a preset prediction model, including inputting the target data into the prediction model by calling a Python user-defined function.

11. The method of claim 1, wherein, The calculation result returned by the second operator is saved to the preset cache space, including: If the data amount of the calculation result returned by the second operator is greater than the upper limit of the capacity of the cache space, the capacity of the cache space is expanded, and the calculation result returned by the second operator is saved to the expanded cache space.

12. A prediction query device, the device comprising: an acquisition unit configured to acquire a query plan for a target database, the query plan comprising at least a first operator and a second operator; a calling unit configured to start the query plan, call the second operator through the first operator, and save a calculation result returned by the second operator to a preset cache space; if the data amount of the saved data in the cache space reaches a predetermined target amount, extracting target data of the target amount from the cache space, inputting the target data into a preset prediction model, and obtaining a prediction result; a determination unit configured to determine a query result of the query plan according to the prediction result.

13. A computer-readable storage medium having a computer program stored thereon, when the computer program is executed in a computer, the computer program causes the computer to execute the method of any one of claims 1-11.

14. A computing device comprising a memory and a processor, the memory having executable code stored therein, and the processor, when executing the executable code, implements the method of any one of claims 1-11.