A data query method, device, apparatus and storage medium
By constructing a star schema and pruning the pre-computation results of the cube, the problem of slow cardinality calculation in the MapReduce method is solved, achieving efficient data query and storage optimization.
Patent Information
- Application Number
- CN202210202237.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-03
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2042-03-03
AI Technical Summary
In big data multidimensional analysis scenarios, existing technologies that use MapReduce combined with sampling calculation methods to estimate the cardinality are slow, affecting user query efficiency and leading to excessively long pre-computation time and increased storage costs.
By constructing multiple star schemas, the columns that need cardinality calculation are determined based on the dimension table and fact table of the schema. The cardinality calculation results are used to prune the pre-calculation results of the Cube, optimize the Cube design, and reduce unnecessary cardinality calculations.
It improves data query efficiency, reduces Cube storage costs and computing resource consumption, shortens cardinality calculation time, and increases user query speed.
Smart Images

Figure CN114780570B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data warehouse, and particularly relates to a data query method and device, electronic equipment and computer storage medium. BACKGROUND
[0002] In a big data multi-dimensional analysis scene, the data scale is often in the order of hundreds of billions or even trillions, and the number of dimensions is too large and the dimension base is too large, which has the risk of dimension explosion. If all the dimension combinations are still pre-calculated, it will definitely lead to too long pre-computation time and too large result data, which on the one hand increases the pre-computation and storage cost, and on the other hand also brings challenges to the scanning of a large number of pre-computation results.
[0003] To address this challenge, it is necessary to help users design data cubes more reasonably, that is, to optimize the Cube design by analyzing user query history, to set an aggregation group and classify dimensions, so as to avoid a large number of dimension combinations without affecting the query speed of users, and the base is an important feature for dimension classification.
[0004] In related technologies, the method of combining MapReduce with sampling calculation is mostly used to estimate the base, but this method is slow in calculation, which affects the query efficiency of users and greatly affects the user experience in actual application scenarios; therefore, a method for quickly determining the base to improve the data query efficiency is needed. SUMMARY
[0005] The present application provides a data query method, device, electronic equipment and computer storage medium.
[0006] The technical solution of the present application is implemented as follows:
[0007] The present application provides a data query method, which comprises the following steps:
[0008] According to the historical query data of users, a plurality of star models are constructed; the historical query data represents data obtained by performing an aggregated query on a data warehouse in a historical time period;
[0009] Based on the dimension table and the fact table of each star model in the plurality of star models, the base of a column that needs to be calculated is determined;
[0010] Based on the target base, the pre-computation result of the Cube is pruned; the pre-computation result after pruning is used to realize the query of business data; the target base includes the base of the column that needs to be calculated.
[0011] In some embodiments, the determining the cardinality of the column for which the cardinality needs to be calculated based on the dimension table and the fact table of each of the plurality of star models comprises:
[0012] extracting the column for which the cardinality needs to be calculated based on the dimension table and the fact table of each of the plurality of star models;
[0013] In a case where the column for which the cardinality needs to be calculated is determined to be a first double column, determining whether the first double column satisfies a replacement condition;
[0014] determining that the replacement is satisfied, and replacing the first double column to obtain a second double column, and determining the cardinality of the first double column by using the second double column; and determining that the replacement is not satisfied, and calculating the cardinality of the first double column.
[0015] In some embodiments, the method further comprises:
[0016] In a case where the column for which the cardinality needs to be calculated is determined to be a single column and located in a fact table, limiting the length of the fact table to a set length, and then calculating the cardinality of the single column.
[0017] In some embodiments, the determining whether the first double column satisfies the replacement condition comprises:
[0018] determining whether the first double column satisfies the replacement condition by judging the type of the table corresponding to each column in the first double column and whether one of the columns in the first double column is a primary key of a dimension table.
[0019] In some embodiments, the determining whether the first double column satisfies the replacement condition by judging the type of the table corresponding to each column in the first double column and whether one of the columns in the first double column is a primary key of a dimension table comprises:
[0020] In a case where the first double column is determined to be located in the same dimension table and one of the columns in the first double column is a primary key of the dimension table, determining that the first double column satisfies the replacement condition.
[0021] The replacing the first double column to obtain a second double column comprises:
[0022] replacing the first double column with the primary key of the dimension table to obtain the second double column.
[0023] In some embodiments, the determining whether the first double column satisfies the replacement condition by judging the type of the table corresponding to each column in the first double column and whether one of the columns in the first double column is a primary key of a dimension table comprises:
[0024] In a case where a first column in the first double column is determined to be located in a fact table, a second column in the first double column is determined to be located in a dimension table, and the second column is determined to be a primary key of the dimension table, determining that the first double column satisfies the replacement condition.
[0025] The replacing the first double columns to obtain second double columns comprises:
[0026] The first double columns are replaced by foreign keys in the fact table corresponding to the primary keys of the dimension table in which the first column and the second column are located, to obtain the second double columns.
[0027] In some embodiments, the determining whether the first double columns satisfy the replacement condition comprises:
[0028] When it is determined that the first column in the first double columns is located in a fact table, the second column is located in a dimension table, and the second column is not a primary key of the dimension table, determining whether the first double columns satisfy the replacement condition according to a ratio of a cardinality corresponding to the primary key in the dimension table in which the second column is located.
[0029] In some embodiments, the determining whether the first double columns satisfy the replacement condition according to the ratio of the cardinality corresponding to the primary key in the dimension table in which the second column is located comprises:
[0030] When it is determined that the ratio of the cardinality corresponding to the primary key in the dimension table in which the second column is located reaches a repetition rate threshold, it is determined that the first double columns satisfy the replacement condition.
[0031] The replacing the first double columns to obtain second double columns comprises:
[0032] The first double columns are replaced by foreign keys in the fact table corresponding to the primary keys of the dimension table in which the first column and the second column are located, to obtain the second double columns.
[0033] In some embodiments, the method further comprises:
[0034] Extracting model information of each star model in the plurality of star models;
[0035] Determining, based on the model information, whether there is a star model with a repeated fact table in the plurality of star models;
[0036] When it is determined that there is, fusing the star model with the repeated fact table to obtain a fused model, and constructing a wide table corresponding to the fused model;
[0037] When it is determined that there is not, constructing a wide table corresponding to each star model in the plurality of star models.
[0038] In some embodiments, the extracting the column for which the cardinality needs to be calculated based on the dimension table and the fact table of each star model in the plurality of star models comprises:
[0039] According to the dimension table and the fact table of the wide table corresponding to the fused model, or the dimension table and the fact table of the wide table corresponding to each of the plurality of star models, a column requiring a base number is extracted; and a length of the fact table in the wide table is limited to a set length.
[0040] The embodiment of the present application also provides a data query device, the device comprising a construction module, a determination module and a query module, wherein,
[0041] The construction module is used for constructing a plurality of star models according to historical query data of a user; the historical query data represents data obtained by performing an aggregated query on a data warehouse in a historical time period;
[0042] The determination module is used for determining a base number of a column requiring a base number based on a dimension table and a fact table of each of the plurality of star models;
[0043] The query module is used for pruning a pre-computation result of a Cube based on a target base number; and implementing a query on business data by using the pruned pre-computation result; the target base number comprises the base number of the column requiring the base number.
[0044] The embodiment of the present application provides an electronic device, the device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements any one of the methods provided in the foregoing one or more technical solutions when executing the program.
[0045] The embodiment of the present application provides a computer storage medium, the computer storage medium storing a computer program; the computer program can implement any one of the methods provided in the foregoing one or more technical solutions after being executed.
[0046] The embodiment of the present application provides a data query method, device, electronic device and computer storage medium, the method comprising: constructing a plurality of star models according to historical query data of a user; the historical query data represents data obtained by performing an aggregated query on a data warehouse in a historical time period; determining a base number of a column requiring a base number based on a dimension table and a fact table of each of the plurality of star models; pruning a pre-computation result of a Cube based on a target base number; and implementing a query on business data by using the pruned pre-computation result; the target base number comprises the base number of the column requiring the base number.
[0047] As can be seen, the embodiment of the present application constructs a corresponding star model according to historical query data of a user, and determines a base number of a column requiring a base number based on a dimension table and a fact table of the star model, so that the pre-computation result of the Cube can be pruned by using the base number computation result, the storage cost of the Cube is reduced, and the data query efficiency is improved. Attached Figure Description
[0048] Figure 1 This is a flowchart illustrating a data query method in an embodiment of this application;
[0049] Figure 2A This is a schematic diagram of another data query process in an embodiment of this application;
[0050] Figure 2B This is a schematic diagram of a process for constructing a wide table in an embodiment of this application;
[0051] Figure 2C This is a schematic diagram of a radix calculation process in an embodiment of this application;
[0052] Figure 2D This is a schematic diagram showing the results of cardinality calculation for three standard test sets in an embodiment of this application.
[0053] Figure 2E This is a schematic diagram showing the results of the bi-column cardinality calculation time for three standard test sets in the embodiments of this application;
[0054] Figure 3 This is a schematic diagram of the composition structure of the data query device according to an embodiment of this application;
[0055] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0056] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments provided herein are merely illustrative of the present application and are not intended to limit the present application. Furthermore, the embodiments provided below are some embodiments for implementing the present application, and not all embodiments for implementing the present application. Unless otherwise specified, the technical solutions described in the embodiments of the present application can be implemented in any combination.
[0057] It should be noted that, in the embodiments of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a method or apparatus that includes a list of elements includes not only the elements expressly described, but also other elements not expressly listed, or elements inherent to implementing the method or apparatus. Without further limitations, an element defined by the phrase "comprising a..." does not exclude the presence of other related elements (e.g., steps in the method or units in the apparatus, such as portions of circuitry, processors, programs, or software, etc.) in the method or apparatus that includes that element.
[0058] The term "and / or", used in the present document, only describes an association relationship of associated objects, which means that there can be three relationships, for example, I and / or J, which can represent three cases of I alone, I and J together, and J alone. In addition, the term "at least one" in the present document means any one of a plurality of or any combination of at least two of a plurality of, for example, at least one of I, J, and R can mean including any one or more elements selected from the set consisting of I, J, and R.
[0059] For example, the data query method provided by the embodiment of the present application includes a series of steps, but the data query method provided by the embodiment of the present application is not limited to the steps described. Similarly, the data query device provided by the embodiment of the present application includes a series of modules, but the data query device provided by the embodiment of the present application is not limited to including the explicitly described modules, and can also include modules required to be set when obtaining relevant data or processing based on data.
[0060] The embodiment of the present application can be applied to a computer system composed of a terminal device and a server, and can operate with many other general-purpose or special-purpose computing system environments or configurations. Here, the terminal device can be a thin client, a thick client, a handheld or laptop device, a microprocessor-based system, a set-top box, a programmable consumer electronics, a network personal computer, a small computer system, etc., and the server can be a server computer system, a small computer system, a large computer system, and a distributed cloud computing technology environment including any of the above systems, etc.
[0061] The terminal device, server and other electronic devices can be described in the general context of computer system executable instructions, such as program modules, executed by the computer system. Generally, program modules can include routines, programs, objects, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. The computer system / server can be implemented in a distributed cloud computing environment, in which tasks are performed by remote processing devices connected through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media, including storage devices.
[0062] In today's data era, how to analyze massive and complex data to assist business decision-making is an important issue in the field of business intelligence and data analysis. Generally, as the data volume of a data warehouse increases, directly performing multi-dimensional aggregation operation on a large amount of data requires a large amount of computing resources and a long time. Online analytical processing (OLAP) provides a solution for improving multi-dimensional analysis efficiency based on pre-computation, that is, a "data cube" (Cube) is implemented to pre-aggregate data in the data warehouse according to different dimension combinations, and the results are saved. When performing actual business queries, there is no need to perform aggregation operation on data again, but to directly read the pre-computed results, so that it is possible to achieve sub-second response and analysis for querying data with a size of millions or even hundreds of millions. The data model is the basis of OLAP analysis. The use of OLAP Cube does not suggest frequent changes to the data model, which will increase the difficulty of trial and error in data modeling. Therefore, it is particularly important to implement automatic modeling through computer algorithms to reduce the cost of manual modeling.
[0063] In a common OLAP solution, in order to analyze selected dimensions more quickly, the metrics of each node on the OLAP Cube are aggregated in advance through pre-computation, and the results are saved. When subsequent query operations are performed, the system can directly return the pre-computed results. Here, the O(N) level aggregation operation is converted into O(1) result query, improving query efficiency.
[0064] However, the above method needs to pre-compute all dimension combinations, which will cause the pre-computation time to be too long and the result data volume to be too large, which not only increases the pre-computation and storage costs, but also brings challenges to scanning a large number of pre-computed results. Therefore, it is necessary to optimize the Cube design to reduce a large number of dimension combinations while not affecting the query speed of users; and the cardinality is an important feature for classifying dimensions to implement the optimized Cube design.
[0065] In related technologies, the method of using MapReduce combined with sampling calculation is mostly used to estimate the cardinality, which has the following disadvantages: a small part of data is sampled each time, which will cause a large error in a large data volume scenario; and the calculation speed is slow, which will greatly affect the user experience in actual application scenarios. Therefore, in order to improve query efficiency, a method is needed to quickly determine the cardinality to implement the optimized Cube design.
[0066] In view of the above technical problems, the following embodiments are proposed.
[0067] In some embodiments of the present application, the data query method can be implemented by using a processor in the data query device, and the processor can be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, or a microprocessor.
[0068] Figure 1 is a flowchart of a data query method in an embodiment of the present application, as shown in the figure, the method comprises the following steps: Figure 1
[0069] Step 100: Constructing a plurality of star models according to historical query data of a user.
[0070] In an embodiment of the present application, the data query method can be applied to a data warehouse; the data warehouse comprises business data related to actual business; here, the type of the business data is not limited, for example, the business data can be related to bank transactions, or can be related to product sales, etc.
[0071] Exemplarily, the historical query data represents data obtained by aggregating and querying the data warehouse in a historical time period; here, the length of the historical time period can be set according to the actual scene, and the embodiment of the present application is not limited; for example, it can be within one month, or within three days, etc.
[0072] In the embodiments of the present application, first, the historical query data of a user is acquired, then the structured query language (SQL) statement corresponding to the acquired historical query data is parsed, and then, for the parsed query data, a plurality of star models are constructed. Here, the star model is used to represent the specific connection relationship between the dimension table and the fact table. The dimension table is a table in the data warehouse, and its entries describe the data in the fact data table. The dimension table contains the data on which the dimension is based, and each dimension table has a dimension as the primary key. The fact table is the central table in the data warehouse architecture, which contains the numerical measurement values and keys that connect the fact and dimension tables. The fact data table contains data describing specific events within the actual business (such as bank transactions or product sales).
[0073] Exemplarily, in the intelligent index modeling process of the data warehouse, it is necessary to count the cardinality of the related columns in the user's historical query based on the constructed star models, which will consume a large amount of cluster computing power and time. The following steps will specifically explain how to solve the problem of excessive calculation and long time consumption in the cardinality calculation process.
[0074] Step 101: Based on the dimension table and the fact table of each star model in the plurality of star models, the cardinality of the column that needs to be calculated is determined.
[0075] In some embodiments, based on the dimension table and the fact table of each star model in the plurality of star models, the cardinality of the column that needs to be calculated can include: based on the dimension table and the fact table of each star model in the plurality of star models, extracting the column that needs to be calculated; when the column that needs to be calculated is determined to be a first double column, determining whether the first double column satisfies the replacement condition; determining that it is satisfied, replacing the first double column to obtain a second double column; using the second double column to determine the cardinality of the first double column; determining that it is not satisfied, calculating the cardinality of the first double column.
[0076] In the embodiments of the present application, after obtaining the plurality of constructed star models according to the above steps, the column that needs to be calculated can be extracted from the plurality of constructed star models; wherein the column that needs to be calculated can be a single column or a double column; in the case that the column that needs to be calculated is a single column, the single column can be a column in the fact table or a column in the dimension table; in the case that the column that needs to be calculated is a double column, the double column can be two columns in the fact table, or two columns in the dimension table, or one column in the dimension table and the other column in the fact table.
[0077] In some embodiments, the method can further include: extracting model information of each of the plurality of star models; determining whether there is a star model of a repeated fact table in the plurality of star models based on the model information; determining that there is, fusing the star models of the repeated fact table to obtain a fused model, and constructing a wide table corresponding to the fused model; and determining that there is not, and constructing a wide table corresponding to each of the plurality of star models.
[0078] In the embodiments of the present application, the model information can represent information related to the fact table in the star model; by extracting the model information of each of the plurality of star models, it can be determined whether there is a repeated fact table between the plurality of star models; if it is determined that there is, the star models of the repeated fact table can be fused into one star model, i.e., a fused model is obtained; otherwise, no fusion is performed.
[0079] As can be seen, in the embodiments of the present application, when the column that needs to calculate the cardinality is a double column, and the double column is located in the tables of two star models, if the fact tables corresponding to the two star models are the same, by fusing the two star models into one star model, the number of cardinality calculations can be reduced, and the calculation time can be reduced.
[0080] Exemplarily, when it is determined that the plurality of star models only include star models of repeated fact tables, the star models can be fused to obtain at least one fused star model, and at this time, a corresponding wide table can be constructed for the fused star models.
[0081] Exemplarily, when it is determined that the plurality of star models only include star models of unique fact tables, no fusion is performed, and at this time, a corresponding wide table can be constructed for each of the plurality of star models.
[0082] Exemplarily, when it is determined that the plurality of star models include star models of repeated fact tables and star models of unique fact tables, the star models of the repeated fact tables can be fused to obtain at least one fused star model; the star models of the unique fact tables are not fused; at this time, a corresponding wide table can be constructed for the fused star models, and a corresponding wide table can also be constructed for the star models of the unique fact tables.
[0083] In some embodiments, based on the dimension table and the fact table of each of the plurality of star models, the column that needs to calculate the cardinality can include: extracting the column that needs to calculate the cardinality according to the dimension table and the fact table of the wide table corresponding to the fused model, or the dimension table and the fact table of the wide table corresponding to each of the plurality of star models; and limiting the length of the fact table in the wide table to a set length.
[0084] Exemplarily, after the corresponding wide tables of the plurality of star models are constructed according to the above steps, columns for which the cardinality needs to be calculated can be extracted based on each constructed wide table; here, the wide table can be the wide table corresponding to the fused model, or the wide table corresponding to the single star model of the fact table. It should be noted that the length of the fact table in each wide table is limited to a set length.
[0085] Exemplarily, the value of the set length is pre-set according to an actual scenario, and embodiments of the present application do not limit this, for example, it can be 100000 or less.
[0086] As can be seen, in the embodiments of the present application, by limiting the fact table in each wide table to a set length, the length of the wide table can be greatly reduced, and the calculation time can be reduced.
[0087] In some embodiments, determining whether the first double column satisfies the replacement condition can include: determining whether the first double column satisfies the replacement condition by judging the type of the table corresponding to each column in the first double column and whether one of the columns in the first double column is the primary key of the dimension table.
[0088] In the embodiments of the present application, when the column for which the cardinality needs to be calculated is determined to be the first double column, it is necessary to determine whether the first double column satisfies the replacement condition; since the replacement condition is mainly related to the type of the table corresponding to each column in the first double column and the primary key condition, and the type of the table corresponding to each column in the first double column can be a dimension table or a fact table, when determining whether the first double column satisfies the replacement condition, it is necessary to first judge the type of the table corresponding to each column in the first double column; then, after judging the type of the table corresponding to each column in the first double column, it is necessary to further judge whether one of the columns in the first double column is the primary key of the dimension table; finally, the result of the two judgments can be combined to determine whether the first double column satisfies the replacement condition. The implementation of determining whether the first double column satisfies the replacement condition will be described below.
[0089] In some embodiments, when it is determined that the first double column is located in the same dimension table and one of the columns in the first double column is the primary key of the dimension table, it is determined that the first double column satisfies the replacement condition; at this time, the first double column can be replaced to obtain a second double column; the specific implementation can be: replacing the first double column with the primary key of the dimension table to obtain the second double column; then, the cardinality of the first double column can be determined using the second double column.
[0090] Here, the first double column is replaced with the primary key of the dimension table, that is, the column in the first double column that is not the primary key of the dimension table is replaced with the primary key of the dimension table, that is, each column in the replaced first double column (second double column) is the primary key of the dimension table; at this time, the cardinality of the first double column is equivalent to the cardinality of the primary key in the second double column, and the primary key cardinality that has been calculated can be directly replaced.
[0091] In some embodiments, when it is determined that the first column in the first double column is located in the fact table, the second column is located in the dimension table, and the second column is the primary key of the dimension table, it is determined that the first double column satisfies the replacement condition; at this time, the first double column can be replaced to obtain a second double column; a specific implementation manner can be that the first double column is replaced by the foreign key in the fact table corresponding to the primary key of the dimension table in which the first column and the second column are located, to obtain the second double column; then, the cardinality of the first double column can be determined by using the second double column.
[0092] Here, the first double column is replaced by the foreign key in the fact table corresponding to the primary key of the dimension table in which the first column and the second column are located, that is, the first column in the first double column is unchanged, and the second column in the first double column is replaced by the foreign key in the fact table corresponding to the primary key of the dimension table in which the second column is located; that is, the two columns in the first double column after replacement (the second double column) are both pairs of columns in the fact table; at this time, the cardinality of the pairs of columns in the fact table that has been calculated can be directly replaced, and the cardinality of the first double column does not need to be calculated.
[0093] In some embodiments, when it is determined that the first column in the first double column is located in the fact table, the second column is located in the dimension table, and the second column is not the primary key of the dimension table, whether the first double column satisfies the replacement condition is determined according to the ratio of the second column to the cardinality corresponding to the primary key of the dimension table in which the second column is located.
[0094] Exemplarily, for the implementation manner of determining whether the first double column satisfies the replacement condition according to the ratio of the second column to the cardinality corresponding to the primary key of the dimension table in which the second column is located, it can be that when it is determined that the ratio of the second column to the cardinality corresponding to the primary key of the dimension table in which the second column is located reaches a repetition rate threshold, it is determined that the first double column satisfies the replacement condition; at this time, the first double column can be replaced to obtain a second double column; a specific implementation manner can be that the first double column is replaced by the foreign key in the fact table corresponding to the primary key of the dimension table in which the first column and the second column are located, to obtain the second double column.
[0095] Exemplarily, when the second column in the first double column is located in the dimension table but is not the primary key in the dimension table, the cardinality corresponding to the second column and the cardinality corresponding to the primary key of the dimension table in which the second column is located are respectively determined; then, the ratio of the two cardinalities is calculated, and it is determined whether the ratio reaches a pre-set repetition rate threshold; if it is determined that the ratio reaches the repetition rate threshold, it is indicated that the first double column satisfies the replacement condition; otherwise, it is indicated that the first double column does not satisfy the replacement condition.
[0096] Here, the value of the repetition rate threshold is pre-set according to an actual scene, and embodiments of the present application do not limit this, for example, can be 0.8, 0.9, etc.
[0097] Exemplarily, in the case where the first double column satisfies the replacement condition, the implementation manner of replacing the first double column to obtain a second double column has been described in the above embodiments, and will not be described here again.
[0098] It can be seen that, in the case that the cardinality of the first double column needs to be calculated and it is determined that the first double column meets the replacement condition, the first double column whose cardinality needs to be calculated can be directly replaced by the above three replacement manners, i.e., the cardinality of the first double column does not need to be calculated each time, and only the first double column that does not meet the replacement condition is calculated for the cardinality. In this way, the number of times of calculating the cardinality of each pair of columns and the single calculation time are greatly shortened, and a large amount of calculation resources are saved.
[0099] Step 102: pruning the pre-computation result of the Cube based on the target cardinality; and using the pruned pre-computation result to realize the query of the business data; the target cardinality includes the cardinality of the column whose cardinality needs to be calculated.
[0100] In the embodiment of the application, the target cardinality can include the cardinality of the column whose cardinality needs to be calculated; wherein the column whose cardinality needs to be calculated can be a double column (for the above first double column) or a single column; the calculation manner of the double column cardinality has been described in the above steps; and the calculation process of the single column cardinality is described below.
[0101] In some embodiments, the above method can further include: when it is determined that the column whose cardinality needs to be calculated is a single column and is located in the fact table, limiting the length of the fact table to a set length, and then calculating the cardinality of the single column.
[0102] In the embodiment of the application, when it is determined that the column whose cardinality needs to be calculated is a single column, it needs to be judged whether the single column is located in the fact table. If yes, the length of the fact table is limited to a set length first, and then the cardinality of the single column is calculated based on the fact table with the limited length; otherwise, it is indicated that the single column is located in the dimension table, and the cardinality of the single column is directly calculated based on the dimension table. Here, the set length is the same as the set length of the fact table in the wide table.
[0103] Here, by limiting the length of the fact table in which the single column is located to a set length, the length of the fact table can be greatly reduced, and the cardinality calculation time can be reduced.
[0104] In the embodiment of the application, after the target cardinality is obtained through the above steps, the pre-computation result of the Cube can be pruned using the target cardinality. This is because, when the pre-computation result of the Cube is pruned, an aggregation group and an aggregation group rule need to be designed, and the design of the aggregation group and the aggregation group rule must use the cardinality of the column whose cardinality needs to be calculated. In this way, the purpose of optimizing the Cube design can be achieved.
[0105] Exemplarily, by pruning the pre-computation result of the Cube, the storage size of the Cube can be reduced, so that the query speed of the user can be improved when the user needs to use the Cube to query the business data subsequently.
[0106] The embodiment of the application provides a data query method and device, electronic equipment and computer storage medium. The method comprises the following steps: constructing a plurality of star models according to historical query data of a user; the historical query data represents data obtained by performing an aggregated query on a data warehouse in a historical time period; determining the cardinality of a column requiring cardinality calculation based on a dimension table and a fact table of each star model in the plurality of star models; pruning a pre-computation result of a Cube based on a target cardinality; and implementing a query of business data by using the pruned pre-computation result; the target cardinality comprises the cardinality of the column requiring cardinality calculation. It can be seen that, when the first double column meets the replacement condition, the embodiment of the application does not need to directly perform cardinality calculation on the first double column, but replaces the cardinality of the first double column with the cardinality of the second double column which has been calculated. In this way, the number and time of the cardinality calculation of the two columns are greatly shortened, and a large amount of computing resources is saved. In addition, the pre-computation result of the Cube is pruned by using the cardinality calculation result, so that the storage cost of the Cube is reduced, and the data query efficiency is improved.
[0107] In order to better reflect the purpose of the application, on the basis of the above-mentioned embodiment of the application, further example is given.
[0108] Figure 2A For another data query flowchart in the embodiment of the application, as shown in Figure 2A the flowchart comprises the following steps:
[0109] Step A1: analyzing historical query data of a user.
[0110] Exemplarily, the historical query data is first obtained from the historical aggregated query of the user, and then the obtained historical query data is analyzed to obtain analyzed data.
[0111] Step A2: constructing a star model.
[0112] Exemplarily, the analyzed data is counted to obtain a counting result, and a plurality of star models are constructed according to the counting result and the analyzed data, so as to obtain a data model result.
[0113] Step A3: counting the cardinality of a related column in the historical query.
[0114] Exemplarily, the cardinality of the related column in the historical query of the user is counted according to the plurality of constructed star models, that is, the column requiring cardinality calculation is extracted from the fact table and the dimension table of each star model in the plurality of star models, and the cardinality is calculated.
[0115] Step A4: designing an aggregated group and an aggregation rule.
[0116] For example, after obtaining the cardinality of the column whose cardinality needs to be calculated, the cardinality result is calculated; based on the cardinality result and the data model result, aggregation groups and aggregation rules are designed, and the pre-calculated results of the Cube are pruned using the cardinality to obtain the aggregation group result; based on the aggregation group result, the query speed of subsequent business data for users is improved. Below, we will combine... Figure 2B and Figure 2C The specific implementation process of step A3 will be explained.
[0117] Figure 2B This is a schematic diagram of a process for constructing a wide table in an embodiment of this application, such as... Figure 2B As shown, the process includes the following steps:
[0118] Step B1: Extract model information.
[0119] For example, after obtaining multiple star schemas that have been constructed, the model information of each star schema can be extracted.
[0120] Step B2: Determine if a duplicate fact table exists. If yes, proceed to step B4 after step B3; otherwise, proceed directly to step B4.
[0121] For example, since model information can represent information related to the fact tables in a star schema, it is possible to determine whether there are duplicate fact tables among multiple star schemas based on the model information of each star schema.
[0122] Step B3: Star-shaped model fusion.
[0123] For example, if it is determined that there are duplicate fact tables, the star schema with duplicate fact tables is fused to obtain the fused model.
[0124] Step B4: Build a wide table.
[0125] For example, wide tables are constructed for both the merged model and the unmerged star schema. Since the length of the fact table in the wide table is limited to a set length, the calculation time for subsequent cardinality can be shortened.
[0126] Figure 2C This is a schematic diagram of a radix calculation process in an embodiment of this application, such as... Figure 2C As shown, the process includes the following steps:
[0127] Step C1: Extract the column from which the cardinality needs to be calculated.
[0128] For example, in accordance with Figure 2B The process shown constructs corresponding wide tables for multiple star schemas, and the columns for which cardinality needs to be calculated can be extracted based on each constructed wide table.
[0129] Step C2: judging whether the column is single column. If yes, executing step C3, otherwise, executing step C6.
[0130] Exemplarily, judging whether the column which needs to calculate the cardinality is single column.
[0131] Step C3: judging whether the column is located in the fact table. If yes, executing step C4 and then executing step C5, otherwise, directly executing step C5.
[0132] Exemplarily, when it is determined that the column which needs to calculate the cardinality is single column, it is needed to further judge whether the single column is located in the fact table.
[0133] Step C4: limiting the length of the fact table.
[0134] Exemplarily, when it is determined that the single column which needs to calculate the cardinality is located in the fact table, the length of the fact table is limited to a set length.
[0135] Step C5: calculating the cardinality of the single column.
[0136] Exemplarily, when the single column is located in the fact table, the cardinality of the single column is calculated based on the fact table with limited length; here, it is assumed that the length of the fact table is limited to 100000, then the cardinality of the single column can be calculated by executing the instruction select count(distinct column) from table limit 100000 through the interface of pyspark; if the single column is not located in the fact table, the length of the table is not limited and the cardinality of the single column is directly calculated. It can be seen that the application can use pyspark as the interface, and can realize the automatic construction of the wide table and the automatic calculation of the multi-threaded cardinality.
[0137] Here, after executing step C5, the process of calculating the cardinality of the single column has been completed.
[0138] Step C6: judging whether the column is double column. If yes, executing step C7, otherwise, throwing an exception.
[0139] Exemplarily, when it is determined that the column which needs to calculate the cardinality is not single column, it is needed to further judge whether the column which needs to calculate the cardinality is double column.
[0140] Step C7: cardinality filtering.
[0141] Exemplarily, when it is determined that the column which needs to calculate the cardinality is double column, the cardinality filtering is performed before calculating the cardinality of the double column; here, the double column corresponds to the first double column described above, and the cardinality filtering corresponds to the process of determining whether the first double column meets the replacement condition described above. The process of the cardinality filtering specifically includes the following steps (corresponding to the dashed box in the figure):
[0142] Step C70: Determine whether the two columns in the first double column are in the same dimension table. If yes, execute Step C71, otherwise, execute Step C73.
[0143] For example, it is needed to determine whether the two columns in the first double column whose cardinality is to be calculated are in the same dimension table.
[0144] Step C71: Determine whether there is a column as the primary key. If yes, execute Step C72, Step C8, otherwise, no replacement is performed and the cardinality calculation is directly performed.
[0145] For example, after determining that the two columns in the first double column whose cardinality is to be calculated are in the same dimension table, it is further determined whether there is a column in the first double column as the primary key of the dimension table.
[0146] Step C72: Cardinality replacement.
[0147] For example, the cardinality of the first double column is replaced, and the specific replacement manner has been described in the above embodiment, which will not be repeated here.
[0148] Step C73: Determine whether there is a column in the fact table. If yes, execute Step C74, otherwise, no replacement is performed and the cardinality calculation is directly performed.
[0149] For example, if it is determined that the two columns in the first double column are not in the same dimension table, it is further determined whether there is a column in the first double column in the fact table.
[0150] Step C74: Determine whether there is a column as the primary key. If yes, execute Step C72, Step C8, otherwise, execute Step C75.
[0151] For example, if it is determined that there is a column in the first double column in the fact table and another column in the first double column is the primary key of the dimension table, the cardinality replacement is performed by executing Step C72.
[0152] Step C75: Determine whether the ratio reaches the repetition rate threshold. If yes, execute Step C72, Step C8, otherwise, no replacement is performed and the cardinality calculation is directly performed.
[0153] For example, if it is determined that there is a column in the fact table and another column in the first double column is not the primary key of the dimension table, it is further determined whether the ratio of the cardinality of the other column to the cardinality of the primary key of the dimension table reaches the repetition rate threshold.
[0154] Step C8: Calculate the cardinality of the replaced double column.
[0155] Here, the two-by-two columns that do not need to calculate the cardinality can be filtered out by the cardinality replacement described above, and for the replaced two-column cardinality, the pyspark interface is called to traverse each wide table and calculate the two-by-two column cardinality by executing the instruction select count (distinct col1, col2) from table.
[0156] It can be seen that the embodiment of the application formulates a series of cardinality filtering strategies according to the specific connection relationship between the dimension table and the fact table in the star model and the primary-foreign key characteristics, and combines the limitation of the length of the wide table to greatly shorten the number of two-by-two column cardinality calculations and the single calculation time. The following will be illustrated by specific standard test sets.
[0157] Figure 2D For the results of the cardinality calculation for the three standard test sets in the embodiment of the application, refer to Figure 2D , which lists the calculation times and calculation times before and after the single cardinality calculation of the three million-level standard test sets SSC, TPC-DS and TPC-H using the cardinality calculation method provided by the embodiment of the application, specifically including: single column calculation times, single column calculation times, double column calculation times and double column calculation times. It can be seen that when performing single cardinality calculation on double columns, the time reduction of more than 10 times is achieved compared to using the prior art, and a large amount of calculation resources is saved.
[0158] Figure 2E For the results of the double-column cardinality calculation time for the three standard test sets in the embodiment of the application, refer to Figure 2E , the abscissa represents the three standard test sets SSC, TPC-DS and TPC-H, and the ordinate represents the double-column cardinality calculation time, in minutes; it can be seen that before using the cardinality calculation method provided by the embodiment of the application to calculate the double-column cardinality, the three standard test sets SSC, TPC-DS and TPC-H need 150 minutes, 300 minutes and 70 minutes of cardinality calculation time, respectively, and after using the cardinality calculation method provided by the embodiment of the application to calculate the double-column cardinality, the three standard test sets SSC, TPC-DS and TPC-H need 2 minutes, 10 minutes and 6 minutes of cardinality calculation time, respectively.
[0159] It can be seen that the embodiment of the application can abstract the replaceability of the primary-foreign key connection mode according to the connection characteristics of the star model, and find the type of the table corresponding to each column, and replace the column with the largest primary key cardinality to convert the double-column cardinality calculation into single-column calculation, greatly reducing the calculation times and time.
[0160] Figure 3 For the composition structure diagram of the data query device of the embodiment of the application, refer to Figure 3As shown, the apparatus comprises a construction module 300, a determination module 301 and a query module 302, wherein:
[0161] The construction module 300 is configured to construct a plurality of star models according to historical query data of a user; the historical query data represents data obtained by performing an aggregated query on a data warehouse in a historical time period;
[0162] The determination module 301 is configured to determine a cardinality of a column requiring a cardinality calculation based on a dimension table and a fact table of each star model in the plurality of star models.
[0163] The query module 302 is configured to prune a pre-computation result of a Cube based on a target cardinality; and implement a query of business data by using the pruned pre-computation result; the target cardinality comprises the cardinality of the column requiring the cardinality calculation.
[0164] In some embodiments, the determination module 301 is configured to determine the cardinality of the column requiring the cardinality calculation based on the dimension table and the fact table of each star model in the plurality of star models, comprising:
[0165] extracting the column requiring the cardinality calculation based on the dimension table and the fact table of each star model in the plurality of star models;
[0166] when the column requiring the cardinality calculation is determined to be a first double column, determining whether the first double column satisfies a replacement condition;
[0167] when the determination result is that the first double column satisfies the replacement condition, replacing the first double column to obtain a second double column, determining the cardinality of the first double column by using the second double column, and when the determination result is that the first double column does not satisfy the replacement condition, calculating the cardinality of the first double column.
[0168] In some embodiments, the determination module 301 is further configured to:
[0169] when the column requiring the cardinality calculation is determined to be a single column and located in the fact table, limiting a length of the fact table to a set length, and then calculating the cardinality of the single column.
[0170] In some embodiments, the determination module 301 is configured to determine whether the first double column satisfies the replacement condition, comprising:
[0171] determining whether the first double column satisfies the replacement condition by judging a type of a table corresponding to each column in the first double column and whether one column in the first double column is a primary key of a dimension table.
[0172] In some embodiments, the determination module 301 is configured to determine whether the first double column satisfies the replacement condition by judging a type of a table corresponding to each column in the first double column and whether one column in the first double column is a primary key of a dimension table, comprising:
[0173] determining that the first double column satisfies a replacement condition when it is determined that the first double column is located in the same dimension table and one column in the first double column is a primary key of the dimension table;
[0174] The determination module 301 is configured to replace the first double column to obtain a second double column, including:
[0175] replacing the first double column with a primary key of the dimension table to obtain the second double column.
[0176] In some embodiments, the determination module 301 is configured to determine whether the first double column satisfies a replacement condition by judging the type of the table corresponding to each column in the first double column and whether one column in the first double column is a primary key of a dimension table, including:
[0177] determining that the first double column satisfies a replacement condition when it is determined that a first column in the first double column is located in a fact table, a second column is located in a dimension table, and the second column is a primary key of the dimension table;
[0178] The determination module 301 is configured to replace the first double column to obtain a second double column, including:
[0179] replacing the first double column with a foreign key in a fact table corresponding to a primary key of the dimension table where the first column and the second column are located to obtain the second double column.
[0180] In some embodiments, the determination module 301 is configured to determine whether the first double column satisfies a replacement condition by judging the type of the table corresponding to each column in the first double column and whether one column in the first double column is a primary key of a dimension table, including:
[0181] determining whether the first double column satisfies a replacement condition according to a ratio of the second column to a primary key of the dimension table where the second column is located when it is determined that a first column in the first double column is located in a fact table, a second column is located in a dimension table, and the second column is not a primary key of the dimension table.
[0182] In some embodiments, the determination module 301 is configured to determine whether the first double column satisfies a replacement condition according to a ratio of the second column to a primary key of the dimension table where the second column is located, including:
[0183] determining that the first double column satisfies a replacement condition when it is determined that the ratio of the second column to the primary key of the dimension table where the second column is located reaches a repetition rate threshold;
[0184] The determination module 301 is configured to replace the first double column to obtain a second double column, including:
[0185] The first double column is replaced by a foreign key in a fact table corresponding to a dimension table primary key of a first column and a second column, to obtain the second double column.
[0186] In some embodiments, the construction module 300 is further configured to:
[0187] extract model information of each star model in the plurality of star models;
[0188] determine whether there is a star model of a repeated fact table in the plurality of star models based on the model information;
[0189] if there is, fuse the star model of the repeated fact table to obtain a fused model, and construct a wide table corresponding to the fused model;
[0190] if there is not, construct a wide table corresponding to each star model in the plurality of star models.
[0191] In some embodiments, the construction module 300 is configured to extract the column for which the cardinality needs to be calculated based on a dimension table and a fact table of each star model in the plurality of star models, including:
[0192] extract the column for which the cardinality needs to be calculated based on a dimension table and a fact table of the wide table corresponding to the fused model, or a dimension table and a fact table of the wide table corresponding to each star model in the plurality of star models; and limit the length of the fact table in the wide table to a set length.
[0193] In actual applications, the construction module 300, the determination module 301, and the query module 302 can be implemented by a processor in an electronic device, which can be at least one of an ASIC, a DSP, a DSPD, a PLD, an FPGA, a CPU, a controller, a microcontroller, and a microprocessor.
[0194] In addition, each functional module in the embodiment can be integrated in one processing unit, or each unit can exist physically independently, or two or more units can be integrated in one unit. The integrated unit can be implemented in the form of hardware or in the form of a software functional module.
[0195] If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer readable storage medium based on such understanding. The technical solutions of the embodiments essentially or the parts that make contributions to the related art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the embodiments. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0196] Specifically, the computer program instructions corresponding to the data query method and the training method of the detection model in the embodiments can be stored on a storage medium such as an optical disc, a hard disk, a U disk, etc. When the computer program instructions corresponding to the data query method and the training method of the detection model in the storage medium are read by an electronic device or executed, any one of the data query method and the training method of the detection model in the foregoing embodiments is implemented.
[0197] Based on the same technical concept as the foregoing embodiments, refer to Figure 4 which shows the electronic device 400 provided by the embodiments of the present application, which can include: a memory 401 and a processor 402; wherein,
[0198] The memory 401 is configured to store computer programs and data.
[0199] The processor 402 is configured to execute the computer programs stored in the memory to implement any one of the methods of the foregoing embodiments.
[0200] In actual applications, the memory 401 can be a volatile memory (volatile memory) such as RAM, or a non-volatile memory (non-volatile memory) such as ROM, flash memory, hard disk (Hard Disk Drive, HDD) or solid state disk (Solid-State Drive, SSD), or a combination of the above types of memories, and provides instructions and data to the processor 402.
[0201] The processor 402 described above can be at least one of an ASIC, a DSP, a DSPD, a PLD, an FPGA, a CPU, a controller, a microcontroller, and a microprocessor. It can be understood that, for different processing devices, the electronic devices used to implement the functions of the processor described above can also be other devices, and the embodiments of the present application are not limited in this regard.
[0202] In some embodiments, the apparatus provided by the embodiments of the present application has functions or includes modules for performing the methods described in the above method embodiments, and the specific implementation can be referred to the description of the above method embodiments, and details are not described here.
[0203] The above description of various embodiments tends to emphasize the differences between various embodiments, and the same or similar parts can be mutually referred to, and details are not described here for the sake of brevity.
[0204] The methods disclosed in the various method embodiments of the present application can be combined arbitrarily without conflict to obtain new method embodiments.
[0205] The features disclosed in the various product embodiments of the present application can be combined arbitrarily without conflict to obtain new product embodiments.
[0206] The features disclosed in the various method or device embodiments of the present application can be combined arbitrarily without conflict to obtain new method embodiments or device embodiments.
[0207] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can be in the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0208] The present application is described with reference to flowcharts and / or block diagrams according to the methods, devices (systems), and computer program products of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks. Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks.
[0209] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide a process for implementing the functions specified in the flowchart Figure 1 one flow or multiple flows and / or one block or multiple blocks. Figure 1 Figure 1 the functions specified in the flowchart or multiple flowcharts and / or the functions specified in one block or multiple blocks.
[0210] The above merely describes the preferred embodiments of the present application, but not for limiting the protection scope of the present application.
Claims
1. A data query method, characterized by, The method includes: Multiple star schemas are constructed based on users' historical query data; the historical query data refers to the data obtained by performing aggregate queries on the data warehouse within a historical time period. Based on the dimension table and fact table of each star schema in the plurality of star schemas, determine the cardinality of the columns for which cardinality needs to be calculated; Based on the target cardinality, the pre-calculation results of the data cube are pruned; the pruned pre-calculation results are used to query business data; the target cardinality includes the cardinality of the columns whose cardinality needs to be calculated; The columns that need to have their cardinality calculated include: single columns and / or double columns that need to have their cardinality calculated; The determination of the cardinality of the columns requiring cardinality calculation based on the dimension table and fact table of each of the multiple star schemas includes: Based on the dimension table and fact table of each star schema in the multiple star schemas, extract the columns for which the cardinality needs to be calculated; When it is determined that the column for which the cardinality needs to be calculated is the first double column, it is determined whether the first double column satisfies the replacement condition; Once the condition is met, the first double column is replaced to obtain the second double column; using the second double column, the base of the first double column is determined.
2. The method of claim 1, wherein, After determining whether the first double column meets the replacement condition, the method further includes: If the condition is not met, calculate the cardinality of the first double column.
3. The method according to claim 1 or 2, characterized in that, The method further includes: When it is determined that the column for which the cardinality needs to be calculated is a single column and is located in the fact table, the cardinality of the single column is calculated after limiting the length of the fact table to a set length.
4. The method of claim 1, wherein, Determining whether the first double column meets the replacement condition includes: By determining the table type corresponding to each column in the first double column and whether one of the columns in the first double column is the primary key of the dimension table, it is determined whether the first double column meets the replacement condition.
5. The method of claim 4, wherein, The step of determining whether the first double column meets the replacement condition by judging the table type corresponding to each column in the first double column and whether one of the columns in the first double column is the primary key of the dimension table includes: When it is determined that the first double column is located in the same dimension table, and one of the columns in the first double column is the primary key of the dimension table, the first double column is determined to satisfy the replacement condition. The step of replacing the first double column to obtain the second double column includes: The second double column is obtained by replacing the first double column with the primary key of the dimension table.
6. The method of claim 4, wherein, The step of determining whether the first double column meets the replacement condition by judging the table type corresponding to each column in the first double column and whether one of the columns in the first double column is the primary key of the dimension table includes: When it is determined that the first column of the first double column is located in the fact table, the second column is located in the dimension table, and the second column is the primary key of the dimension table, the first double column is determined to satisfy the replacement condition. The step of replacing the first double column to obtain the second double column includes: The second double column is obtained by replacing the first double column with a foreign key in the fact table corresponding to the primary key of the dimension table containing the first and second columns.
7. The method of claim 4, wherein, The step of determining whether the first double column meets the replacement condition by judging the table type corresponding to each column in the first double column and whether one of the columns in the first double column is the primary key of the dimension table includes: In a case where it is determined that the first column in the first double column is located in a fact table, the second column is located in a dimension table, and the second column is not a primary key of the dimension table, it is determined whether the first double column meets a replacement condition according to a ratio of a cardinality corresponding to the second column to a primary key in the dimension table in which the second column is located.
8. The method of claim 7, wherein, The determining whether the first double column meets the replacement condition according to the ratio of the cardinality corresponding to the second column to the primary key in the dimension table in which the second column is located includes: In a case where it is determined that the ratio of the cardinality corresponding to the second column to the primary key in the dimension table in which the second column is located reaches a repetition rate threshold, it is determined that the first double column meets the replacement condition. The replacing the first double column to obtain a second double column includes: The first double column is replaced by a foreign key corresponding to a primary key of the dimension table in which the first column and the second column are located in a fact table to obtain the second double column.
9. The method of claim 1 or 2, wherein, The method further includes: extracting model information of each star model in the plurality of star models; determining, based on the model information, whether there is a star model with a repeated fact table in the plurality of star models; in a case where it is determined that there is, fusing the star model with the repeated fact table to obtain a fused model, and constructing a wide table corresponding to the fused model; in a case where it is determined that there is not, constructing a wide table corresponding to each star model in the plurality of star models.
10. The method of claim 9, wherein, The extracting the column for which the cardinality needs to be calculated based on the dimension table and the fact table of each star model in the plurality of star models includes: extracting the column for which the cardinality needs to be calculated based on the dimension table and the fact table of the wide table corresponding to the fused model, or the dimension table and the fact table of the wide table corresponding to each star model in the plurality of star models; and limiting a length of the fact table in the wide table to a set length.
11. A data query apparatus, characterized by comprising: The apparatus includes: a construction module configured to construct a plurality of star models according to historical query data of a user; the historical query data represents data obtained by performing an aggregate query on a data warehouse in a historical time period; a determination module configured to determine a cardinality of a column for which the cardinality needs to be calculated based on a dimension table and a fact table of each star model in the plurality of star models; a query module configured to prune a pre-computation result of a Cube based on a target cardinality; and implement a query on business data by using the pruned pre-computation result; the target cardinality includes the cardinality of the column for which the cardinality needs to be calculated; wherein the column for which the cardinality needs to be calculated includes a cardinality: a single column and / or a double column for which the cardinality needs to be calculated. The determination module is specifically configured to: extract the column for which the cardinality needs to be calculated based on the dimension table and the fact table of each star model in the plurality of star models; in a case where it is determined that the column for which the cardinality needs to be calculated is a first double column, determine whether the first double column meets a replacement condition; in a case where it is determined that the first double column meets the replacement condition, replace the first double column to obtain a second double column; and determine the cardinality of the first double column by using the second double column.
12. An electronic device, comprising: The device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the method in any one of claims 1 to 10 when executing the program.
13. A computer storage medium having stored thereon a computer program, characterized in that The computer program is executable on the processor to implement the method in any one of claims 1 to 10.
Citation Information
Patent Citations
Hadoop OLAP engine
US20150310082A1
Cardinality estimation of a join predicate
US20170364556A1