Collaborative query processing method and system based on declarative reasoning, electronic device
By employing a collaborative query processing method based on declarative reasoning, the execution mode of the neural network model is automatically selected and optimized, solving the problem of low efficiency in unstructured data analysis using traditional databases and achieving efficient query optimization.
Patent Information
- Application Number
- CN202310660570.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2043-06-05
AI Technical Summary
Traditional relational databases lack analytical capabilities when processing unstructured data, requiring data analysts to manually select neural network models, leading to low work efficiency.
A collaborative query processing method based on declarative reasoning is adopted. Logical query plans are generated through syntax analysis and algebraic operator substitution. The optimal neural network model is automatically selected by combining category and precision constraints, and its execution method is determined to generate a physical query plan.
It automatically selects the optimal neural network model and execution method, optimizes query processing, reduces the selection overhead for data analysts, and improves query efficiency and execution time.
Smart Images

Figure CN116628136B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of database systems, and particularly relates to a collaborative query processing method and system based on declarative reasoning and an electronic device. BACKGROUND
[0002] Traditional relational database queries lack the ability to analyze unstructured data. Due to the continuous progress in the field of deep learning, people are increasingly interested in extending relational databases to handle advanced analytical queries involving structured and unstructured data using collaborative query processing (CQP) technology.
[0003] Existing CQP methods use user-defined functions (UDFs) to implement deep neural network (NN) models to process unstructured data and use relational operations to process structured data. Database integrates multiple NN models to perform similar but not identical classification tasks, and different models provide different classification performance and accuracy. Therefore, in ad hoc data analysis, data analysts need to manually select appropriate NN models, which is a serious challenge to the work efficiency of data analysts.
[0004] Therefore, it is urgent to provide a collaborative query processing method to provide automatic selection of NN models and determine their execution mode in the database, reduce the overhead of manual selection of NN models, and improve the analysis efficiency of data analysts. SUMMARY
[0005] In view of the deficiencies of the prior art, the application provides a collaborative query processing method and system based on declarative reasoning and an electronic device.
[0006] In a first aspect, the application provides a collaborative query processing method based on declarative reasoning, comprising:
[0007] Step S1, inputting the query text into a syntax analyzer to obtain a syntax analysis tree, and then replacing the nodes and structures in the syntax analysis tree with relational algebra operators to generate a relational algebra expression, and performing equivalent transformation using algebraic laws to obtain a logical query plan;
[0008] Step S2, converting the logical query plan into an intermediate query plan; including: finding the NN model with the minimum cost for the DIF in the logical query plan based on category constraints and accuracy constraints;
[0009] Step S3, converting the intermediate query plan into a physical query plan; including: selecting an implementation mode for each operator in the intermediate query plan by determining the running mode of the NN model implementing the DIF to obtain a physical query plan with the lowest cost.
[0010] The second aspect of the embodiment of the present application provides a high-efficiency collaborative query processing system based on declarative reasoning, comprising:
[0011] The logical query plan acquisition module inputs the query text into the syntax analyzer to obtain a syntax analysis tree, and then replaces nodes and structures in the syntax analysis tree by using relational algebra operators to generate a relational algebra expression, and performs equivalent conversion by using algebraic laws to obtain a logical query plan.
[0012] The intermediate query plan acquisition module converts the logical query plan into an intermediate query plan, and comprises: finding a NN model with the minimum cost for a DIF in the logical query plan based on category constraints and precision constraints.
[0013] The physical query plan acquisition module converts the intermediate query plan into a physical query plan, and comprises: selecting an implementation mode for each operator in the intermediate query plan by determining a running mode of the NN model implementing the DIF to obtain a physical query plan with the minimum cost.
[0014] The third aspect of the embodiment of the present application provides an electronic device comprising one or more processors for implementing the collaborative query processing method based on declarative reasoning described above.
[0015] The fourth aspect of the embodiment of the present application provides a computer readable storage medium having a program stored thereon, and the program is executed by a processor to implement the collaborative query processing method based on declarative reasoning described above.
[0016] Compared with the prior art, the high-efficiency query processing method has the beneficial effects that the DIF in the collaborative query based on declarative reasoning can automatically select a NN model satisfying constraints and a corresponding execution mode, and the physical query is optimized by using optimization rules. The method eliminates the overhead of manual selection of the NN model in the query by the data analyst, improves the efficiency of data analysis, optimizes the implementation mode of the DIF in the collaborative query, and reduces the execution time of the query. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. 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 creative labor.
[0018] Figure 1 The flowchart of the collaborative query processing method based on declarative reasoning provided by the embodiment of the present application is shown in the figure.
[0019] Figure 2 A flowchart of a collaborative query processing system based on declarative inference provided for an embodiment of the present application;
[0020] Figure 3 A schematic diagram of a news database query provided for an embodiment of the present application;
[0021] Figure 4 A schematic diagram of an electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0023] It should be noted that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0024] The present application aims at the deficiencies of the existing UDF-based CQP method, and proposes an efficient collaborative query processing method based on declarative inference. For the collaborative query of simultaneously operating structured data and unstructured data in a database, the present application uses a declarative inference function (DIF), i.e., proposes a new neural network (NN) model integration facility, to replace the UDF for processing unstructured data; a data analyst only needs to specify a classification task, a category constraint and a required classification accuracy, select a NN model combination that meets the category constraint and the accuracy constraint and has a low calculation cost according to an optimization rule, and determine an execution mode of the model to meet the requirements, so as to eliminate the overhead of manually selecting the NN model by the data analyst.
[0025] As shown in Figure 1 The present application provides a collaborative query processing method based on declarative inference, which specifically includes the following steps:
[0026] Step S1, input a query text into a parser (Parser) to obtain a syntax analysis tree, and then replace nodes and structures in the syntax analysis tree by using relational algebra operators to generate a relational algebra expression, and perform equivalent transformation by using algebraic laws to obtain a logical query plan.
[0027] Step S2, convert the logical query plan into an intermediate query plan; including: finding a NN model with the minimum cost for a DIF in the logical query plan based on a category constraint and an accuracy constraint.
[0028] Specifically, finding the NN model for the DIF based on the category constraint and the accuracy constraint specifically includes:
[0029] The selection operator σ in the logical query plan contains the DIF DIFin (·) The category constraint S is specified for the DIF. It needs to be explained that the category constraint is a set of categories, that is, the part of the data in the given range is reserved for the DIF output result, and only the data in the set of the DIF output result will be selected by the selection operator. With the category constraint and the precision constraint given by the DIF, a model set is selected in the model library corresponding to the DIF. This model set needs to cover the category constraint in the condition and meet the precision constraint in the DIF, while having the lowest possible computational cost.
[0030] Further, the cost of the NN model is the sum of the NN model deployment cost, the data transmission cost, and the NN model inference cost.
[0031] (A) NN model selection for a single DIF.
[0032] Without considering the model order, the problem of finding the model set M' is similar to the set cover problem. For this problem, the time complexity of considering all model combinations and selecting the optimal set is exponential, that is, O(2 n ) In the case of a relatively small number of models, all models related to the L inner categories can be pre-selected, and all their combinations can be compared to obtain the optimal model set.
[0033] For the scenario of a large number of models and large category constraints, a set bundle search algorithm is used to find the model set. Given the size of the set bundle bs. First, initialize the set bundle with the models, category set, and cost. In each search stage, based on each search path in the set bundle, calculate the cost of introducing an unconsidered model. The cost is calculated as follows:
[0034]
[0035] That is, the ratio of the cost of the model to the number of unconsidered categories covered by the model, which reflects the value of selecting the model. Sort the costs from low to high to facilitate the selection of the top bs models as candidate models for the corresponding path, thereby constructing bs new candidate paths. Since there are bs search paths in the set bundle, each path has bs corresponding candidate paths, so a total of bs×bs candidate paths are obtained. Sort these candidate paths by cost from low to high, and select the top bs as the new set bundle, and repeat the process. Until there is a search path (model set) in the set bundle that can meet the user's category constraint. At this time, the lowest running cost in different search paths can be returned as the search result.
[0036] (B) NN model selection for two DIFs.
[0037] On the basis of the single DIF model selection method, for the scenario of multiple DIFs, the influence between different DIFs and their corresponding category constraints needs to be considered. It is assumed that there are two DIFs A and B in the user query. The category constraints corresponding to A and B are L A and L B , and the classification cost of A is lower than that of B. A subset l B in L B is considered. If the coincidence degree of the data belonging to L A and the data belonging to l B is lower than a preset threshold after classification by A and B, the part of l B may be omitted in B without affecting the accuracy of the entire query. Thus, the category constraint corresponding to B is reduced from L B to L B -l B . When the model selection is performed on B, fewer models can be selected.
[0038] (C) NN model selection for multiple DIFs.
[0039] On the basis of two DIFs, the case of multiple DIFs is considered. First, the model combination corresponding to each DIF and the expected calculation cost are obtained by using the single DIF model selection method. According to the expected cost from low to high, the DIFs can be arranged as Q = {q1,..., m}. The corresponding category constraints are L1,..., m . Then, the category constraint overlap degree corresponding to each pair of DIFs: Q i and Q j (i < j) is investigated. Since Q i arranged in the front has a lower calculation cost, Q i needs to process more data as much as possible. When the overlap degree of the category l in L j corresponding to the data in L i is below a given threshold, it means that l can be omitted in Q j . Finally, the category constraint of Q j is reduced.
[0040] Step S3, converting the intermediate query plan into a physical query plan; including: selecting an implementation mode for each operator in the intermediate query plan by determining the running mode of the NN model for implementing the DIF, to obtain a physical query plan with the lowest cost.
[0041] Since the cost of physical implementation of different operators in the intermediate query plan is different, an implementation manner needs to be selected for each operator in the intermediate query plan to obtain a physical query plan with the lowest cost. The selection of the implementation manner for each operator in the intermediate query plan includes determining a running manner of a model implementing the DIF.
[0042] Further, the process of determining the running manner of the model implementing the DIF includes the following steps:
[0043] Step S301, determining an execution order of the model implementing the DIF.
[0044] For the NN model combination M corresponding to a single DIF, a manner with lower cost in parallel / serial execution is selected for execution. The execution of the model can be divided into parallel and serial two manners. For the parallel execution manner, different models need to infer the same full data, but these models can run simultaneously on the same device or different devices. Assuming that the same amount of data B is accepted, the target is as follows:
[0045]
[0046] For the serial execution manner, the execution order of the models in M' needs to be calculated. Thus, the models can be executed in turn according to the calculated order. In the execution details, the previous model completes the inference work on its input data and obtains the output category. The output category is compared with the constraint category set L q , so that the data meeting the requirements can be removed to reduce the amount of data to be processed by the next model. The query time of this running manner is the sum of the model time of sequential execution. Assuming that the amount of data accepted by each model m is b m , the target is as follows:
[0047]
[0048] In the case of the same device d and the same input data batch amount b, the running cost Cost d (m, b) of each model m is calculated. The models are arranged in order from low to high cost and examined one by one. When the category set of the model contains an unconsidered category, the model is added to the model set. The model set when the category constraint L is met is the optimal model set for parallel execution. After comparing the optimal model sets of the serial and parallel manners respectively, it can be determined which scheme to select.
[0049] On the basis of the execution order of a single DIF model, the execution order of models in a query containing multiple DIFs is calculated. Specifically, all DIFs are divided into multiple segments. The DIFs in the same segment are executed in parallel, and the models of DIFs between segments are executed in series. Consider a DIF set Q = {q1,..., k} and the corresponding selectivity ratios S = {s1,..., k}. The selectivity ratio represents the filtering degree of the predicate in which the DIF is located. When the input data with a data volume of B is calculated and filtered by q i , the data volume obtained is b i , and s i = b i / . Corresponding to the data volume B, the model combination has a respective calculation cost C = {c1,..., k}. After the previous serial task filtering, the data volume will be smaller. At this time, the calculation cost of the subsequent task will also be correspondingly smaller. Before introducing the optimization method, a theorem is introduced:
[0050] The different DIFs are arranged in order of cost from small to large, and the cost is calculated as follows:
[0051]
[0052] At this time, the estimated calculation cost of serial execution is the minimum value, as shown in the following formula:
[0053]
[0054] According to this theorem, the execution mode and order arrangement between DIFs are adjusted. First, the different DIFs are sorted in order of the value of s from low to high. Starting from the initial state of all tasks being executed in parallel, the sequence is recursively split. For the sorted sequence q1,..., n , each model in the sequence is taken as a dividing point, and the task sequence is divided into an upper half and a lower half. For the upper half, the same algorithm is used to obtain its split point, total calculation cost, and data filtering ratio. The filtering ratio can be used to calculate the input data volume of the lower half. Based on the calculated input data volume, the lower half is also calculated to obtain the split point and the calculation cost. The sum of the calculation costs of the two ends is the total cost after the division. It is compared with the existing minimum cost to determine whether to split. After the loop ends, the segment with the lowest cost is returned as the result.
[0055] Step S302, determine the device for implementing the model deployment of the DIF. Different devices will affect the time of deploying the model on the device, transmitting the input data to the device, and model inference.
[0056] For a single model m, the cost model can be used to calculate the cost of binding it to all devices. This makes it easy to select the device that can accommodate m and has the lowest cost to let m perform the inference task.
[0057] Let the owned computing devices be denoted as D = {d} j |j=1,...,}. For each device d in D, there is a corresponding remaining capacity calculation method: Remain. d (m,M in That is, M already exists on device d. in When these models are deployed, the remaining capacity after introducing m is considered. From a storage capacity perspective, the size of model m itself is considered. m It should be less than the device's remaining storage space. This is to ensure successful model deployment. From a computing power perspective, after a new model is added, it should first be allocated to the existing model M. in The computational power fluctuation should not be too large, and the computational power allocated to the new model m should be close to that of a separately deployed model. This can minimize the mutual interference between models during inference on this device. Considering both of these aspects, only in Remaining... d (m,M in When ) ≥ 0, the new model m can be deployed to device d. The model combinations corresponding to the two execution methods are as follows: serial model combination (arranged in order). Combining parallel models (order independent) The following section will analyze the device binding of these two execution methods.
[0058] For serial combination M s In general, the models are executed sequentially. Therefore, the device selection for each model is relatively independent. A set of available devices D is provided for each model. and the corresponding batch size Then, using the cost model mentioned above, this model can be calculated for each device d. j The cost This allows us to compare the costs of the same model on different devices to decide which device to choose.
[0059] For parallel combination M pFor a model, parallel execution is possible. Therefore, the device selection for a single model affects the device selection for the remaining models. First, calculate the estimated computational cost of each model on each device. Then, sort the devices corresponding to each model in ascending order of cost. Since each model has a device with the lowest cost, the models can be sorted in descending order of the lowest cost. Starting from the model with the highest computational cost, deploy this model on the device with the lowest corresponding cost. Process the subsequent models in order. Specifically, check them in the order of the models' devices. When the device is sufficient to accommodate the model, deploy the model to this device.
[0060] As Figure 2 shown, an embodiment of the present invention also provides an efficient collaborative query processing system based on declarative reasoning for implementing the above-mentioned collaborative query processing method based on declarative reasoning. The system includes:
[0061] A logical query plan acquisition module that inputs the query text into a syntax analyzer to obtain a syntax analysis tree, and then uses relational algebra operators to replace the nodes and structures in the syntax analysis tree to generate a relational algebra expression, and uses algebraic laws for equivalent transformation to obtain a logical query plan;
[0062] An intermediate query plan acquisition module that converts the logical query plan into an intermediate query plan; including: finding the NN model with the lowest cost for the DIF in the logical query plan based on category constraints and accuracy constraints;
[0063] A physical query plan acquisition module that converts the intermediate query plan into a physical query plan; including: selecting an implementation method for each operator in the intermediate query plan by determining the running mode of the NN model that implements the DIF to obtain the physical query plan with the lowest cost.
[0064] Embodiment 1
[0065] For Figure 3 the news database in, the following query is proposed:
[0066] SELECT agency FROM news WHERE text_classifier(news.text,80%)IN(’Finance’,’Banking’,’Technology’,’Education’,’Entertainment’,’Home’);
[0067] The process of query processing is as follows:
[0068] Step S1, input the query text into a syntax analyzer to obtain a syntax analysis tree, and then use relational algebra operators to replace the nodes and structures in the syntax analysis tree to generate a relational algebra expression, and use algebraic laws for equivalent transformation to obtain a logical query plan.
[0069] Step S2, converting the logical query plan into an intermediate query plan; including: finding the NN model with the minimum cost for the DIF in the logical query plan based on the category constraint and the precision constraint.
[0070] Step S201, calculating the cost of the model in the model library corresponding to the DIF. The model library corresponding to the DIF in this embodiment is shown in Table 1. The cost of different models is calculated by setting the same deployed device (such as GPU) and the input data volume (the size of the news table). The cost column in Table 1 is the calculated cost.
[0071] Step S202, finding the NN model for the DIF using the category constraint, the precision constraint and the model cost. According to the logical query plan, the category constraint of the DIF is L=(‘finance’, ‘finance’, ‘technology’, ‘education’, ‘entertainment’, ‘home’), the precision constraint is 80%, and the model cost is shown in Table 1.
[0072] Table 1: Example of model library table
[0073]
[0074]
[0075] Based on the category constraint, the model m6 does not contain the category in the category constraint, so the model is not considered. Based on the precision constraint, the model m7 contains the category required by the query, but the accuracy of the model in the category “home” is 0.75<0.8, so the model is not considered. Among the remaining models, select the model combination that satisfies the category constraint. For example, the model combination m1, m2, m5 and the combination m1, m3, m4 can satisfy the category constraint. Use the bundle search algorithm to find the model set that satisfies the constraint and has low cost. Take a bundle with a size of 2 as an example.
[0076] The cost of each model in the first round is calculated, which is 5, 10, 8.33, 12.5, and 20 respectively. Take the two models with the lowest cost to form two paths of the bundle, {m1} and {m2}.
[0077] Based on the two paths, the cost of each model in the second round is calculated. For the path {m1}, the cost of m2-m5 is calculated, which is 10, 12.5, 12.5, 20 respectively. The two models with the lowest cost are combined to form two alternative paths {m1, m2} and {m1, m3}. For the path {m2}, the cost of m1 and m3-m5 is calculated, which is 5, 12.5, 25, 20 respectively. The two models with the lowest cost are combined to form two alternative paths {m2, m1} and {m2, m3}. All alternative paths are centralized and de-duplicated, for example, {m1, m2} and {m2, m1} are the same model set and can be combined. The total cost of different alternative paths is calculated, that is, {m1, m2} is 30, {m1, m3} is 35, and {m2, m3} is 45. Since the bundle size is 2, the two alternative paths with the lowest total cost are retained to form the two paths of the bundle, that is, {m1, m2} and {m1, m3}.
[0078] In the calculation of the third round, for the path {m1, m2}, the cost of m3-m5 is calculated, which is 25, 25, 20 respectively. The two models with the lowest cost are combined to form two alternative paths {m1, m2, m5} and {m1, m2, m3}. For the path {m1, m3}, the cost of m2, m4, m5 is calculated, which is 20, 12.5, 40 respectively. The two models with the lowest cost are combined to form two alternative paths {m1, m3, m4} and {m1, m3, m2}. After merging and de-duplicating, three paths are left: {m1, m2, m5}, {m1, m2, m3}, {m1, m3, m4}, with total costs of 70, 55, and 60 respectively. Since the path {m1, m3, m4} can meet the category constraint and has the lowest total cost, {m1, m3, m4} is finally selected to implement DIF.
[0079] Step S3, converting the intermediate query plan into a physical query plan; including: selecting an implementation for each operator in the intermediate query plan by determining the running mode of the NN model that implements DIF, to obtain a physical query plan with the lowest cost.
[0080] Step S301, determining the execution order of the models. The cost of model parallel execution is 25, that is, the cost of the model m3 with the highest cost in the model set {m1, m3, m4}. When the models are executed in series, they are executed in the order of m1→m3→m4. The cost is 10+(1-0.2)*25+(1-0.2)*(1-0.2)*25=46. Since 25<46, the models are executed in parallel.
[0081] Step S302, determine the deployment device of the model. The following table 2 shows the provided devices. Since the model is executed in parallel, deploying a more costly model on a device with faster computing rate can save more time. As can be known from table 1 and table 2, model m4 can be deployed on device d3. m3 and m1 can be deployed on d2 at the same time. At this time, the cost of running all models is
[0082] Table 2: Device example table
[0083] Device Storage capacity Computing rate (flop rate) d1 10 1 [d2] 7 3 [d3] 3 5
[0084] Correspondingly, the present application also provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned efficient cooperative query processing method based on declarative reasoning. As Figure 4 shown, a hardware structure diagram of any data processing capable device provided by the efficient cooperative query processing method based on declarative reasoning of the embodiment of the present application, in addition to Figure 4 the processor, the memory and the network interface, any data processing capable device in which the device is generally according to the actual function of the data processing capable device, can also include other hardware, and this will not be described again.
[0085] Correspondingly, the present application also provides a computer readable storage medium having computer instructions stored thereon, which are executed by a processor to implement the above-mentioned efficient cooperative query processing method based on declarative reasoning. The computer readable storage medium can be an internal storage unit of any data processing capable device, such as a hard disk or a memory. The computer readable storage medium can also be an external storage device, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. Further, the computer readable storage medium can include both the internal storage unit of any data processing capable device and the external storage device. The computer readable storage medium is used to store the computer program and other programs and data required by the data processing capable device, and can also be used to temporarily store data that has been output or will be output.
[0086] The above examples are only used for illustrating the design idea and characteristics of the present application, and the purpose is to enable the person skilled in the art to understand the present application and to implement it, and the protection scope of the present application is not limited to the above examples. Therefore, any equivalent changes or modifications made according to the disclosed principles and design ideas of the present application are within the protection scope of the present application.
Claims
1. A method for collaborative query processing based on declarative reasoning, characterized in that, Comprise: Step S1, input the query text into the syntax analyzer to obtain a syntax analysis tree, and then replace the nodes and structures in the syntax analysis tree with relational algebra operators to generate a relational algebra expression, and perform equivalent transformation using algebraic laws to obtain a logical query plan; Step S2, convert the logical query plan into an intermediate query plan; including: finding the NN model with the minimum cost for the DIF in the logical query plan based on category constraints and precision constraints; wherein the NN model is a neural network model, and the DIF is a declarative inference function; Step S3, convert the intermediate query plan into a physical query plan; including: selecting an implementation for each operator in the intermediate query plan by determining the running mode of the NN model implementing the DIF to obtain a physical query plan with the lowest cost; Wherein, determining the running mode of the model implementing the DIF comprises: Determine the running mode of the model implementing the DIF; including: for a single DIF corresponding NN model combination, select the lower cost mode in parallel / serial execution mode to execute; for a plurality of DIF corresponding NN model combination, divide all DIFs into multiple segments; the models corresponding to the DIFs in the same segment are executed in parallel, and the models of the DIFs between segments are executed in series; Determine the device for deploying the model implementing the DIF; including: for a single NN model, calculate the cost of binding the NN model to all devices, and select the device that can accommodate the NN model and has the minimum cost; for a serial NN model combination, there is a set of available devices, calculate the cost of each NN model in the serial NN model combination on each device, and select the device that can accommodate the NN model and has the minimum cost; for a parallel NN model combination, calculate the cost of each NN model on each corresponding device, and sort, deploy the NN model with the highest cost on the device with the lowest cost.
2. The method of claim 1, wherein the method further comprises: The cost of the NN model is the sum of the NN model deployment cost, data transmission cost, and NN model inference cost. 3.The method of claim 1, wherein, For a single DIF, selecting a NN model comprises: Select the NN model that covers all category constraints, compare the costs of all NN model combinations, and select the optimal NN model set; Or, Use a beam search algorithm to find the NN model set.
4. The method of claim 3, wherein the method further comprises: Using a beam search algorithm to find the NN model set comprises: Record the size of the beam as bs; Initialize the NN model, category set and cost owned by the beam; In each search stage, based on each search path in the beam, calculate the cost of introducing an unconsidered NN model; the cost of the unconsidered NN model is the ratio of the cost of the NN model to the number of unconsidered categories covered by the model; Sort by cost from low to high to facilitate the selection of the top bs NN models to join the candidate models of the corresponding path, thereby constructing bs new candidate paths; There are bs search paths in the bundle, each path has bs corresponding candidate paths, and the number of candidate paths is candidate paths; sort all candidate paths by cost from low to high, and select the first bs as the new bundle, and so on, until the bundle has a search path that meets the category constraint; the model set with the lowest running cost in different search paths is taken as the search result.
5. The method of claim 1, wherein the method further comprises: For multiple DIFs, selecting a NN model comprises: Get the model combination corresponding to each DIF and calculate the expected cost; The DIFs are arranged from low to high according to expected cost The corresponding category constraint is ; Examine each pair of DIF and Category constraint overlap, When category constraints Categories Corresponding data and category constraints When the overlap is less than a preset threshold, the category will be... exist The middle part is omitted to reduce the size. Category constraints.
6. The method of claim 1, wherein the method further comprises: For a serial NN model combination, there is a set of available devices, calculate the cost of each NN model in the serial NN model combination on each device, and select the device that can accommodate the NN model and has the minimum cost; For parallel execution, different NN models need to make inference on the same full data; For the serial execution manner, the execution order of the NN models in the NN model combination is required; a previous NN model completes inference on its input data and obtains an output category; the output category is compared with a constraint category set so that the data meeting the requirement can be removed to reduce the amount of data to be processed by the next NN model, and the query time is the sum of the model times of the sequential execution. In comparison, the data meeting the requirement can be removed to reduce the amount of data to be processed by the next NN model, and the query time is the sum of the model times of the sequential execution. In the case of the same device and the same input data, the running cost of each NN model is calculated; the NN models are arranged from low to high according to the running cost, and it is checked whether the NN models meet the category constraint; the model set meeting the category constraint is taken as the optimal model set; The parallel or serial execution mode is determined by comparing the optimal model sets corresponding to the serial and parallel execution modes respectively.
7. An efficient collaborative query processing system based on declarative reasoning, characterized in that, The system for implementing the collaborative query processing method based on declarative reasoning in any one of claims 1-6 comprises: A logical query plan acquisition module, which inputs the query text into a syntax analyzer to obtain a syntax analysis tree, and then replaces nodes and structures in the syntax analysis tree with relational algebra operators to generate a relational algebra expression, and performs equivalent transformation by using algebraic laws to obtain a logical query plan; An intermediate query plan acquisition module, which converts the logical query plan into an intermediate query plan; including: finding the NN model with the minimum cost for the DIF in the logical query plan based on the category constraint and the precision constraint; A physical query plan acquisition module, which converts the intermediate query plan into a physical query plan; including: selecting an implementation mode for each operator in the intermediate query plan by determining the running mode of the NN model implementing the DIF to obtain a physical query plan with the lowest cost.
8. An electronic device, comprising: The system comprises one or more processors for implementing the collaborative query processing method based on declarative reasoning in any one of claims 1-6.
9. A computer-readable storage medium having stored thereon a program, characterized in that, The program is executed by the processor to implement the collaborative query processing method based on declarative reasoning in any one of claims 1-6.