Cardinality estimation and approximate query processing method and apparatus based on sum-product network model

By constructing a sum-product network model of fused bitmaps, the error problem caused by the neglect of attribute correlation in existing technologies is solved, the accuracy and efficiency of cardinality estimation and approximate query processing are improved, user queries and dataset changes are adapted, and the accuracy of query optimization results and user experience are enhanced.

CN116756291BActive Publication Date: 2025-12-02FUDAN UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310818649.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-04
Publication Date
2025-12-02
Estimated Expiration
2043-07-04

AI Technical Summary

Technical Problem

Existing data-driven sum-product network models ignore the correlation between attributes in cardinality estimation and approximate query processing, resulting in a large error between the inference result and the accurate result, which reduces their value in query optimization and approximate query processing scenarios.

Method used

A product network model with fused bitmaps is constructed. This model stores numerical values ​​and row number bitmaps in the leaf nodes, merges the row number bitmaps according to accuracy requirements, allocates them based on the accuracy requirements of the product nodes, determines the calculation method based on the query request, and uses the row number bitmaps or numerical proportions to perform intersection or multiplication operations to obtain the query results.

Benefits of technology

It improves the accuracy of cardinality estimation and approximate query processing, reduces inference overhead, enhances the accuracy of query optimization results and user experience, and adapts to changes in user queries and datasets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116756291B_ABST
    Figure CN116756291B_ABST
Patent Text Reader

Abstract

This invention provides a cardinality estimation and approximate query processing method and apparatus based on a product network model. In the model construction step, the row number bitmaps of leaf nodes are merged based on accuracy requirements, thereby constructing a product network model with a fused bitmap that achieves high accuracy and minimizes inference overhead. In the query processing step, the calculation method of the leaf nodes is determined based on given rules related to accuracy requirements and the query requests decomposed down to the lowest-level product nodes, thus achieving optimal inference accuracy and cost. The method and apparatus of this invention improve the accuracy of cardinality estimation in query optimization, thereby helping to improve query optimization results, reduce query execution overhead, and assist data analysts in real-time analysis of large-scale datasets. By incorporating additional data distribution characteristics, the accuracy of approximate query processing on SPJA queries is improved, thereby enhancing user experience and increasing the effectiveness of decision-making.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data analysis technology, specifically relating to a cardinality estimation and approximate query processing method and apparatus based on a sum-product network model. Background Technology

[0002] Currently, with the rapid development of artificial intelligence technology, AI models are being applied more and more widely in the database field. For example, in query optimization, models are used to estimate the cardinality of queries, and in approximate query processing, models are used to replace the original data and samples to answer user queries. Existing models are mainly divided into two types: query-driven models and data-driven models. Compared to data-driven models, query-driven models have the following disadvantages: 1) It is difficult to collect sufficient training data to train the model; 2) When the user's query or the dataset changes, it is necessary to recollect training data.

[0003] To address this, researchers have proposed a series of data-driven models. Benjamin Hilprecht et al. proposed DeepDB, which constructs a sum-product network model based on the distribution characteristics and correlations of the original data and applies it to cardinality estimation and approximate query processing scenarios to answer user queries, adapting to changes in user queries and datasets. RongZhu et al. proposed FLAT, which stores highly correlated attributes in the same leaf node when constructing the sum-product network model, using multi-dimensional histograms in the leaf node to record statistical information of multiple attributes, i.e., the numerical value and proportion of each attribute. However, because these methods assume that the attributes stored in different leaf nodes are uncorrelated during inference, they ignore the potential correlation between these attributes, leading to significant errors between the inferred results and the accurate results for some queries, reducing their value in query optimization and approximate query processing scenarios. Therefore, improving the accuracy of such data-driven models is a crucial problem that urgently needs to be solved. Summary of the Invention

[0004] This invention addresses the aforementioned problems and aims to provide a cardinality estimation and approximate query processing apparatus and method that improves inference accuracy in scenarios such as cardinality estimation and approximate query processing. The invention employs the following technical solution:

[0005] This invention provides a cardinality estimation and approximate query processing method based on a sum-product network model, characterized by the following steps: Model construction step: Constructing a sum-product network model of a fused bitmap, wherein the model includes summation nodes, product nodes, and multiple leaf nodes. The leaf nodes store multiple sets of values, the corresponding numerical proportions, and row number bitmaps. The row number bitmaps contain the row numbers of the data tuples corresponding to the values. When constructing the model, the row number bitmaps stored in the leaf nodes are merged according to predetermined accuracy requirements. Query processing step: Upon receiving a query request, the sum-product network model of the fused bitmap is executed to infer the query result. Specifically, it is determined whether the query request decomposed down to the lowest level of the product node satisfies predetermined rules related to the accuracy requirements. If yes, the row number bitmaps stored in the leaf nodes are used for intersection operations; if no, the numerical proportions stored in the leaf nodes are used for multiplication operations to obtain the query result.

[0006] The cardinality estimation and approximate query processing method based on the sum-product network model provided by this invention may also have the following technical features, wherein the model construction step includes the following sub-steps: in the trained sum-product network model, the accuracy requirement is allocated from top to bottom; for each leaf node, the error between its stored value and the different values ​​of other leaf nodes is calculated, and the row number bitmap corresponding to the value whose maximum error is less than the accuracy requirement on the leaf node is merged with the row number bitmap of the subsequent values, thereby obtaining the sum-product network model of the fused bitmap.

[0007] The cardinality estimation and approximate query processing method based on the sum-product network model provided by this invention may also have the following technical feature: when allocating the accuracy requirement, the accuracy requirement is evenly distributed among the product nodes according to the number of numerical attributes contained in each child node of the product node. In the formula, β i It is the product node L i The accuracy requirement on n j It is the product node L i The number of numeric attributes contained in the j-th child node, β j It is the node L after allocation i The accuracy requirement for the j-th child node.

[0008] The cardinality estimation and approximate query processing method based on the sum-product network model provided by this invention may also have the following technical features, wherein merging the row number bitmaps of the leaf nodes based on the accuracy requirement includes the following steps: In a leaf node, for each value, calculate the product value by multiplying the proportion of the value used by that value by the proportions of different values ​​in other leaf nodes; in the leaf node, for each value, calculate the intersection value by intersecting the row number bitmaps corresponding to that value with the row number bitmaps corresponding to different values ​​in other leaf nodes; for each value in the leaf node, calculate multiple product values ​​and sums. The error between multiple intersecting values; for each value in the leaf node, if the maximum error among the corresponding errors is less than the accuracy requirement of the leaf node, then the row number bitmap corresponding to the value is merged with the row number bitmap of the subsequent values, until the sum of the errors of the values ​​in the leaf node is greater than the accuracy requirement of the leaf node, then merging stops. In the leaf node after bitmap merging, the storage structure is <{value}, row number bitmap of the data tuple corresponding to {value}>, where {value} is the value of the merged values, and the row number bitmap of the data tuple corresponding to {value} is the bitmap obtained after merging the row number bitmaps corresponding to these values.

[0009] The cardinality estimation and approximate query processing method based on the sum-product network model provided by this invention may also have the following technical features, wherein the model construction step includes the following sub-steps: upon receiving the query request, determining whether the query predicate of the query request contains only one attribute; if it is determined to contain only one attribute, using the numerical proportion stored in the leaf node to answer the query request; if it is determined to contain multiple attributes, further determining whether the intersection size of the attributes contained in the bottom-level product node and the attributes involved in the query predicate is less than or equal to 1; if it is determined that the intersection size is less than or equal to 1, using the numerical proportion stored in the leaf node to answer the query; if it is determined that the intersection size is greater than 1, processing all the leaf nodes... If the range of values ​​corresponding to the merged row number bitmap on a leaf node is included in the query predicate, then all other leaf nodes are multiplied with that leaf node using the numerical ratio to obtain the query result. If the range of values ​​corresponding to the merged row number bitmap on a leaf node is fully included in the query predicate, then it is determined whether the row number bitmaps in the other leaf nodes are fully included in the query predicate. If they are fully included, all other leaf nodes are intersected with that leaf node using the row number bitmap to obtain the query result. If they are not included, all other leaf nodes are multiplied with that leaf node using the numerical ratio to obtain the query result.

[0010] This invention provides a cardinality estimation and approximate query processing device based on a sum-product network model. The device comprises: a model builder for constructing a sum-product network model of a fused bitmap, wherein the model includes summation nodes, product nodes, and multiple leaf nodes. Each leaf node stores multiple sets of values, the corresponding numerical proportions, and a row number bitmap. The row number bitmap contains the row number of the data tuple corresponding to the value. During model construction, the row number bitmaps stored in the leaf nodes are merged according to predetermined accuracy requirements. The device also includes a model executor that, upon receiving a query request, executes the sum-product network model of the fused bitmap to perform inference and obtain a query result. Specifically, it determines whether the query request decomposed down to the lowest-level product node satisfies predetermined rules related to the accuracy requirements. If yes, it performs an intersection operation using the row number bitmap stored in the leaf node; if no, it performs a multiplication operation using the numerical proportions stored in the leaf node to obtain the query result.

[0011] Invention Function and Effect

[0012] According to the present invention, a cardinality estimation and approximate query processing method and apparatus based on a product network model includes a model building step and a query processing step. In the model building step, a product network model with fused bitmaps is constructed. The leaf nodes of this model store numerical values ​​and corresponding row number bitmaps. The row number bitmaps are merged based on accuracy requirements to construct a model with high accuracy and minimized inference overhead. In the query processing step, the calculation method of the leaf nodes is determined based on given rules related to accuracy requirements and the query requests decomposed to the lowest-level product nodes, thus achieving optimal inference accuracy and cost. As described above, the method and apparatus of the present invention can improve the accuracy of cardinality estimation in query optimization, thereby helping to improve query optimization results and reduce the overhead required for query execution. Using the method and apparatus of the present invention, data analysts can perform real-time analysis of large-scale datasets, improving the accuracy of approximate query processing on SPJA queries by fusing additional data distribution characteristics, thereby enhancing user experience and improving decision-making effectiveness. Attached Figure Description

[0013] Figure 1 This is a schematic diagram of the architecture of the cardinality estimation and approximate query processing device in an embodiment of the present invention;

[0014] Figure 2 This is a schematic diagram illustrating the process of model training and user query execution in an embodiment of the present invention;

[0015] Figure 3 This is a flowchart of the cardinality estimation and approximate query processing method in an embodiment of the present invention;

[0016] Figure 4 This is a flowchart of the model construction steps in an embodiment of the present invention;

[0017] Figure 5 This is a flowchart of fusing bitmaps for numerical leaf nodes in an embodiment of the present invention;

[0018] Figure 6 This is a schematic diagram of the leaf node structure in the sum-product network model of the fused bitmap in an embodiment of the present invention;

[0019] Figure 7 This is a flowchart of the query processing steps in an embodiment of the present invention;

[0020] Figure 8 This is a comparison chart of the query accuracy of the three models in the comparative example of this invention on the Flights dataset;

[0021] Figure 9 This is a comparison chart of query latency for the three models in the comparative example of this invention on the Flights dataset. Detailed Implementation

[0022] To make the technical means, creative features, objectives and effects of the present invention easy to understand, the cardinality estimation and approximate query processing method and apparatus of the present invention will be specifically described below in conjunction with embodiments and accompanying drawings.

[0023] <Example>

[0024] This embodiment provides a cardinality estimation and approximate query processing apparatus and method based on an improved sum-product network model. Its main application scenarios are query optimization in databases and approximate query processing in interactive data exploration.

[0025] Figure 1 This is a schematic diagram of the architecture of the cardinality estimation and approximate query processing device in this embodiment.

[0026] like Figure 1 As shown, the cardinality estimation and approximate query processing device includes a model builder, a fused bitmap sum-product network model, and a model executor. Furthermore, this device communicates with a database and can retrieve underlying data from the database.

[0027] The fused bitmap sum-product network model is obtained by fusing bitmaps based on the existing sum-product network model. For existing sum-product network models, please refer to the literature "DeepDB: Learn from Data, not from Queries!" (HILPRECHT B, SCHMIDT A, KULESSAM et al., Very Large DataBase Endowment, VLDB, 2020, 13(7):992-1005). In short, the sum-product network model includes summation nodes for summation operations, product nodes for product operations, and multiple leaf nodes. The summation nodes and product nodes are the parent nodes of the leaf nodes. In this embodiment, the sum-product network model is expanded in each leaf node to store the numerical value and its corresponding row number, in order to calculate approximate results for SPJA queries and to perform cardinality estimation for such queries in query optimization. For ease of description, the sum-product network model of this embodiment will be referred to as the improved sum-product network model.

[0028] Specifically, in each leaf node, for all the values ​​of the data tuple attributes stored in that leaf node, a bitmap (hereinafter referred to as the row number bitmap) is constructed with each value as the key and the row number (i.e., the unique value) of the data tuple corresponding to the value as the value. The above information is stored using a key-value structure such as <value, row number bitmap of the data tuple corresponding to the value>.

[0029] The model builder constructs a sum-product network model of fused bitmaps based on predetermined accuracy requirements. Specifically, during model construction, the row number bitmaps stored in the leaf nodes are merged according to the given accuracy requirements to construct a sum-product network model that meets the accuracy requirements and minimizes inference overhead.

[0030] The model executor is used to execute the model for inference. During model execution, it determines the computation method in the leaf nodes based on the query requests decomposed down to the lowest-level product node (i.e., the parent node of the leaf node) to achieve optimal inference accuracy and cost. When using the fused bitmap sum-product network model to infer query results, the model executor judges the query requests decomposed down to the lowest-level product node based on predetermined rules. If the query request satisfies the rules, it performs an intersection operation using the row number bitmap stored in the leaf node to obtain the inference result; otherwise, it performs a multiplication operation using the numerical proportions stored in the leaf node to obtain the inference result.

[0031] Figure 2 This is a schematic diagram illustrating the process of model training and user query execution in this embodiment.

[0032] Figure 3 This is a flowchart of the cardinality estimation and approximate query processing method in this embodiment.

[0033] like Figure 2 and Figure 3 As shown, based on the aforementioned cardinality estimation and approximate query processing apparatus, the cardinality estimation and approximate query processing method includes the following steps:

[0034] Model building step S1: The model builder constructs a sum-product network model of the fused bitmap based on the given accuracy requirements.

[0035] Query processing step S2: Upon receiving a query request, the model executor executes the sum-product network model of the fused bitmap for inference to obtain the query result.

[0036] The steps described above will be explained in detail below.

[0037] Model building step S1: The model builder constructs a sum-product network model of the fused bitmap based on the given accuracy requirements.

[0038] Figure 4 This is a flowchart of the model construction steps in this embodiment.

[0039] like Figure 4 As shown, model construction step S1 specifically includes the following sub-steps:

[0040] Step S1-1: Train the improved sum-product network model using training data to obtain the trained model.

[0041] The structure of the improved sum-product network model is as described above. The training method of this model is similar to that in the existing technology, so it will not be described again.

[0042] Step S1-2: In the trained improved sum-product network model, allocate the predetermined accuracy requirements from top to bottom.

[0043] In particular, no additional processing is required for accuracy at the summation node.

[0044] Within the product node, the accuracy requirement is evenly distributed based on the number of numerical attributes contained in each of its child nodes, as shown in the following formula:

[0045]

[0046] In the formula, β i It is the product node L i The accuracy requirement on n j It is the product node L i The number of numeric attributes contained in the j-th child node, β j It is the product node L after allocation i The accuracy requirement for the j-th child node.

[0047] Step S1-3: For each numerical leaf node L m The algorithm calculates the error between the stored value and the different values ​​of other leaf nodes, and merges the row number bitmap corresponding to the value with the largest error less than the accuracy requirement of the leaf node with the row number bitmap of the subsequent values ​​to obtain the sum-product network model of the fused bitmap.

[0048] Figure 5 This is a flowchart of the bitmap fusion process for numerical leaf nodes in this embodiment.

[0049] like Figure 5 As shown, steps S1-3 specifically include the following sub-steps:

[0050] Step S1-3-1: In a numerical leaf node L m In the process, for each value, the proportion of that value used is calculated relative to other leaf nodes L. k The result of multiplying the proportions of different values ​​is called the product value, which is considered an approximate result.

[0051] The numerical ratio is the number of data tuples corresponding to a single value in the leaf node divided by the number of data tuples contained in the leaf node. It is also the statistical information stored for inference in the existing sum-product network model.

[0052] Step S1-3-2: In the numerical leaf node L m In the process, for each value, the corresponding row number bitmap and other leaf nodes L are calculated. k The result of intersecting the row number bitmaps corresponding to different values ​​is denoted as the intersection value, and this intersection value is considered the accurate result.

[0053] Step S1-3-3: For the numerical leaf node L m For each value in the array, calculate the error between multiple product values ​​and multiple intersection values, that is, calculate the error between the calculation result of each value using the row number bitmap and the calculation result using the value scale.

[0054] Step S1-3-4: For the numerical leaf node L m For each value in the list, if the maximum error calculated between that value and the different values ​​of other leaf nodes is less than that of the leaf node L, then... m The accuracy requirement β m Then, consider merging the row number bitmap corresponding to the current value with the row number bitmaps of subsequent values ​​(values ​​stored in the leaf node that are ordered after the current value), until the sum of the errors of all values ​​in the leaf node is greater than the accuracy requirement β for that leaf node. m The merger has been stopped.

[0055] Step S1-3-5: Determine if all numeric leaf nodes L are numeric. m All the above processing has been completed. If the judgment is negative, return to step S1-3-1 to continue processing other numerical leaf nodes. If the judgment is positive, the model construction is completed, and the sum-product network model of the fused bitmap is obtained.

[0056] Figure 6 This is a schematic diagram of the leaf node structure in the sum-product network model of the fused bitmap in this embodiment.

[0057] like Figure 6 As shown, in the leaf node after bitmap merging, the storage structure is <{value}, row number bitmap of the data tuple corresponding to {value}>, where {value} is the specific value of the value that can be merged together, and the row number bitmap of the data tuple corresponding to {value} is a bitmap obtained after merging the row number bitmaps corresponding to these values.

[0058] Query processing step S2: When a query request is received (when an SQL query is received, i.e. when the model is invoked), the model executor executes the sum-product network model of the fused bitmap to perform inference and obtain the query result.

[0059] Figure 7 This is a flowchart of the query processing steps in this embodiment.

[0060] like Figure 7 As shown, query processing step S2 specifically includes the following sub-steps:

[0061] Step S2-1: When a query request is received, determine whether the query request filters data tuples for only one attribute, that is, whether the query predicate of the query statement contains only one attribute.

[0062] Step S2-2: If the determination in step S2-1 is yes, that is, if the query contains only one attribute, the numerical ratio stored in the leaf node is used to answer the query.

[0063] Step S2-3: If the determination in step S2-1 is negative, i.e. when the query contains multiple attributes, further determine whether the intersection size of the attributes contained in the lowest-level product node of the fused bitmap and the attributes involved in the query is less than or equal to 1.

[0064] Step S2-4: If the result is yes in step S2-3, that is, when the intersection size is less than or equal to 1, the numerical ratio stored in the leaf node is used to answer the query.

[0065] Step S2-5: If the determination in step S2-3 is negative, i.e., the intersection size is greater than 1, then bitmaps need to be used for reasoning in the child nodes of the product to ensure the accuracy of the reasoning. Furthermore, if there are bitmaps with numerical values ​​in the leaf nodes that were merged during construction, then both the bitmap and the numerical scale need to be used for reasoning.

[0066] Specifically, for all leaf nodes, if the range of values ​​corresponding to the merged bitmap on a certain leaf node is included in the query predicate, then all other leaf nodes can only obtain the query result by multiplying with that leaf node using the numerical ratio.

[0067] If the range of values ​​corresponding to the merged bitmap at a leaf node is entirely contained within the query predicate, other leaf nodes can obtain the query result by either intersecting the row number bitmap with that leaf node's bitmap or by multiplying the values ​​using numerical proportions. Specifically, it is determined whether the row number bitmaps in other leaf nodes are entirely contained within the query predicate. If they are, all other leaf nodes can obtain the query result by intersecting the row number bitmaps with that leaf node; otherwise, only multiplication using numerical proportions can be used.

[0068] In this embodiment, the parts not described in detail are well-known technologies in the art.

[0069] Functions and effects of the embodiments

[0070] According to the cardinality estimation and approximate query processing method and apparatus based on a product network model provided in this embodiment, the method includes a model building step and a query processing step. In the model building step, a product network model with fused bitmaps is constructed. The leaf nodes of this model store numerical values ​​and corresponding row number bitmaps. Based on accuracy requirements, the row number bitmaps are merged to construct a model with high accuracy and minimized inference overhead. In the query processing step, the calculation method of the leaf nodes is determined based on given rules related to accuracy requirements and the query requests decomposed to the lowest-level product nodes, thus achieving optimal inference accuracy and cost. As described above, the method and apparatus of this embodiment can improve the accuracy of cardinality estimation in query optimization, thereby helping to improve query optimization results and reduce the overhead required for query execution. Using the method and apparatus of this embodiment, data analysts can perform real-time analysis of large-scale datasets, improve the accuracy of approximate query processing on SPJA queries by fusing additional data distribution features, thereby enhancing user experience and improving decision-making effectiveness.

[0071] <Comparative Example>

[0072] This comparative example provides two existing data-driven cardinality estimation models as comparison models to compare the performance of the fused bitmap sum-product network model of the embodiment.

[0073] The comparison models are DeepDB and FLAT, both of which use a sampling-based approximate query processing method.

[0074] On the commonly used exploratory analytics dataset Flights, user queries were answered using the fusion bitmap sum-product network model of the example and two contrasting models to compare the performance of the three models.

[0075] The Flights dataset is a US flight delay dataset containing statistics such as flight delay times and passenger volume, and includes six categorical attributes and six numerical attributes. The Flights dataset used in this comparative example contains 5 million data tuples.

[0076] For the sum-product network model of the fused bitmap in this embodiment, the query is first rewritten as a probabilistic expression for the model. Then, inference is performed on the probabilities and expectations of each term in the probabilistic expression on the model. Finally, the inferred results are combined and rewritten to obtain the final approximate query result. In this comparative example, 200 SPJA queries are used for testing.

[0077] Figure 8This is a comparison chart showing the query accuracy of the three models in this comparison example on the Flights dataset. The chart illustrates the relative error comparison when using DeepDB, FLAT, and the example model for the test workload. Figure 8 As shown, on the Flights dataset, the query accuracy of the model in the example is better than the other two models. The average relative error of the query based on the model in the example is 1.2%, while the average relative errors of queries on DeepDB and FLAT are 26.6% and 40.2%, respectively, which are significantly higher than the relative error of the model in the example.

[0078] Figure 9 This is a comparison chart showing the query latency of the three models in this comparison example on the Flights dataset. The chart illustrates the query latency comparison when using DeepDB, FLAT, and the example model for the test workload. Figure 9 As shown, on the Flights dataset, while the query latency of the example model is slightly higher than DeepDB and FLAT, it is still within a few hundred milliseconds. Therefore, compared to the two existing data-driven modeling methods, DeepDB and FLAT, the example model can significantly improve the accuracy of query results while maintaining a millisecond-level query response time.

[0079] The above embodiments are only used to illustrate specific implementations of the present invention, and the present invention is not limited to the scope of the description of the above embodiments.

[0080] In the above embodiments, the sum-product network model of numerical leaf nodes is used as an example for specific explanation. Numerical leaf nodes are constructed for numerical attributes in the data. In fact, the method of the present invention can also use the sum-product network model of categorical leaf nodes, which are constructed for categorical attributes in the data.

Claims

1. A cardinality estimation and approximate query processing method based on a sum-product network model, used in the query optimization stage of a database and the approximate query processing stage of interactive data exploration, wherein the database contains a flight delay dataset, which contains multiple categorical attributes and multiple numerical attributes, including flight delay time and passenger capacity, characterized in that... Includes the following steps: Model building steps: Construct a sum-product network model with fused bitmaps, wherein the model includes summation nodes, product nodes and multiple leaf nodes. Each leaf node stores multiple sets of values, the numerical ratios corresponding to the values ​​and row number bitmaps. The row number bitmaps contain the row numbers of the data tuples corresponding to the values. When building the model, the row number bitmaps stored in the leaf nodes are merged according to the predetermined accuracy requirements. Query processing steps: Upon receiving a query request, the product network model of the fused bitmap is executed to infer the query result. Specifically, it is determined whether the query request at the lowest level (the product node) satisfies predetermined rules related to the accuracy requirement. If yes, an intersection operation is performed using the row number bitmap stored in the leaf node; otherwise, a multiplication operation is performed using the numerical ratio stored in the leaf node to obtain the query result. The model construction steps include the following sub-steps: In the trained sum-product network model, the accuracy requirements are allocated from top to bottom; For each leaf node, the error between its stored value and the different values ​​of other leaf nodes is calculated, and the row number bitmap corresponding to the value whose maximum error is less than the accuracy requirement on the leaf node is merged with the row number bitmap of the subsequent values ​​to obtain the sum-product network model of the fused bitmap.

2. The cardinality estimation and approximate query processing method based on the sum-product network model according to claim 1, characterized in that: in, When allocating the accuracy requirement, the accuracy requirement is distributed evenly among the product nodes based on the number of numerical attributes contained in each of the product nodes: In the formula, β i It is the product node L i The accuracy requirement on n j It is the product node L i The number of numeric attributes contained in the j-th child node, β j It is the node L after allocation i The accuracy requirement for the j-th child node.

3. The cardinality estimation and approximate query processing method based on the sum-product network model according to claim 1, Its features are: The process of merging the row number bitmaps of the leaf nodes based on the accuracy requirement includes the following steps: In one of the leaf nodes, for each value, the product of the proportion of the value used with the value and the proportion of the values ​​of different values ​​in the other leaf nodes is calculated and recorded as the product value. In this leaf node, for each value, calculate the intersection result of the row number bitmap corresponding to that value with the row number bitmap corresponding to different values ​​in other leaf nodes, and record it as the intersection value; For each value in the leaf node, calculate the error between the plurality of product values ​​and the plurality of intersection values; For each value in the leaf node, if the maximum error among the corresponding errors is less than the accuracy requirement for that leaf node, then the row number bitmap corresponding to that value is merged with the row number bitmap of the subsequent values, until the sum of the errors of the values ​​in the leaf node exceeds the accuracy requirement for that leaf node, at which point the merging stops. In the leaf node after bitmap merging, the storage structure is <{value}, row number bitmap of the data tuple corresponding to {value}>, where {value} is the value of the merged values, and the row number bitmap of the data tuple corresponding to {value} is the bitmap obtained after merging the row number bitmaps corresponding to these values.

4. The cardinality estimation and approximate query processing method based on the sum-product network model according to claim 1, Its features are: The model construction step includes the following sub-steps: Upon receiving the query request, determine whether the query predicate of the query request contains only one attribute. When it is determined that only one attribute is included, the numerical proportion stored in the leaf node is used to answer the query request; When it is determined that the product node contains multiple attributes, it is further determined whether the size of the intersection between the attributes contained in the lowest-level product node and the attributes involved in the query predicate is less than or equal to 1. When it is determined that the size of the intersection is less than or equal to 1, the numerical ratio stored in the leaf node is used to answer the query; If the intersection size is determined to be greater than 1, for all leaf nodes, if the numerical range corresponding to the merged row number bitmap of a leaf node is included in the query predicate, then all other leaf nodes are multiplied with that leaf node using the numerical ratio to obtain the query result. If the range of values ​​corresponding to the merged row number bitmap on a leaf node is completely contained by the query predicate, then it is determined whether the row number bitmaps in the other leaf nodes are completely contained by the query predicate. If they are completely contained, all other leaf nodes are intersected with the leaf node using the row number bitmap to obtain the query result. If they are not, all other leaf nodes are multiplied with the leaf node using the numerical ratio to obtain the query result.

5. A cardinality estimation and approximate query processing device based on a sum-product network model, used in the query optimization stage of a database and the approximate query processing stage in interactive data exploration, wherein the database contains a flight delay dataset, which contains multiple categorical attributes and multiple numerical attributes, including flight delay time and passenger capacity, characterized in that... include: A model builder is used to construct a sum-product network model with fused bitmaps. This model includes summation nodes, product nodes, and multiple leaf nodes. Each leaf node stores multiple sets of values, their corresponding numerical proportions, and row number bitmaps. The row number bitmaps contain the row numbers of the data tuples corresponding to each value. During model construction, the row number bitmaps stored in the leaf nodes are merged according to predetermined accuracy requirements. Model executor: Upon receiving a query request, it executes the sum-product network model of the fused bitmap to perform inference and obtain the query result. Specifically, it determines whether the query request decomposed down to the lowest-level product node satisfies predetermined rules related to the accuracy requirement. If yes, it performs an intersection operation using the row number bitmap stored in the leaf node; otherwise, it performs a multiplication operation using the numerical ratio stored in the leaf node to obtain the query result. The model builder performs the following operations: In the trained sum-product network model, the accuracy requirements are allocated from top to bottom; For each leaf node, the error between its stored value and the different values ​​of other leaf nodes is calculated, and the row number bitmap corresponding to the value whose maximum error is less than the accuracy requirement on the leaf node is merged with the row number bitmap of the subsequent values ​​to obtain the sum-product network model of the fused bitmap.

Citation Information

Patent Citations

  • Database benchmark test set generation method based on data and query synchronous generation

    CN115712554A

  • Approximate query processing-oriented sum-product network and residual neural network hybrid model

    CN115794880A