Query processing method and apparatus based on precomputation scenario
By performing pre-computation processing to generate access constraints in big data analysis scenarios, the problem of inefficient bounded computing access constraints is solved, and the acceleration and performance improvement of complex queries are achieved.
Patent Information
- Application Number
- PCT/CN2023/081692
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-22
- Filing Date
- 2023-03-15
- Publication Date
- 2024-08-29
AI Technical Summary
In big data analysis scenarios, access constraints based on bounded calculations are not ideal for accelerating complex queries, resulting in low query efficiency and affecting query performance.
By performing pre-computation processing on the optimization end, the first access constraints are generated, including conditional filtering, aggregate functions and expression calculations, and query plans are generated based on the query rewrite type to reduce the amount of calculation during query execution.
It improves the performance of complex queries, reduces the amount of data required for access constraints, speeds up the query process, and improves query efficiency.
Smart Images

Figure CN2023081692_29082024_PF_FP_ABST
Abstract
Description
A query processing method and device based on pre-calculation scenario Technical Field
[0001] The present application relates to the field of data query, and in particular to a query processing method and device based on pre-calculation scenarios. Background Art
[0002] Query performance is a key metric for query analysis in big data scenarios. To improve query performance, the industry has explored a variety of methods, including indexes, materialized views, cubes, and bounded-computing-based access constraints.
[0003] In the current existing technology: 1) Index: A typical method to improve query efficiency is to create a suitable index for the query. Common indexes include B+Tree index, Hash index, and Bitmap index. When querying, the records or ranges of records that meet the conditions can be quickly located according to the index, thereby reducing the number of records involved in the calculation. 2) Materialized view and cube: Both materialized view and cube can be used to pre-calculate and save the results of time-consuming operations such as table joins or aggregations. In this way, when executing queries, these time-consuming operations can be avoided and results can be obtained quickly. When the source table changes, the materialized view should also be refreshed. 3) Access constraints based on bounded computing: Based on the above-mentioned bounded computing principles, an access constraint (AC) {x->y, N} can be created on the table. Any query Q on the table that meets the access constraint can be rewritten as a query Q' on AC, thereby accelerating query performance.
[0004] In big data analysis scenarios, however, operations like grouping, aggregation, joining, and filtering on massive amounts of data are computationally intensive, resulting in low query efficiency. Access constraints based on bounded computation theory are less than ideal for accelerating complex queries involving grouping, aggregation, joining, and filtering. The inefficiency of access constraints in big data analysis scenarios significantly impacts query efficiency.
[0005] Summary of the Invention
[0006] In view of the above problems, the present application is proposed to provide a query processing method and apparatus based on a pre-calculation scenario that overcomes the above problems or at least partially solves the above problems, including:
[0007] A query processing method based on a pre-computation scenario, the method involving a user end, an optimization end, an execution end, and a database, the method comprising:
[0008] The optimization end receives the query request sent by the user end, and the user end is used to generate the query request according to the user demand and send the query request to the optimization end;
[0009] The optimization end reads metadata in the database according to the query request, wherein the metadata includes a data table and an access constraint set;
[0010] The optimization end performs pre-calculation processing based on the data in the data table to generate a first access constraint, wherein the pre-calculation processing includes condition filtering, aggregation function and expression calculation;
[0011] The optimizer generates a query plan according to the first access constraint and the query rewrite type, wherein the query rewrite type includes filter matching rewrite, projection matching rewrite, aggregate column matching rewrite, and join rewrite;
[0012] The optimization end sends the query plan to the execution end, and the execution end is used to feed back the query results generated after the query plan is executed to the user end.
[0013] Furthermore, the first access constraint is generated by performing pre-calculation processing based on the data in the data table, wherein the pre-calculation processing includes the steps of condition filtering, aggregation function and expression calculation, including:
[0014] When the pre-calculation process is the conditional filtering, the optimization end determines, based on the preset filtering condition, the pre-processed data that meets the preset filtering condition from the data in the data table;
[0015] The optimization end generates the first access constraint according to the preprocessed data.
[0016] Furthermore, the first access constraint is generated by performing pre-calculation processing based on the data in the data table, wherein the pre-calculation processing includes the steps of condition filtering, aggregation function and expression calculation, including:
[0017] The optimization end generates a first initial access constraint according to the data, and obtains a first expression set and a second expression set in the first initial access constraint;
[0018] When the pre-calculation processing is the aggregate function, the optimization end adds or modifies the preset aggregate function in the first expression set and the second expression set, and generates the first access constraint based on the first expression set after the added or modified preset aggregate function and the second expression set after the preset aggregate function; wherein, the preset aggregate function includes containing specified fields or containing specified expressions.
[0019] Furthermore, the first access constraint is generated by performing pre-calculation processing based on the data in the data table, wherein the pre-calculation processing includes the steps of condition filtering, aggregation function and expression calculation, including:
[0020] The optimization end generates a second initial access constraint based on the data, and obtains a third expression set and a fourth expression set in the second initial access constraint;
[0021] When the pre-calculation process is the expression calculation, the optimization end obtains the target field according to the third expression set and the fourth expression set;
[0022] The optimization end determines a target column corresponding to the data table according to the target field;
[0023] The optimization end determines a target expression corresponding to the target column according to the target column;
[0024] The optimization end generates the first access constraint by performing calculations based on the target expression.
[0025] Furthermore, generating a query plan based on the first access constraint and the query rewrite type, wherein the query rewrite type includes filter matching rewrite, projection matching rewrite, aggregate column matching rewrite, and join rewrite steps, includes:
[0026] When the query rewriting type is the Filter matching rewriting, the optimization end determines whether the result set generated by analyzing the query statement is a subset of the first access constraint, and if so, generates the query plan according to the first access constraint; or
[0027] When the query rewriting type is the projection matching rewriting, the optimization end determines whether the projection expression in the analysis query statement is included in the first access constraint, and if so, generates the query plan according to the first access constraint; or
[0028] When the query rewrite type is cluster column matching rewrite, the optimizer determines a target aggregate function within the first access constraint, modifies an original aggregate function corresponding to the analysis query statement, and generates the query plan using the target aggregate function and the modified original aggregate function; or
[0029] When the query rewrite type is Join rewrite, the optimizer determines whether data of the left and right nodes of the join operator exist in the first access constraint, and if so, generates the query plan according to the first access constraint.
[0030] The present application also discloses a query processing method based on a pre-calculation scenario, which involves a user terminal, an optimization terminal, an execution terminal, and a database, and includes:
[0031] The execution end receives the query plan sent by the optimization end, and the optimization end is used to send the query plan to the execution end;
[0032] The execution end determines the target access constraint according to the query plan;
[0033] The execution end determines the second target data in the data table according to the target access constraint;
[0034] The execution end generates a query result according to the second target data;
[0035] The execution end sends the query result to the user end, and the user end is used to receive the query result fed back by the execution end.
[0036] The present application also discloses a query processing method based on a pre-calculation scenario, which involves a user terminal, an optimization terminal, an execution terminal, and a database, and includes:
[0037] The user terminal generates a query request according to user needs and sends the query request to the optimization terminal, which is used to receive the query request sent by the user terminal;
[0038] The user end receives the query result sent by the execution end and returns the query result to the corresponding target user. The execution end is used to feed back the query result to the user end.
[0039] The embodiment of the present application further discloses a query processing device based on a pre-calculation scenario, the device involving a user end, an optimization end, an execution end, and a database, and the device comprising:
[0040] A first sending module, configured for the optimization end to receive a query request sent by the user end, wherein the user end is configured to generate a query request according to user needs and send the query request to the optimization end;
[0041] A first reading module, configured for the optimization end to read metadata from the database according to the query request, wherein the metadata includes a data table and an access constraint set;
[0042] A first generation module, configured for the optimization end to perform pre-calculation processing based on the data in the data table to generate a first access constraint, wherein the pre-calculation processing includes conditional filtering, aggregation function and expression calculation;
[0043] A second generation module is configured for the optimization end to generate a query plan based on the first access constraint and a query rewrite type, wherein the query rewrite type includes filter matching rewrite, projection matching rewrite, aggregate column matching rewrite, and join rewrite;
[0044] The second sending module is used for the optimization end to send the query plan to the execution end, and the execution end is used to feed back the query results generated after the query plan is executed to the user end.
[0045] The embodiment of the present application further discloses a query processing device based on a pre-calculation scenario, the device involving a user end, an optimization end, an execution end, and a database, and the device comprising:
[0046] a third sending module, configured for the execution end to receive the query plan sent by the optimization end, and the optimization end to send the query plan to the execution end;
[0047] A first determination module, configured for the execution end to determine a target access constraint according to the query plan;
[0048] A second determining module, configured for the execution end to determine second target data in the data table according to the target access constraint;
[0049] a third generating module, configured for the execution end to generate a query result according to the second target data;
[0050] A fourth sending module is used for the execution end to send the query result to the user end, and the user end is used to receive the query result fed back by the execution end.
[0051] The embodiment of the present application further discloses a query processing device based on a pre-calculation scenario, the device involving a user end, an optimization end, an execution end, and a database, and the device comprising:
[0052] A fifth sending module, configured for the user terminal to generate a query request according to user needs and send the query request to the optimization terminal, wherein the optimization terminal is configured to receive the query request sent by the user terminal;
[0053] The return module is used for the user end to receive the query result sent by the execution end and return the query result to the corresponding target user. The execution end is used to feed back the query result to the user end.
[0054] This application has the following advantages:
[0055] In an embodiment of the present application, compared with the problems in the prior art of "very large operation and calculation amount, low query efficiency; unsatisfactory acceleration effect of complex queries; low access constraint efficiency, which greatly affects query efficiency", the present application provides a solution for "pre-computation processing of access constraints", specifically: "the optimization end receives the query request sent by the user end, the user end is used to generate a query request according to user needs, and sends the query request to the optimization end; the optimization end reads metadata in the database according to the query request, wherein the metadata includes a data table and an access constraint set; the optimization end performs pre-computation processing based on the data in the data table to generate a first access constraint, wherein the pre-computation processing includes conditional filtering, aggregation function and expression calculation; the optimization end generates a query plan based on the first access constraint and the query rewrite type, wherein the query rewrite type includes Filter matching rewrite, projection matching rewrite, aggregate column matching rewrite and Join rewrite; the optimization end sends the query plan to the execution end, and the execution end is used to feed back the query result generated after the query plan is executed to the user end." By "generating a query plan based on the first access constraint and query rewriting type", we solved the problems of "the operation calculation amount is very large, the query efficiency is low; the acceleration effect of complex queries is not ideal; the access constraint efficiency is not high, which greatly affects the query efficiency" and achieved "after the access constraint adds pre-calculation processing, the query calculation can be advanced to the time when the access constraint data is generated, reducing the amount of calculation during the query execution process; it helps to increase the complexity, reduce the amount of access constraint data, and accelerate query performance." BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for the description of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0057] FIG1 is a flowchart of a query processing method based on a pre-calculation scenario provided by an embodiment of the present application;
[0058] FIG2 is a flowchart of a query processing method based on a pre-calculation scenario provided in an embodiment of the present application;
[0059] FIG3 is a flowchart of a query processing method based on a pre-calculation scenario provided in an embodiment of the present application;
[0060] FIG4 is a structural block diagram of a query processing device based on a pre-calculation scenario provided by an embodiment of the present application;
[0061] FIG5 is a structural block diagram of a query processing device based on a pre-calculation scenario provided by an embodiment of the present application;
[0062] FIG6 is a structural block diagram of a query processing device based on a pre-calculation scenario provided in an embodiment of the present application;
[0063] FIG7 is a schematic structural diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] To make the objectives, features, and advantages of this application more readily apparent, the present application is further described below in conjunction with the accompanying drawings and specific embodiments. It is apparent that the embodiments described are only a portion of the embodiments of this application, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments in this application without inventive effort are also within the scope of protection of this application.
[0065] The inventors found through analysis of the prior art that:
[0066] 1. When indexes are used for large-scale data queries, there may be a large amount of random I / O, resulting in performance degradation. When there is a large amount of duplicate data, all of it must be stored in the index, which does not save storage space. Furthermore, indexes do not pre-calculate aggregation operations.
[0067] 2. Real-time synchronization of materialized views and cubes is difficult to achieve. Data refreshes are often required, which can take a long time when the data volume is large, and the materialized view is unavailable during the refresh. These limitations result in limited flexibility for materialized views and cubes, limiting their use to relatively fixed query statements.
[0068] 3. In bounded computation access constraints, we need to find the degree of repetition N of x->y and store the repeated x->y as {x,y,count}. In applications, we've found that actual query statements often involve a large number of fields in a table. To enable queries to use AC (access constraints created on a table based on access patterns), these fields must be added to x or y, even if some of these fields are only used for filtering or aggregation. This results in ACs created in real applications with too many x and y fields, resulting in a small degree of repetition N and failing to achieve the desired acceleration effect.
[0069] In big data analysis scenarios, however, operations like grouping, aggregation, joining, and filtering on massive amounts of data are computationally intensive, resulting in low query efficiency. Access constraints based on bounded computation theory are less than ideal for accelerating complex queries involving grouping, aggregation, joining, and filtering. The inefficiency of access constraints in big data analysis scenarios significantly impacts query efficiency.
[0070] It should be noted that the original AC is organized to compress and deduplicate duplicate data in a specified column according to the model definition {x->y,N}. x and y are sets of expressions, each of which contains one or more fields from the table. Therefore, AC contains x, y, and the number of duplicate records of y values corresponding to each x value (called the duplication degree, denoted as count). In other words, AC is the set {x, y, count}. Generally speaking, the more fields x and y involve, the less likely x->y will have a high duplication degree, meaning the count value will be smaller.
[0071] 1 , there is shown a flowchart of a query processing method based on a pre-calculation scenario provided by an embodiment of the present application;
[0072] A query processing method based on a pre-computation scenario, the method involving a user end, an optimization end, an execution end, and a database, the method comprising:
[0073] S110, the optimization end receives a query request sent by the user end, the user end is used to generate a query request according to user needs, and send the query request to the optimization end;
[0074] S120: The optimization end reads metadata from the database according to the query request, wherein the metadata includes a data table and an access constraint set;
[0075] S130, the optimization end performs pre-calculation processing based on the data in the data table to generate a first access constraint, wherein the pre-calculation processing includes conditional filtering, aggregation function and expression calculation;
[0076] S140. The optimizer generates a query plan according to the first access constraint and the query rewrite type, where the query rewrite type includes filter matching rewrite, projection matching rewrite, aggregate column matching rewrite, and join rewrite.
[0077] S150: The optimization end sends the query plan to the execution end, and the execution end is used to feed back the query results generated after the query plan is executed to the user end.
[0078] In an embodiment of the present application, compared with the problems in the prior art of "very large operation and calculation amount, low query efficiency; unsatisfactory acceleration effect of complex queries; low access constraint efficiency, which greatly affects query efficiency", the present application provides a solution for "pre-computation processing of access constraints", specifically: "the optimization end receives the query request sent by the user end, the user end is used to generate a query request according to user needs, and sends the query request to the optimization end; the optimization end reads metadata in the database according to the query request, wherein the metadata includes a data table and an access constraint set; the optimization end performs pre-computation processing based on the data in the data table to generate a first access constraint, wherein the pre-computation processing includes conditional filtering, aggregation function and expression calculation; the optimization end generates a query plan based on the first access constraint and the query rewrite type, wherein the query rewrite type includes Filter matching rewrite, projection matching rewrite, aggregate column matching rewrite and Join rewrite; the optimization end sends the query plan to the execution end, and the execution end is used to feed back the query result generated after the query plan is executed to the user end." By "generating a query plan based on the first access constraint and query rewriting type," we solved the problems of "the operation and calculation amount is very large, the query efficiency is low; the acceleration effect of complex queries is not ideal; the access constraint efficiency is not high, which greatly affects the query efficiency." We achieved "after adding pre-calculation processing to the access constraint, the calculation during the query can be advanced to the time when the access constraint data is generated, reducing the amount of calculation during the query execution process; it helps to increase the complexity, reduce the amount of access constraint data, and accelerate query performance."
[0079] Next, a query processing method based on a pre-calculation scenario in this exemplary embodiment will be further described.
[0080] In one embodiment of the present invention, when creating an access constraint, the user must provide a complete definition of the access constraint, including the access constraint's filter conditions, the specific definitions of x and y, and the definition of the aggregate function. Based on the access constraint definition, the database filters the original table data according to the specified filter conditions and generates {x, y, count, aggregate} data, where aggregate represents a set of aggregate functions.
[0081] In one embodiment of the present invention, a portion of required data can be screened out through pre-calculation processing, and unnecessary data can be removed. When generating the first access constraint, the data within the first access constraint is the required data after pre-calculation processing, which can avoid the need to re-screen the data when generating the first access constraint, thereby improving work efficiency.
[0082] In one embodiment of the present invention, the pre-calculation processing is performed based on the data in the data table to generate the first access constraint, wherein the pre-calculation processing includes the steps of conditional filtering, aggregation function and expression calculation, including:
[0083] When the pre-calculation process is the conditional filtering, the optimization end determines, based on the preset filtering condition, the pre-processed data that meets the preset filtering condition from the data in the data table;
[0084] The optimization end generates the first access constraint according to the preprocessed data.
[0085] It should be noted that the conditional filtering is used to add a preset filtering condition to the first access constraint, and only data that meets the preset filtering condition will be inserted into the first access constraint.
[0086] In one embodiment of the present invention, the pre-calculation processing is performed based on the data in the data table to generate the first access constraint, wherein the pre-calculation processing includes the steps of conditional filtering, aggregation function and expression calculation, including:
[0087] The optimization end generates a first initial access constraint according to the data, and obtains a first expression set and a second expression set in the first initial access constraint;
[0088] When the pre-calculation processing is the aggregate function, the optimization end adds or modifies the preset aggregate function in the first expression set and the second expression set, and generates the first access constraint based on the first expression set after the added or modified preset aggregate function and the second expression set after the preset aggregate function; wherein, the preset aggregate function includes containing specified fields or containing specified expressions.
[0089] It should be noted that, in addition to the first expression set and the second expression set, an aggregation function for a specified field or expression may be added to implement pre-calculation of the aggregation operation.
[0090] In one embodiment of the present invention, the pre-calculation processing is performed based on the data in the data table to generate the first access constraint, wherein the pre-calculation processing includes the steps of conditional filtering, aggregation function and expression calculation, including:
[0091] The optimization end generates a second initial access constraint based on the data, and obtains a third expression set and a fourth expression set in the second initial access constraint;
[0092] When the pre-calculation process is the expression calculation, the optimization end obtains the target field according to the third expression set and the fourth expression set;
[0093] The optimization end determines a target column corresponding to the data table according to the target field;
[0094] The optimization end determines a target expression corresponding to the target column according to the target column;
[0095] The optimization end generates the first access constraint by performing calculations based on the target expression.
[0096] It should be noted that the fields in the third expression set and the fourth expression set can not only be columns in the table, but also expression calculations on columns in the table, thereby implementing pre-calculation of expression calculations.
[0097] In a specific implementation, expressions may also appear in the filter conditions.
[0098] In one embodiment of the present invention, generating a query plan based on the first access constraint and the query rewrite type, wherein the query rewrite type includes filter matching rewrite, projection matching rewrite, aggregate column matching rewrite, and join rewrite steps, includes:
[0099] When the query rewriting type is the Filter matching rewriting, the optimization end determines whether the result set generated by analyzing the query statement is a subset of the first access constraint, and if so, generates the query plan according to the first access constraint; or
[0100] When the query rewriting type is the projection matching rewriting, the optimization end determines whether the projection expression in the analysis query statement is included in the first access constraint, and if so, generates the query plan according to the first access constraint; or
[0101] When the query rewrite type is cluster column matching rewrite, the optimizer determines a target aggregate function within the first access constraint, modifies an original aggregate function corresponding to the analysis query statement, and generates the query plan using the target aggregate function and the modified original aggregate function; or
[0102] When the query rewrite type is Join rewrite, the optimizer determines whether data of the left and right nodes of the join operator exist in the first access constraint, and if so, generates the query plan according to the first access constraint.
[0103] It should be noted that, by analyzing the query statement, the expressions corresponding to the Filter matching rewrite, the projection matching rewrite, the aggregate column matching rewrite and the Join rewrite are determined respectively, and the degree of overlap and / or the logical relationship with the target expression defined by the access constraint in the access constraint set are determined based on the expression, and then the degree of overlap and / or the logical relationship can be calculated and rewritten in the query statement using the expression of the access constraint to directly query the specific column in the access constraint.
[0104] It should be noted that whether an analytical query statement can use a certain AC is determined by comparing the definition when the AC was created with some information in the query statement. This is the AC matching process, which is achieved through filter matching rewriting, projection matching rewriting, aggregate column matching rewriting, and join rewriting.
[0105] It's important to note that when querying table data, the optimizer determines whether the query can be rewritten to access AC during the query optimization phase. The optimizer's query rewriting is primarily divided into the following areas: filter matching rewriting, projection matching rewriting, cluster column matching rewriting, and join rewriting.
[0106] It should be noted that the purpose of filter matching rewriting is to ensure that the queried result set is a subset of the result set when AC is defined, and to reduce the query calculation amount by deleting the satisfied filters.
[0107] It's important to note that the purpose of projection matching rewriting is to ensure that all projection expressions required by a query can be provided by the AC data. Therefore, the optimizer calculates the expressions required for upward projection in the underlying scan based on the logical operator tree generated by the query and matches the calculated projections with the expressions in the AC definition, ensuring that all projection expressions can be calculated using the expressions in the AC definition.
[0108] It should be noted that the aggregate column matching rewrite will identify the aggregate functions that can be used in AC and rewrite the aggregate functions in the original query, thereby reducing the amount of calculation and speeding up the query.
[0109] It should be noted that the Join rewrite will identify whether the data of the left and right nodes of the join operator contain the count column from AC. If both nodes do, the product of the count columns of the left and right nodes will be added to the Join output column.
[0110] 2 , an embodiment of the present invention further discloses a flowchart of a query processing method based on a pre-calculation scenario provided by an embodiment of the present application;
[0111] A query processing method based on a pre-computation scenario, the method involving a user end, an optimization end, an execution end, and a database, the method comprising:
[0112] S210: The execution end receives the query plan sent by the optimization end, and the optimization end is configured to send the query plan to the execution end;
[0113] S220, the execution end determines a target access constraint according to the query plan;
[0114] S230, the execution end determines second target data in the data table according to the target access constraint;
[0115] S240, the execution end generates a query result according to the second target data;
[0116] S250: The execution end sends the query result to the user end, and the user end is used to receive the query result fed back by the execution end.
[0117] 3 , an embodiment of the present invention further discloses a flowchart of a query processing method based on a pre-calculation scenario provided by an embodiment of the present application;
[0118] A query processing method based on a pre-computation scenario, the method involving a user end, an optimization end, an execution end, and a database, the method comprising:
[0119] S310: The user terminal generates a query request according to user needs and sends the query request to the optimization terminal, which is used to receive the query request sent by the user terminal;
[0120] S320: The user end receives the query result sent by the execution end, and returns the query result to the corresponding target user. The execution end is used to feed back the query result to the user end.
[0121] Example 1
[0122] on_time table structure:
[0123] The on_time table records flight delay information. It contains over 100 million records, and the FlightNo, DestAirportID, and DelayTime fields contain a large number of duplicate values.
[0124] There are queries like:
[0125] selectFlightNo,avg(DelayTime)from on_time where DestAirportID='101'group by FlightNo;
[0126] Assume there are 1,000 flights and 1 million records satisfying the condition DestAirportID = '101'. Each DestAirportID corresponds to a maximum of 1,000 FlightNos. That is, the duplication of DestAirportID->FlightNo is 1,000.
[0127] If the above query statement is executed by filtering the entire on_time table and then performing grouping and aggregation, 100 million records must first be compared and filtered, and then the 1 million filtered records must be grouped and aggregated. There are 1,000 groups, and DelayTime must be accumulated 1,000 times in each group, which means a total of 1 million times.
[0128] If the original AC method is used, an AC needs to be created for the on_time table: {DestAirportID, FlightNo, DelayTime, count}. Using the access constraints designed in this invention, an AC is created for the on_time table: {DestAirportID, FlightNo, count, sum(DelayTime) as SumDelayTime}. Based on the previous assumption about the data volume, the AC can contain a maximum of 1 million records. The AC only retrieves approximately 1,000 records that meet the requirements. The aggregation operation directly uses the SumDelayTime value, significantly reducing the computational effort.
[0129] Advantages of the current technical solution:
[0130] 1. Added pre-computation capability to AC to reduce the amount of calculation during query;
[0131] 2. The number of fields in AC is reduced, which helps to improve duplication and reduce data volume.
[0132] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0133] 4 , there is shown a block diagram of a query processing device based on a pre-calculation scenario according to an embodiment of the present application;
[0134] A query processing device based on a pre-computation scenario, the device involving a user end, an optimization end, an execution end, and a database, the device comprising:
[0135] A first sending module 410 is configured to receive, at the optimization end, a query request sent by the user end, wherein the user end is configured to generate a query request based on user needs and send the query request to the optimization end;
[0136] A first reading module 420 is configured for the optimization end to read metadata from the database according to the query request, wherein the metadata includes a data table and an access constraint set;
[0137] A first generation module 430 is configured to generate a first access constraint by performing a pre-calculation process on the optimization end based on the data in the data table, wherein the pre-calculation process includes conditional filtering, aggregation function, and expression calculation;
[0138] A second generation module 440 is configured for the optimizer to generate a query plan based on the first access constraint and a query rewrite type, wherein the query rewrite type includes filter matching rewrite, projection matching rewrite, aggregate column matching rewrite, and join rewrite;
[0139] The second sending module 450 is used for the optimization end to send the query plan to the execution end, and the execution end is used to feed back the query result generated after the query plan is executed to the user end.
[0140] In one embodiment of the present invention, the first generating module 430 includes:
[0141] A first determining submodule, configured to, when the pre-calculation process is the conditional filtering, determine, by the optimization end, pre-processed data that meets the preset filtering condition from the data in the data table according to the preset filtering condition;
[0142] The first generating submodule is used by the optimization end to generate the first access constraint according to the pre-processed data.
[0143] In one embodiment of the present invention, the first generating module 430 includes:
[0144] A first acquisition submodule is configured for the optimization end to generate a first initial access constraint based on the data, and to acquire a first expression set and a second expression set in the first initial access constraint;
[0145] The second generation submodule is used for, when the pre-calculation processing is the aggregate function, the optimization end adds or modifies the preset aggregate function in the first expression set and the second expression set, and generates the first access constraint based on the first expression set after the added or modified preset aggregate function and the second expression set after the preset aggregate function; wherein, the preset aggregate function includes containing a specified field or containing a specified expression.
[0146] In one embodiment of the present invention, the first generating module 430 includes:
[0147] A second acquisition submodule, configured for the optimization end to generate a second initial access constraint based on the data, and to acquire a third expression set and a fourth expression set in the second initial access constraint;
[0148] a third acquisition submodule, configured to, when the pre-calculation process is the expression calculation, cause the optimization end to acquire a target field according to the third expression set and the fourth expression set;
[0149] A second determining submodule is configured for the optimization end to determine a target column corresponding to the data table according to the target field;
[0150] A third determining submodule, configured for the optimization end to determine a target expression corresponding to the target column based on the target column;
[0151] The third generation submodule is used by the optimization end to calculate and generate the first access constraint according to the target expression.
[0152] In one embodiment of the present invention, the second generating module 440 includes:
[0153] a fourth generation submodule, configured to, when the query rewriting type is the Filter matching rewriting, determine by the optimization end whether the result set generated by analyzing the query statement is a subset of the first access constraint, and if so, generate the query plan according to the first access constraint; or
[0154] a fifth generation submodule, configured to, when the query rewriting type is the projection matching rewriting, determine by the optimization end whether the projection expression in the analysis query statement is contained in the first access constraint, and if so, generate the query plan according to the first access constraint; or
[0155] A sixth generation submodule is configured to, when the query rewrite type is an aggregate column matching rewrite, cause the optimization end to determine a target aggregate function within the first access constraint, modify an original aggregate function corresponding to the analysis query statement, and generate the query plan using the target aggregate function and the modified original aggregate function; or
[0156] The seventh generation submodule is used to, when the query rewriting type is Join rewriting, determine by the optimization end whether the data of the left and right nodes of the join operator exist in the first access constraint; if so, generate the query plan according to the first access constraint.
[0157] 5 , there is shown a block diagram of a query processing device based on a pre-calculation scenario according to an embodiment of the present application;
[0158] A query processing device based on a pre-computation scenario, the device involving a user end, an optimization end, an execution end, and a database, the device comprising:
[0159] A third sending module 510 is configured for the execution end to receive the query plan sent by the optimization end, and the optimization end is configured to send the query plan to the execution end;
[0160] A first determination module 520 is configured for the execution end to determine a target access constraint according to the query plan;
[0161] A second determination module 530, configured for the execution end to determine second target data in the data table according to the target access constraint;
[0162] A third generating module 540 is configured for the execution end to generate a query result based on the second target data;
[0163] The fourth sending module 550 is configured for the execution end to send the query result to the user end, and the user end is configured to receive the query result fed back by the execution end.
[0164] 6 , which shows a block diagram of a query processing device based on a pre-calculation scenario according to an embodiment of the present application;
[0165] A query processing device based on a pre-computation scenario, the device involving a user end, an optimization end, an execution end, and a database, the device comprising:
[0166] A fifth sending module 610 is configured for the user terminal to generate a query request according to user needs and send the query request to the optimization terminal, and the optimization terminal is configured to receive the query request sent by the user terminal;
[0167] Return module 620 is used for the user end to receive the query result sent by the execution end and return the query result to the corresponding target user. The execution end is used to feed back the query result to the user end.
[0168] 7 , a computer device for a query processing method based on a pre-calculation scenario of the present invention is shown, which may specifically include the following:
[0169] The computer device 12 is a general-purpose computing device. The components of the computer device 12 may include but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).
[0170] The bus 18 represents one or more of several types of bus 18 structures, including a memory bus 18 or memory controller, a peripheral bus 18, an accelerated graphics port, a processor, or a local bus 18 that utilizes any of a variety of bus 18 architectures. Examples of such architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus 18, a Micro Channel Architecture (MAC) bus 18, an Enhanced ISA bus 18, an Audio Video Electronics Standards Association (VESA) local bus 18, and a Peripheral Component Interconnect (PCI) bus 18.
[0171] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0172] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be configured to read and write to non-removable, non-volatile magnetic media (commonly referred to as a "hard drive"). Although not shown in FIG. 7 , a magnetic disk drive may be provided for reading and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), as well as an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media). In these cases, each drive may be connected to bus 18 via one or more data media interfaces. The memory may include at least one program product having a set (e.g., at least one) of program modules 42 configured to perform the functions of various embodiments of the present invention.
[0173] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in a memory. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules 42, and program data, each of which, or some combination thereof, may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0174] The computer device 12 may also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, camera, etc.), one or more devices that enable a user to interact with the computer device 12, and / or any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may occur via an input / output (I / O) interface 22. Furthermore, the computer device 12 may also communicate with one or more networks (e.g., a local area network (LAN)), a wide area network (WAN), and / or a public network (e.g., the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with the other modules of the computer device 12 via a bus 18. It should be understood that, although not shown in FIG. 7 , other hardware and / or software modules may be used in conjunction with the computer device 12, including, but not limited to, microcode, device drivers, redundant processing units 16, external disk drive arrays, RAID systems, tape drives, and data backup storage systems 34.
[0175] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the query processing method based on the pre-calculation scenario provided by the embodiment of the present invention.
[0176] That is, when the processing unit 16 executes the program, the following is achieved: the optimization end receives the query request sent by the user end, the user end is used to generate a query request based on user needs, and sends the query request to the optimization end; the optimization end reads metadata in the database based on the query request, wherein the metadata includes a data table and an access constraint set; the optimization end performs pre-calculation processing based on the data in the data table to generate a first access constraint, wherein the pre-calculation processing includes conditional filtering, aggregation function and expression calculation; the optimization end generates a query plan based on the first access constraint and the query rewrite type, wherein the query rewrite type includes Filter matching rewrite, projection matching rewrite, aggregate column matching rewrite and Join rewrite; the optimization end sends the query plan to the execution end, and the execution end is used to feed back the query result generated after the query plan is executed to the user end.
[0177] In an embodiment of the present invention, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the query processing method based on the pre-calculation scenario provided in all embodiments of the present application:
[0178] That is, when the program is executed by the processor, it is implemented as follows: the optimization end receives the query request sent by the user end, the user end is used to generate a query request based on user needs, and sends the query request to the optimization end; the optimization end reads metadata in the database according to the query request, wherein the metadata includes a data table and an access constraint set; the optimization end performs pre-calculation processing based on the data in the data table to generate a first access constraint, wherein the pre-calculation processing includes conditional filtering, aggregation function and expression calculation; the optimization end generates a query plan based on the first access constraint and the query rewrite type, wherein the query rewrite type includes Filter matching rewrite, projection matching rewrite, aggregate column matching rewrite and Join rewrite; the optimization end sends the query plan to the execution end, and the execution end is used to feed back the query result generated after the query plan is executed to the user end.
[0179] Any combination of one or more computer-readable media may be used. A computer-readable medium may be a computer signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0180] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0181] The computer program code for performing the operations of the present invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to connect through the Internet). The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referenced to each other.
[0182] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0183] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0184] The above is a detailed introduction to the query processing method and device based on pre-calculation scenarios provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A query processing method based on a pre-calculation scenario, characterized in that: The method involves a user end, an optimization end, an execution end and a database, and the method includes: The optimization end receives the query request sent by the user end, and the user end is used to generate the query request according to the user demand and send the query request to the optimization end; The optimization end reads metadata in the database according to the query request, wherein the metadata includes a data table and an access constraint set; The optimization end performs pre-calculation processing according to the data in the data table to generate a first access constraint, wherein the pre-calculation processing includes condition filtering, aggregation function and expression calculation; The optimization end generates a query plan according to the first access constraint and the query rewriting type, wherein the query rewriting type includes filter matching rewriting, projection matching rewriting, aggregate column matching rewriting and join rewriting; The optimization end sends the query plan to the execution end, and the execution end is used to feed back the query results generated after the query plan is executed to the user end.
2. The method according to claim 1, characterized in that The pre-calculation process is performed based on the data in the data table to generate the first access constraint, wherein the pre-calculation process includes the steps of condition filtering, aggregation function and expression calculation, including: When the pre-calculation process is the conditional filtering, the optimization end determines the pre-processed data that meets the preset filtering condition from the data in the data table according to the preset filtering condition; The optimization end generates the first access constraint according to the preprocessed data.
3. The method according to claim 1, characterized in that The pre-calculation process is performed based on the data in the data table to generate the first access constraint, wherein the pre-calculation process includes the steps of condition filtering, aggregation function and expression calculation, including: The optimization end generates a first initial access constraint according to the data, and obtains a first expression set and a second expression set in the first initial access constraint; When the pre-calculation process is the aggregation function, the optimization end adds or modifies the preset aggregation function in the first expression set and the second expression set, and The first expression set after the preset aggregation function and the second expression set after the preset aggregation function generate the first access constraint; wherein the preset aggregation function includes containing a specified field or containing a specified expression.
4. The method according to claim 1, characterized in that: The pre-calculation process is performed based on the data in the data table to generate the first access constraint, wherein the pre-calculation process includes the steps of condition filtering, aggregation function and expression calculation, including: The optimization end generates a second initial access constraint according to the data, and obtains a third expression set and a fourth expression set in the second initial access constraint; When the pre-calculation process is the expression calculation, the optimization end obtains the target field according to the third expression set and the fourth expression set; The optimization end determines a target column corresponding to the data table according to the target field; The optimization end determines a target expression corresponding to the target column according to the target column; The optimization end generates the first access constraint by performing calculation according to the target expression.
5. The method according to claim 1, characterized in that The step of generating a query plan according to the first access constraint and the query rewriting type, wherein the query rewriting type includes filter matching rewriting, projection matching rewriting, aggregate column matching rewriting and join rewriting, comprises: When the query rewriting type is the Filter matching rewriting, the optimization end determines whether the result set generated by analyzing the query statement is a subset of the first access constraint, and if so, generates the query plan according to the first access constraint; or When the query rewriting type is the projection matching rewriting, the optimization end determines whether the projection expression in the analysis query statement is included in the first access constraint, and if so, generates the query plan according to the first access constraint; or, When the query rewrite type is cluster column matching rewrite, the optimization end determines the target aggregation function within the first access constraint, modifies the original aggregation function corresponding to the analysis query statement, and generates the query plan through the target aggregation function and the modified original aggregation function; or When the query rewrite type is Join rewrite, the optimizer determines the left and right nodes of the join operator. Whether the data of the point exists in the first access constraint, and if so, generating the query plan according to the first access constraint.
6. A query processing method based on pre-calculation scenario, characterized in that: The method involves a user end, an optimization end, an execution end and a database, and the method includes: The execution end receives the query plan sent by the optimization end, and the optimization end is used to send the query plan to the execution end; The execution end determines the target access constraint according to the query plan; The execution end determines the second target data in the data table according to the target access constraint; The execution end generates a query result according to the second target data; The execution end sends the query result to the user end, and the user end is used to receive the query result fed back by the execution end.
7. A query processing method based on pre-calculation scenario, characterized in that: The method involves a user end, an optimization end, an execution end and a database, and the method includes: The user terminal generates a query request according to user needs, and sends the query request to the optimization terminal, and the optimization terminal is used to receive the query request sent by the user terminal; The user end receives the query result sent by the execution end, and returns the query result to the corresponding target user. The execution end is used to feed back the query result to the user end.
8. A query processing device based on pre-calculation scenarios, characterized in that: The device involves a user end, an optimization end, an execution end and a database, and the device includes: A first sending module, configured for the optimization end to receive a query request sent by the user end, wherein the user end is configured to generate a query request according to user requirements and send the query request to the optimization end; A first reading module, configured for the optimization end to read metadata from the database according to the query request, wherein the metadata includes a data table and an access constraint set; The first generation module is used for the optimization end to perform pre-calculation processing based on the data in the data table to generate the first access constraint, wherein the pre-calculation processing includes conditional filtering, aggregation function and table Formula calculation; A second generation module is used for the optimization end to generate a query plan according to the first access constraint and the query rewriting type, wherein the query rewriting type includes Filter matching rewriting, projection matching rewriting, aggregate column matching rewriting and Join rewriting; The second sending module is used for the optimization end to send the query plan to the execution end, and the execution end is used to feed back the query results generated after the query plan is executed to the user end.
9. A query processing device based on pre-calculation scenarios, characterized in that: The device involves a user end, an optimization end, an execution end and a database, and the device includes: A third sending module, configured for the execution end to receive the query plan sent by the optimization end, and the optimization end to send the query plan to the execution end; A first determination module, used by the execution end to determine a target access constraint according to the query plan; A second determination module, configured for the execution end to determine second target data in the data table according to the target access constraint; A third generating module, used for the execution end to generate a query result according to the second target data; A fourth sending module is used for the execution end to send the query result to the user end, and the user end is used to receive the query result fed back by the execution end.
10. A query processing device based on pre-calculation scenarios, characterized in that: The device involves a user end, an optimization end, an execution end and a database, and the device includes: A fifth sending module, used for the user end to generate a query request according to user needs, and send the query request to the optimization end, and the optimization end is used to receive the query request sent by the user end; The return module is used for the user end to receive the query result sent by the execution end and return the query result to the corresponding target user. The execution end is used to feed back the query result to the user end.
Citation Information
Patent Citations
Querying big data by accessing small data
CN109074373A
Database materialized view construction system and method and system creation method
CN111597209A
Equivalence verification method and system for template database query plan
CN114756581A
Data Query Method and Apparatus, and Database System
US20180276277A1
Real-time analytical queries of a document store
US20190361897A1
Cited By
Method, device and equipment for optimizing performance of expression in graph database
CN120179868A
Query system supporting multiple data sources
CN121365068A
