Data query method, device, equipment, storage medium and program product
By identifying user query intent and dynamically selecting query strategies, combined with adaptive sampling decision-making and statistical error calculation, the problem of excessively long processing times in traditional data query methods is solved. This achieves a seamless connection between fast preview and accurate calculation, improving data analysis efficiency and resource utilization.
Patent Information
- Application Number
- CN202611093987.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-11-20
AI Technical Summary
Traditional full-scan data query methods are too time-consuming in big data analysis, making it difficult to meet the interactive needs of rapid trial and error. Moreover, existing technologies lack intelligent recognition of query intent, leading to resource waste and increased costs.
By acquiring user behavior pattern information, identifying query intent, and dynamically selecting full query or sampling query strategies, combined with data distribution characteristics and query type, an adaptive sampling decision engine and statistical error calculation are adopted to achieve a seamless connection between fast preview and accurate calculation.
It improves data analysis efficiency, reduces resource consumption from repeated queries, optimizes the allocation of computing resources, and provides a reliability assessment of query results.
Smart Images

Figure CN123138296A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data, and in particular to a data query method, apparatus, device, storage medium, and program product. Background Technology
[0002] In big data analytics scenarios, data analysts frequently need to execute exploratory queries to validate hypotheses, adjust analytical models, or uncover data trends. However, traditional full-data-scan query methods struggle to meet the interactive needs of rapid trial and error, and with massive datasets, single queries can be excessively time-consuming.
[0003] Therefore, there is an urgent need for a data query method to improve the query speed of exploratory queries in order to improve the efficiency of data analysis. Summary of the Invention
[0004] This application provides a data query method, apparatus, device, storage medium, and program product to improve the efficiency of data analysis.
[0005] Firstly, this application provides a data query method, including:
[0006] In response to user data query requests, obtain user behavior pattern information;
[0007] The query intent is determined based on the data query request and the user behavior pattern information;
[0008] The query strategy is determined based on the query intent, and the query strategy is either a full query or a sample query.
[0009] The query is executed according to the query strategy to obtain the target query result.
[0010] Optionally, determining the query intent based on the data query request and the user behavior pattern information includes:
[0011] Parse the syntax structure of the data query request to determine the query type;
[0012] The required level of precision for data queries is determined based on the query type and the user behavior pattern.
[0013] The query type and the required level of precision are defined as the query intent.
[0014] Optionally, determining the query strategy based on the query intent includes:
[0015] When the required accuracy level is the target level, the query strategy is determined to be a full query.
[0016] If the required accuracy level is lower than the target level, the query strategy is determined to be a sampling query, and the sampling parameters of the sampling query are determined according to the query type.
[0017] Optionally, the sampling parameters include a sampling algorithm and a sampling rate; determining the sampling parameters for the sampling query based on the query type includes:
[0018] Determine the data distribution characteristics of the target data table corresponding to the data query request;
[0019] The sampling algorithm is determined based on the data distribution characteristics and the query type;
[0020] The sampling rate is determined based on the data distribution characteristics and the required accuracy level.
[0021] Optionally, data query methods also include:
[0022] The statistical error is determined based on the query strategy and the target query result;
[0023] The confidence level of the target query result is determined based on the statistical error.
[0024] Optionally, the number of sampling algorithms is multiple, and the step of executing the query according to the query strategy to obtain the target query result includes:
[0025] According to each sampling algorithm and the corresponding sampling rate, a sampling query is executed to obtain the candidate query results corresponding to each sampling algorithm.
[0026] Determine the statistical error corresponding to each candidate query result, and determine the candidate query result with the smallest statistical error as the target query result.
[0027] Optionally, data query methods also include:
[0028] Store the data query request and the target query result in the query database;
[0029] In response to a user's first data query request, if the first data query request matches a second data query request in the query database, the first query result corresponding to the second data query request is determined as the second query result of the first data query request.
[0030] Optionally, when the query strategy is a sampling query, the method further includes:
[0031] Execute the query according to the full query and get the full query results;
[0032] The target query result is updated based on the full query result.
[0033] Secondly, this application provides a data query device, including an acquisition module, an intent determination module, a strategy determination module, and a query module, wherein:
[0034] The acquisition module is used to respond to user data query requests and acquire user behavior pattern information;
[0035] The intent determination module is used to determine the query intent based on the data query request and the user behavior pattern information;
[0036] The strategy determination module is used to determine a query strategy based on the query intent, wherein the query strategy is a full query or a sample query.
[0037] The query module is used to execute queries according to the query strategy and obtain the target query results.
[0038] Optionally, the intent determination module is further configured to:
[0039] Parse the syntax structure of the data query request to determine the query type;
[0040] The required level of precision for data queries is determined based on the query type and the user behavior pattern.
[0041] The query type and the required level of precision are defined as the query intent.
[0042] Optionally, the strategy determination module is further configured to:
[0043] When the required accuracy level is the target level, the query strategy is determined to be a full query.
[0044] If the required accuracy level is lower than the target level, the query strategy is determined to be a sampling query, and the sampling parameters of the sampling query are determined according to the query type.
[0045] Optionally, the sampling parameters include a sampling algorithm and a sampling rate; the strategy determination module is further configured to:
[0046] Determine the data distribution characteristics of the target data table corresponding to the data query request;
[0047] The sampling algorithm is determined based on the data distribution characteristics and the query type;
[0048] The sampling rate is determined based on the data distribution characteristics and the required accuracy level.
[0049] Optionally, the query module is further used for:
[0050] The statistical error is determined based on the query strategy and the target query result;
[0051] The confidence level of the target query result is determined based on the statistical error.
[0052] Optionally, the number of sampling algorithms may be multiple, and the query module is further used for:
[0053] According to each sampling algorithm and the corresponding sampling rate, a sampling query is executed to obtain the candidate query results corresponding to each sampling algorithm.
[0054] Determine the statistical error corresponding to each candidate query result, and determine the candidate query result with the smallest statistical error as the target query result.
[0055] Optionally, the query module is further used for:
[0056] Store the data query request and the target query result in the query database;
[0057] In response to a user's first data query request, if the first data query request matches a second data query request in the query database, the first query result corresponding to the second data query request is determined as the second query result of the first data query request.
[0058] Optionally, when the query strategy is a sampling query, the query module is further configured to:
[0059] Execute the query according to the full query and get the full query results;
[0060] The target query result is updated based on the full query result.
[0061] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0062] The memory stores computer-executed instructions;
[0063] The processor executes computer execution instructions stored in the memory, causing the processor to perform the data query method as described in the first aspect and / or various possible embodiments of the first aspect.
[0064] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the data query method as described in the first aspect and / or various possible embodiments of the first aspect.
[0065] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the data query method as described in the first aspect and / or various possible embodiments of the first aspect.
[0066] The data query method, apparatus, device, storage medium, and program products provided in this application respond to user data query requests, obtain user behavior pattern information to accurately identify the user's true query needs, and provide a basis for subsequent data analysis; determine the query intent based on the data query request and user behavior pattern information, thereby distinguishing the user's tolerance for error; determine the query strategy as a full query or a sample query based on the query intent, and realize the dynamic allocation of computing resources; execute the query according to the query strategy to obtain the target query results. By dynamically executing the query strategy, the efficiency of data analysis is improved. Attached Figure Description
[0067] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0068] Figure 1 A flowchart illustrating a data query method provided in this application embodiment. Figure 1 ;
[0069] Figure 2 A flowchart illustrating a data query method provided in this application embodiment. Figure 2 ;
[0070] Figure 3 This is a schematic diagram of the structure of a data query device provided in an embodiment of this application;
[0071] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0072] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0073] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0074] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of the relevant data all comply with the relevant laws, regulations, and standards of the relevant countries and regions, have taken necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation access points for users to choose to authorize or refuse.
[0075] Furthermore, the technical solution involved in this application, which involves big data analysis of user information (including but not limited to personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.) and the use of artificial intelligence technology for automated decision-making, and makes decisions that have a significant impact on personal rights based on the results of automated decision-making, provides users with corresponding operation entry points for users to choose to agree to or reject the results of automated decision-making; if the user chooses to reject, the process will proceed to the expert decision-making process.
[0076] It should be noted that the data query method, apparatus, equipment, storage medium and program products provided in this application can be used in the field of big data, or in any field other than big data. The application fields of the data query method, apparatus, equipment, storage medium and program products in this application are not limited.
[0077] In large-scale data analytics scenarios, data analysts frequently need to execute exploratory queries to validate hypotheses, adjust analytical models, or uncover data trends. Full-scan queries are time-consuming, hindering rapid iterative trial and error and impacting data analysis efficiency. Furthermore, users often need to quickly obtain approximate results to guide subsequent precise queries when performing initial exploratory queries, but current technologies lack the intelligent ability to recognize query intent and cannot dynamically match the needs of rapid preview with precise calculations. Simultaneously, enterprise-level data platforms typically face resource bottlenecks; repeatedly executing low-value trial queries consumes significant computing resources, leading to resource waste and escalating costs.
[0078] Based on the above, existing data query methods are inefficient for data analysis.
[0079] To address the aforementioned technical issues, this application provides a data query method that proposes a query intent recognition mechanism. First, it determines the query intent by analyzing data query requests and user behavior patterns to differentiate between exploratory analysis and precise decision-making needs. Then, addressing the lack of expertise in sampling strategies, an adaptive sampling decision engine is designed to dynamically select the optimal sampling algorithm based on data distribution characteristics and query type. To resolve the issue of result reliability, the inventors introduce a statistical error calculation and confidence assessment module, quantifying result deviations using indicators such as the coefficient of variation and confidence intervals. Finally, through progressive query control and cache reuse management, a seamless connection between rapid preview and precise calculation is achieved, reducing resource consumption from repeated queries and thus improving data analysis efficiency.
[0080] The execution entity in this application embodiment can be a data query device or a control device for the data query device. The control device for the data query device can be implemented through software and / or hardware. For example, the control device for the data query device can be a processor within the data query device.
[0081] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0082] Figure 1 A flowchart illustrating a data query method provided in this application embodiment. Figure 1 .like Figure 1 As shown, the method includes:
[0083] S101. In response to the user's data query request, obtain user behavior pattern information.
[0084] A user's data query request is a raw data query statement entered by the user through a data query terminal. For example, viewing recent order details is used for preliminary data exploration; total order volume and total sales are calculated for business metrics; and daily order volume is analyzed to identify business trends.
[0085] User behavior pattern information can be a set of features stored in the data query terminal, including users' historical queries, operations, preferences, and business attributes. It is behavioral data that characterizes users' analysis habits, accuracy tolerance, and usage scenarios. For example, user behavior pattern information can include two types of information: static attribute behavior and dynamic historical behavior. Static attribute behavior includes information such as user roles, job permissions, and common business scenarios, while dynamic historical behavior includes information such as historical query records, interaction behaviors, and operation frequency.
[0086] In this step, the user submits a data query request through the data query terminal. The terminal then uses the user's identifier to obtain the user's behavioral pattern information, thereby determining the user's behavioral characteristics. Obtaining this behavioral pattern information compensates for information gaps caused by parsing a single data query statement, enabling more accurate identification of the user's query needs.
[0087] S102. Determine the query intent based on the data query request and user behavior pattern information.
[0088] The query intent is determined by combining the data query statement and user behavior pattern information to identify the user's true business purpose, accuracy tolerance, response speed requirements, and other information for this query.
[0089] For example, for exploratory analysis, data query conditions can be repeatedly adjusted for trial and error, and low-precision data analysis can be accepted to quickly obtain query results; for decision support queries, high-precision data analysis is required; for anomaly detection queries, a high recall rate needs to be ensured in order to find illegal or abnormal data.
[0090] S103. Determine the query strategy based on the query intent.
[0091] The query strategy is either full query or sample query.
[0092] The full query strategy involves completely scanning all raw data in the target data table that meets the query conditions, without performing any data extraction, truncation, or sampling.
[0093] The sampling query strategy does not scan all data, but extracts a subset of data by specifying a sampling algorithm and sampling rate, and outputs an approximate result.
[0094] Determining the query strategy based on query intent enables intelligent resource scheduling. With a sampling query strategy, only a small amount of data can be scanned, reducing computational resource consumption, while sufficient computational resources are allocated to the full query. Differentiated resource allocation is achieved by determining the query strategy.
[0095] S104. Execute the query according to the query strategy to obtain the target query result.
[0096] When performing a sampled query according to a query strategy, the original data query statement can be rewritten according to the query strategy, and the query logic can be embedded. Then, the rewritten query statement can be submitted to the query terminal to obtain the target query result.
[0097] The target query result is the final query result displayed to the user. For full interpolation, the target query result is the exact calculation result, and there is no need to label the error and confidence level; for sampled queries, it is necessary to display the approximate statistics calculated from the sample set, as well as information such as the number of rows and sample size of the scanned data.
[0098] The data query method provided in this application responds to a user's data query request by acquiring user behavior pattern information to accurately identify the user's true query needs, providing a basis for subsequent data analysis; it determines the query intent based on the data query request and user behavior pattern information, thereby differentiating the user's tolerance for error; it determines the query strategy as a full query or a sample query based on the query intent, realizing dynamic allocation of computing resources; and it executes the query according to the query strategy to obtain the target query result. By dynamically executing the query strategy, the efficiency of data analysis is improved.
[0099] Figure 2 A flowchart illustrating a data query method provided in this application embodiment. Figure 2 The following is combined Figure 2 To further clarify the intent of the query, such as... Figure 2 As shown, the query intent is determined based on the data query request and user behavior pattern information, including:
[0100] S201. Parse the syntax structure of the data query request to determine the query type.
[0101] The syntactic structure of a data query request is a hierarchical structure composed of standard syntactic units. For example, parsing the syntactic structure of a data query request can generate an abstract syntax tree through a syntax parser. From the abstract syntax tree, the semantics of each data query request can be identified, thereby distinguishing information such as ordinary fields, aggregate functions, time grouping, and relationships.
[0102] Query types can include detailed queries, aggregation queries, or trend queries. Specifically, detailed queries aim to obtain specific, row-by-row raw data records, suitable for scenarios where users need to view specific rows or columns of data; aggregation queries include aggregate functions such as summation, counting, or averaging, which can be used for indicator statistics, suitable for scenarios where users need to summarize data; trend queries are used to analyze the patterns and trends of data changes over time, suitable for scenarios where users need to analyze the trends of data changes over time.
[0103] By parsing the syntactic structure of a data query request, the query type can be determined, thereby providing semantic features for determining the query intent.
[0104] S202. Determine the required level of precision for data queries based on query type and user behavior patterns.
[0105] Precision level requirements measure the tolerance for errors in query results. For example, precision level requirements can be categorized into three levels: high, medium, and low. A high precision level allows for no approximate errors and requires a full query for accurate calculations, suitable for data query scenarios such as financial reconciliation, monthly settlements, or audit reports. A medium precision level allows for small errors but must ensure the recall of abnormal or niche data, suitable for application scenarios such as risk control anomaly investigation and preliminary business verification. A low precision level allows for larger errors, prioritizing query speed, suitable for data analysis scenarios where analysts repeatedly adjust parameters for exploration and quickly identify trends.
[0106] S203. Determine the query type and precision level requirements as the query intent.
[0107] Query intent is a data query business scenario tag determined based on the query type and required precision level. For example, if the query type is an aggregation query and the precision level requirement is high, the query intent can be identified as a decision support scenario, in which users need precise values for business decisions. If the query type is a trend query or a detailed query and the precision level requirement is low, the query intent can be identified as an exploratory analysis scenario, in which users need to repeatedly adjust conditions and try and fail. If the query type is a detailed query and the precision level requirement is medium, the query intent can be identified as an anomaly investigation scenario.
[0108] By parsing the syntax structure of data query requests, the query type is determined, and the required precision level for the data query is determined based on user behavior patterns. The precision level requirements are determined by integrating both query type and user behavior patterns to accurately differentiate error tolerance. Determining the query type and precision level requirements as query intent provides data support for determining the query strategy, achieving multi-dimensional identification of query intent.
[0109] As one implementation method, given a defined accuracy level requirement, a query strategy is determined based on the query intent. This includes: if the accuracy level requirement is the target level, the query strategy is a full query; if the accuracy level requirement is lower than the target level, the query strategy is a sampled query, and the sampling parameters for the sampled query are determined based on the query type.
[0110] The target level is a pre-configured threshold value in the system, serving as the dividing line between whether to use sampling queries. For example, if the accuracy requirements are high, medium, and low, the target level can be set to high, and the accuracy requirements for the medium and low levels can be set to be lower than the target level.
[0111] If the query strategy is determined to be a full query, there is no need to generate any sampling parameters. The full identifier is directly output and sent to the execution module to perform the data query.
[0112] When the query strategy is a sampling query, the sampling parameters can be determined based on the query type. For example, when the query type is a trend query, the sampling parameter is determined to be time window stratified sampling; when the query type is a grouping and aggregation query, stratified sampling is used; and when the query type is a detail query, block sampling is used.
[0113] The query strategy is determined based on the required accuracy level, either as a full query or a sampled query. This enables intelligent matching of sampling algorithms, addressing the issue of insufficient expertise in manually determining query strategies. High-precision data query needs are differentiated by accuracy level, and sampling algorithms are automatically matched to overcome the shortcomings of distorted samples and high resource consumption associated with manual sampling.
[0114] As one implementation method, sampling parameters include sampling algorithm and sampling rate; the sampling parameters for the sampled query are determined according to the query type, including: determining the data distribution characteristics of the target data table corresponding to the data query request; determining the sampling algorithm based on the data distribution characteristics and query type; and determining the sampling rate based on the data distribution characteristics and accuracy level requirements.
[0115] Sampling algorithms are specific data extraction methods determined to achieve a balance between query speed and result accuracy, and are tailored to different data query scenarios and data distribution characteristics.
[0116] The target data table is the main data source for the data query; it is the specific data table that the current query operation points to.
[0117] Data distribution characteristics are a set of quantitative indicators obtained from pre-sampling analysis of the target data table. For example, data distribution characteristics can include the total amount of data, the distribution of values in each column, and the degree of data skewness; where the total amount of data can be the total number of rows of all valid data in the table; the distribution of values in each column can be the maximum or minimum value of the field, the proportion of null values, the frequency of enumerated values, the distribution of continuous numerical intervals, or the cardinality of unique values, etc.; the degree of data skewness can measure the severity of uneven data distribution.
[0118] The sampling rate is the ratio of the sample size to the total data size in the target data table. The sampling rate can be calculated using the following formula:
[0119] (1)
[0120] Among them, the baseline sampling rate is a constant statically configured by the data query system and does not change with a single query. The precision coefficient is a value determined according to the precision level requirements. The higher the precision level, the larger the coefficient and the higher the sampling rate. The data volume coefficient is determined according to the data volume in the target data table. The larger the data volume, the smaller the coefficient, in order to reduce the sampling rate and save resources. The upper limit sampling rate is the maximum value of the system sampling rate to avoid sampling close to the full amount and losing the query acceleration effect.
[0121] For example, determining the sampling algorithm based on data distribution characteristics and query type may include: determining random sampling as the sampling algorithm when the data distribution is uniform and the query type is an aggregate query; and determining stratified sampling as the sampling algorithm when the data distribution is significantly skewed and the query type is an aggregate query.
[0122] By analyzing the data distribution characteristics of the target data table, the sampling algorithm and sampling rate are determined, enabling intelligent adaptive selection of the sampling algorithm while balancing performance and sample quality. Adaptive sampling decisions based on the actual data distribution of the data table solve the problems of skewness and sample distortion that are imperceptible in manual sampling. It can significantly shorten query time and reduce cluster resource consumption while ensuring sample reliability.
[0123] The relevant technologies do not provide statistical error calculation and confidence assessment mechanisms, making it difficult for users to quantify the accuracy of query results, leading to misuse or abandonment of sampling results and affecting decision-making efficiency.
[0124] To address the aforementioned issues, the data query method provided in this application further includes: determining a statistical error based on a query strategy and a target query result; and determining the confidence level of the target query result based on the statistical error.
[0125] Statistical error is an estimated deviation value calculated from the sampled sample, sampling parameters, and sample metadata. It is used to measure the degree of deviation between the sampling results and the true total value.
[0126] When the query strategy is full query, the target query result is the full and accurate calculation result with no estimation bias, so there is no need to calculate the confidence level.
[0127] When the query type included in the query strategy is an aggregate query, the statistical error can be calculated as follows:
[0128] For count queries, statistical error can be represented by relative error:
[0129] (2)
[0130] The absolute error is the absolute value of the difference between the target query result and the actual value in the target data table, where the actual value is the corresponding value in the target data table.
[0131] For summation queries, the statistical error can be determined using the coefficient of variation:
[0132] (3)
[0133] Here, the standard deviation is the standard deviation of the target query results, and the mean is the arithmetic mean of the corresponding data in the target data table.
[0134] For mean-based queries, the statistical error can be determined using confidence intervals:
[0135] (4)
[0136] Among them, the sample mean is the sample mean in the target query results, the Z critical value is a multiple used to define the "normal fluctuation range" and its value can be 1.96, and the standard error is the sampling fluctuation of the sample mean itself, which can be determined based on the population standard deviation and sample size.
[0137] For example, the confidence level of a target query result can be determined based on the statistical error in the following ways: if the statistical error is less than 3%, the target query result is considered to have high confidence and can be used for trend judgment or preliminary query; if the statistical error is between 3% and 10%, the target query result is considered to have medium confidence and can only be used as a reference for data analysis direction, not for precise decision-making; if the statistical error is greater than 10%, the target query result is considered to have low confidence, prompting the user to increase the sampling rate or switch to full query.
[0138] By quantifying the deviation of query results, the problem of unknown reliability of existing data query results is solved. Statistical errors are quantified through mathematical formulas and standardized confidence levels are divided, transforming abstract deviations into user-readable quantitative indicators. This addresses the deficiency of traditional query results having no error reference, allowing users to clearly understand the reliability of the results.
[0139] As one implementation, embodiments of this application can also use multiple sampling algorithms to perform data queries in parallel. In the case of parallel data queries, there are multiple sampling algorithms. Queries are executed according to a query strategy to obtain the target query result, including: executing sampling queries according to each sampling algorithm and its corresponding sampling rate to obtain candidate query results for each sampling algorithm; determining the statistical error corresponding to each candidate query result; and determining the candidate query result with the smallest statistical error as the target query result.
[0140] The candidate query results are the sample datasets and index values produced by each sampling algorithm after it is executed independently. Each set of algorithms corresponds to a set of independent candidate results.
[0141] In parallel data querying, sampling queries are executed in parallel based on different sampling algorithms and corresponding sampling rates. Multiple data query statements are executed concurrently, scanning data independently without interference. After obtaining candidate query results for each sampling algorithm, the statistical error of each candidate query result is determined according to the query strategy. The candidate result with the smallest absolute value of statistical error is selected, and this result, along with its corresponding algorithm, error, and confidence level, is encapsulated and returned to the user as the final target query result.
[0142] By executing multiple sampling algorithms in parallel, multiple candidate query results are obtained, and the statistical error of each query result is calculated. The sample with the lowest error is automatically selected and output, avoiding the result distortion caused by the mismatch between a single algorithm and the data distribution, and greatly improving the reliability of the sampling results.
[0143] To address the issues in existing technologies where low-value trial-and-error queries frequently trigger full scans, consuming significant computational resources, and similar queries cannot reuse historical results, further exacerbating resource waste, the data query method also includes: storing data query requests and target query results in a query database; responding to a user's first data query request, and if the first data query request matches a second data query request in the query database, determining the first query result corresponding to the second data query request as the second query result of the first data query request.
[0144] The query database is a storage medium for all historical query records, corresponding query results, query feature fingerprints, data table versions, and confidence tags. Query feature fingerprints are identifiers calculated based on the data query statement, target data table, table version, and query structure.
[0145] The first data query request is the data query request submitted by the user this time, and the second data query request is the historical query records stored in the query database.
[0146] The first query result is the historical data query result corresponding to the second data query request. The second query result is the data query result of the current query request determined based on the first data query request.
[0147] If the first data query request matches the second data query request in the query database, the stored result corresponding to the historical second query request is directly reused as the output of the new request, and the first query result is used as the second query result of the first data query request.
[0148] Optionally, matching the first data query request with the second data query request in the query database can include an exact match, more lenient query conditions, and more stringent query conditions. In the case of an exact match, the first query result corresponding to the second data query request can be used as the second query result of the first data query request. In the case of more lenient query conditions, the scope of the second data query request can cover that of the first data query request, so the first query result corresponding to the second data query request can be used as the second query result of the first data query request. In the case of more stringent query conditions, incremental queries can be performed by comparing the data query conditions added in the first data query request compared to the second data query request. If the incremental query result is determined, the first query result is partially reused, and the incremental query content in the first query result is updated based on the incremental query result to obtain the second query result corresponding to the first data query request.
[0149] In this embodiment, when the first data query request matches the second data query request in the query database, the target query result stored in the query database is read directly, thereby reducing the resource overhead of repeated queries and improving data analysis efficiency.
[0150] As one implementation method, this application embodiment also supports incremental querying. When using incremental querying, a sample query can be used to pre-obtain the target query results, which are then returned to the user for preview. A full query task is then issued in the background, and the target query results are updated based on the full query results obtained from the full query. When the query strategy is sample querying, the data query method further includes: executing the query according to the full query to obtain the full query results; and updating the target query results based on the full query results.
[0151] If the full query results are obtained, the deviation between the target query results obtained using the sampled query and the full query results is calculated. If the deviation is less than a preset deviation threshold, the target query results cached in the query database are updated using the full query results. If the deviation is greater than the preset deviation threshold, a message is sent to the user to push the full query results. For example, the user is prompted that "the background accurate calculation has been completed. The sampled preview results deviate significantly from the actual values. It is recommended to view the official accurate data." After the user clicks the notification, the page displays a detailed comparison of the sampled query results and the full query results, the actual deviation, and the confidence level difference.
[0152] By setting a progressive query strategy, the needs of both fast preview and accurate query are taken into account. The calculation deviation of the sampled query is quantified by calculating the deviation of the results, and the adaptive sampling strategy is optimized. The cache of the target query results in the query database is updated according to the full query results, reducing redundant calculations when query results are reused. Users are reminded in a tiered manner to avoid the risk of sampling misjudgment.
[0153] Figure 3 This is a schematic diagram of the structure of a data query device provided in an embodiment of this application, as shown below. Figure 3 As shown, a data query device 30 provided in this application embodiment includes: an acquisition module 301, an intent determination module 302, a strategy determination module 303, and a query module 304, wherein:
[0154] The acquisition module 301 is used to acquire user behavior pattern information in response to the user's data query request;
[0155] The intent determination module 302 is used to determine the query intent based on the data query request and user behavior pattern information.
[0156] The strategy determination module 303 is used to determine the query strategy based on the query intent, which is either a full query or a sample query.
[0157] The query module 304 is used to execute queries according to the query strategy and obtain the target query results.
[0158] Optionally, the intent determination module 302 is also used for:
[0159] Parse the syntax structure of the data query request to determine the query type;
[0160] Determine the required level of precision for data queries based on query type and user behavior patterns;
[0161] Define the query type and precision level requirements as the query intent.
[0162] Optionally, the strategy determination module 303 is also used for:
[0163] Given that the required accuracy level is the target level, the query strategy is determined to be a full query.
[0164] When the required accuracy level is lower than the target level, the query strategy is determined to be sampling query, and the sampling parameters of the sampling query are determined according to the query type.
[0165] Optionally, the sampling parameters include the sampling algorithm and the sampling rate; the strategy determination module 303 is also used for:
[0166] Determine the data distribution characteristics of the target data table corresponding to the data query request;
[0167] The sampling algorithm is determined based on the data distribution characteristics and query type;
[0168] The sampling rate is determined based on the data distribution characteristics and accuracy requirements.
[0169] Optionally, query module 304 is also used for:
[0170] The statistical error is determined based on the query strategy and the target query results;
[0171] The confidence level of the target query results is determined based on statistical error.
[0172] Optionally, the number of sampling algorithms can be multiple, and the query module 304 is also used for:
[0173] According to each sampling algorithm and its corresponding sampling rate, the sampling query is executed to obtain the candidate query results corresponding to each sampling algorithm.
[0174] Determine the statistical error corresponding to each candidate query result, and select the candidate query result with the smallest statistical error as the target query result.
[0175] Optionally, query module 304 is also used for:
[0176] Store the data query request and the target query result in the query database;
[0177] In response to a user's first data query request, if the first data query request matches a second data query request in the query database, the first query result corresponding to the second data query request is determined as the second query result of the first data query request.
[0178] Optionally, when the query strategy is a sampling query, the query module 304 is also used for:
[0179] Execute the query according to the full query and get the full query results;
[0180] Update the target query results based on the full query results.
[0181] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 4 As shown, the electronic device of this embodiment may include: at least one processor 401, and a memory 402 communicatively connected to the at least one processor; wherein, the memory 402 stores instructions that can be executed by the at least one processor 401, and the instructions are executed by the at least one processor 401 to cause the electronic device to perform the method as described in any of the above embodiments.
[0182] Alternatively, the memory 402 can be either standalone or integrated with the processor 401.
[0183] The implementation principle and technical effects of the electronic device provided in this embodiment can be found in the foregoing embodiments, and will not be repeated here.
[0184] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method of any of the foregoing embodiments.
[0185] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the method of any of the foregoing embodiments.
[0186] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0187] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0188] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0189] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.
[0190] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.
[0191] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0192] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0193] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0194] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A data query method, characterized in that, The method includes: In response to user data query requests, obtain user behavior pattern information; The query intent is determined based on the data query request and the user behavior pattern information; The query strategy is determined based on the query intent, and the query strategy is either a full query or a sample query. The query is executed according to the query strategy to obtain the target query result.
2. The method according to claim 1, characterized in that, Determining the query intent based on the data query request and the user behavior pattern information includes: Parse the syntax structure of the data query request to determine the query type; The required level of precision for data queries is determined based on the query type and the user behavior pattern. The query type and the required level of precision are defined as the query intent.
3. The method according to claim 2, characterized in that, The step of determining the query strategy based on the query intent includes: When the required accuracy level is the target level, the query strategy is determined to be a full query. If the required accuracy level is lower than the target level, the query strategy is determined to be a sampling query, and the sampling parameters of the sampling query are determined according to the query type.
4. The method according to claim 3, characterized in that, The sampling parameters include the sampling algorithm and the sampling rate; determining the sampling parameters for the sampling query based on the query type includes: Determine the data distribution characteristics of the target data table corresponding to the data query request; The sampling algorithm is determined based on the data distribution characteristics and the query type; The sampling rate is determined based on the data distribution characteristics and the required accuracy level.
5. The method according to any one of claims 1-4, characterized in that, The method further includes: The statistical error is determined based on the query strategy and the target query result; The confidence level of the target query result is determined based on the statistical error.
6. The method according to claim 4, characterized in that, The number of sampling algorithms is multiple, and the step of executing the query according to the query strategy to obtain the target query result includes: According to each sampling algorithm and the corresponding sampling rate, a sampling query is executed to obtain the candidate query results corresponding to each sampling algorithm. Determine the statistical error corresponding to each candidate query result, and determine the candidate query result with the smallest statistical error as the target query result.
7. The method according to any one of claims 1-4, characterized in that, The method further includes: Store the data query request and the target query result in the query database; In response to a user's first data query request, if the first data query request matches a second data query request in the query database, the first query result corresponding to the second data query request is determined as the second query result of the first data query request.
8. The method according to any one of claims 1-4, characterized in that, When the query strategy is a sampling query, the method further includes: Execute the query according to the full query and get the full query results; The target query result is updated based on the full query result.
9. A data query device, characterized in that, The device includes: The acquisition module is used to respond to user data query requests and acquire user behavior pattern information; The intent determination module is used to determine the query intent based on the data query request and the user behavior pattern information; The strategy determination module is used to determine a query strategy based on the query intent, wherein the query strategy is a full query or a sample query. The query module is used to execute queries according to the query strategy and obtain the target query results.
10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 8.
12. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 8.
