A data query method and device
By utilizing pre-built parameters and the correspondence between storage files in a multi-storage system environment, matching and determining the storage file to be queried, and selecting the scheme with the lowest query overhead, the problem of low data query efficiency in multi-storage systems is solved, and efficient data query is achieved.
Patent Information
- Application Number
- CN202311695289.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-11
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2043-12-11
AI Technical Summary
When data generated by a business system is distributed and stored across multiple different types of storage systems, the efficiency of querying data from multiple storage systems is low.
By obtaining the index parameters and target parameters in the query requirements, and using the pre-built correspondence between parameters and storage files, the storage files to be queried are matched and determined. Based on these files, a query plan is generated, and finally, the plan with the minimum query cost is executed to obtain the target parameters.
It improves query efficiency, reduces query overhead, and optimizes the data query process in multi-storage system environments.
Smart Images

Figure CN117520269B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a data query method and apparatus. Background Technology
[0002] With the development of computer technology, more and more data has emerged, and correspondingly, more and more data storage technologies have also appeared. After data is generated, it can be stored in a corresponding data storage system using data storage technologies. In the subsequent data analysis stage, the corresponding data can be retrieved from the data storage system as needed.
[0003] As business systems become increasingly feature-rich, the types of business data also increase. Different types of business data may require different data storage technologies. Therefore, for a given business system, the business data it generates may be distributed and stored across multiple different types of storage systems.
[0004] Currently, when data generated by business systems is distributed and stored across multiple storage systems of different types, querying data from these systems is inefficient. Therefore, a solution is urgently needed to address this problem. Summary of the Invention
[0005] To solve, or at least partially solve, the above-mentioned technical problems, this application provides a data query method and apparatus.
[0006] In a first aspect, embodiments of this application provide a data query method, the method comprising:
[0007] Obtain the query requirements, which include: the index parameters used in the query and the target parameters queried based on the index parameters;
[0008] The index parameter and the target parameter are matched with a pre-built correspondence to determine the storage file to be queried, wherein: the correspondence is the correspondence between the parameter and the storage file storing the parameter, and the storage file to be queried includes the storage file storing the index parameter and the storage file storing the target parameter;
[0009] Based on the storage file to be queried, at least one query scheme that meets the query requirements is obtained, wherein each of the at least one query scheme is used to indicate the storage file to be queried based on the index parameters to obtain the target parameters, and the storage file to be queried based on the index parameters to obtain the target parameters is part or all of the storage files included in the storage file to be queried;
[0010] The query scheme with the lowest query cost among the at least one query schemes is executed to obtain the target parameter. The query cost of each query scheme is determined according to the storage system associated with the query scheme. The storage system associated with the query scheme includes the storage system corresponding to the storage file involved in the query scheme.
[0011] Optionally, the step of matching the index parameters and the target parameters with pre-built correspondences to determine the storage file to be queried includes:
[0012] The index parameters and the target parameters are matched with the pre-built correspondence to obtain multiple storage files that store both the index parameters and the target parameters, and these multiple storage files are determined as the storage files to be queried.
[0013] Based on the storage file to be queried, at least one query scheme that meets the query requirements is obtained, including:
[0014] Determine the query scheme corresponding to each of the multiple storage files.
[0015] Optionally, the target parameter includes a first parameter and a second parameter, and the step of matching the index parameter and the target parameter with a pre-built correspondence to determine the storage file to be queried includes:
[0016] The index parameter and the target parameter are matched with a pre-built correspondence to obtain a first storage file, a second storage file, and a third storage file. The first storage file stores the index parameter and the first parameter, the second storage file stores the index adoption number and the second parameter, and the third storage file stores the index parameter, the first parameter, and the second parameter.
[0017] Based on the storage file to be queried, at least one query scheme that meets the query requirements is obtained, including:
[0018] Based on the first storage file, the second storage file, and the third storage file, a first query scheme and a second query scheme are obtained. The first query scheme indicates how to query the target parameter based on the first storage file and the second storage file, and the third query scheme indicates how to query the target parameter based on the third storage file.
[0019] Optionally, the target parameter includes a third parameter, and the step of matching the index parameter and the target parameter with a pre-built correspondence to determine the storage file to be queried includes:
[0020] The index parameter and the target parameter are matched with the pre-built correspondence to obtain a fourth storage file containing the index parameter and the intermediate parameter, and a fifth storage file containing the intermediate parameter and the third parameter.
[0021] Based on the storage file to be queried, at least one query scheme that meets the query requirements is obtained, including:
[0022] Based on the fourth storage file and the fifth storage file, a fourth query scheme is obtained. The fourth query scheme indicates that the fourth storage file is first queried based on the index parameters, and then the fifth storage file is queried based on the intermediate parameters obtained from querying the fourth storage file, so as to obtain the third parameter.
[0023] Optionally, before executing the query scheme with the lowest query cost among the at least one query schemes to obtain the target parameter, the method further includes:
[0024] For each of the at least one query scheme, the query cost corresponding to the query scheme is determined based on the query cost value of the storage file involved in the query scheme. The storage file involved in the query scheme includes the target storage file, and the query cost value of the target storage file is determined according to the storage system corresponding to the target storage file.
[0025] Optionally, the target storage file includes at least one dimension of indicators, and the query cost value of the target storage file is determined based on the statistical values of each indicator in the at least one dimension of indicators and the weights of each indicator. The weights of each indicator are determined based on the storage system corresponding to the target storage file.
[0026] Optionally, executing the query scheme with the lowest query cost among the at least one query schemes to obtain the target parameter includes:
[0027] Based on the query statement format supported by each storage file involved in the query scheme, a query statement corresponding to each storage file is generated, and the query statement is executed to obtain the target parameter.
[0028] Secondly, embodiments of this application provide a data query device, the device comprising:
[0029] The acquisition unit is used to acquire query requirements, which include: the index parameters used in the query and the target parameters queried based on the index parameters;
[0030] A matching unit is used to match the index parameter and the target parameter with a pre-built correspondence to determine the storage file to be queried, wherein: the correspondence is the correspondence between the parameter and the storage file storing the parameter, and the storage file to be queried includes the storage file storing the index parameter and the storage file storing the target parameter;
[0031] The first determining unit is configured to obtain at least one query scheme that meets the query requirements based on the storage file to be queried, wherein each of the at least one query scheme is configured to indicate the storage file to be queried based on the index parameters to obtain the target parameters, and the storage file to be queried based on the index parameters to obtain the target parameters is part or all of the storage files included in the storage file to be queried;
[0032] The query unit is used to execute the query scheme with the lowest query cost among the at least one query schemes to query and obtain the target parameter. The query cost of each query scheme is determined according to the storage system associated with the query scheme. The storage system associated with the query scheme includes the storage system corresponding to the storage file involved in the query scheme.
[0033] Optionally, the matching unit is used for:
[0034] The index parameters and the target parameters are matched with the pre-built correspondence to obtain multiple storage files that store both the index parameters and the target parameters, and these multiple storage files are determined as the storage files to be queried.
[0035] The first determining unit is configured to:
[0036] Determine the query scheme corresponding to each of the multiple storage files.
[0037] Optionally, the target parameters include a first parameter and a second parameter, and the matching unit is used for:
[0038] The index parameter and the target parameter are matched with a pre-built correspondence to obtain a first storage file, a second storage file, and a third storage file. The first storage file stores the index parameter and the first parameter, the second storage file stores the index adoption number and the second parameter, and the third storage file stores the index parameter, the first parameter, and the second parameter.
[0039] The first determining unit is configured to:
[0040] Based on the first storage file, the second storage file, and the third storage file, a first query scheme and a second query scheme are obtained. The first query scheme indicates how to query the target parameter based on the first storage file and the second storage file, and the third query scheme indicates how to query the target parameter based on the third storage file.
[0041] Optionally, the target parameter includes a third parameter, and the matching unit is used for:
[0042] The index parameter and the target parameter are matched with the pre-built correspondence to obtain a fourth storage file containing the index parameter and the intermediate parameter, and a fifth storage file containing the intermediate parameter and the third parameter.
[0043] The first determining unit is configured to:
[0044] Based on the fourth storage file and the fifth storage file, a fourth query scheme is obtained. The fourth query scheme indicates that the fourth storage file is first queried based on the index parameters, and then the fifth storage file is queried based on the intermediate parameters obtained from querying the fourth storage file, so as to obtain the third parameter.
[0045] Optionally, the device further includes:
[0046] The second determining unit is configured to, before executing the query scheme with the minimum query cost among the at least one query schemes to obtain the target parameter, determine the query cost corresponding to each query scheme based on the query cost value of the storage file involved in the query scheme, wherein the storage file involved in the query scheme includes the target storage file, and the query cost value of the target storage file is determined according to the storage system corresponding to the target storage file.
[0047] Optionally, the target storage file includes at least one dimension of indicators, and the query cost value of the target storage file is determined based on the statistical values of each indicator in the at least one dimension of indicators and the weights of each indicator. The weights of each indicator are determined based on the storage system corresponding to the target storage file.
[0048] Optionally, the query unit is used for:
[0049] Based on the query statement format supported by each storage file involved in the query scheme, a query statement corresponding to each storage file is generated, and the query statement is executed to obtain the target parameter.
[0050] Thirdly, embodiments of this application provide an electronic device, the device including a processor and a memory;
[0051] The processor is configured to execute instructions stored in the memory to cause the device to perform the method as described in any one of the first aspects above.
[0052] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that instruct a device to perform the method as described in any one of the first aspects above.
[0053] Fifthly, embodiments of this application provide a computer program product that, when run on a computer, causes the computer to perform the method described in any of the first aspects above.
[0054] Compared with the prior art, the embodiments of this application have the following advantages:
[0055] This application provides a data query method, including: obtaining a query requirement, wherein the query requirement includes index parameters used for the query and target parameters queried based on the index parameters. In this application embodiment, the storage file to be queried can be determined by combining a pre-built correspondence between parameters and storage files storing the parameters. Specifically, the index parameters and target parameters can be matched with the aforementioned correspondence to determine the storage file to be queried. The storage file to be queried may include the storage file storing the index parameters and the storage file storing the target parameters. After determining the storage file to be queried, at least one query scheme that meets the query requirement can be obtained based on the storage file to be queried. Each of the at least one query scheme is used to indicate the storage file to be queried to obtain the target parameters based on the index parameters. For a certain query scheme, the storage file involved may be some or all of the storage files included in the storage file to be queried. The storage file involved in the query scheme refers to the storage file to be queried based on the index parameters, as indicated by the aforementioned query scheme. Therefore, the solution of this application embodiment eliminates the need for manually sorting through the storage files containing the target parameters to determine the query scheme. Instead, it determines the storage file to be queried based on the aforementioned correspondence, and correspondingly, determines at least one query scheme based on the storage file to be queried, thereby improving the efficiency of determining the query scheme. After obtaining the at least one query scheme, in order to minimize the query overhead while achieving the query objective, the query scheme with the lowest query overhead among the aforementioned at least one query scheme can be executed to retrieve the target parameter. Since different storage systems have different query performance, the query overhead required to query storage files in different storage systems also varies. In this application embodiment, the query overhead of each query scheme is determined based on the storage system associated with that query scheme, which includes the storage system corresponding to the storage file involved in the query scheme. In other words, using this solution, the query overhead of a query scheme can be determined by combining the query performance of the storage system, thereby selecting the query scheme with the lowest query overhead. In summary, the solution of this application embodiment can improve query efficiency and save query overhead when business data is distributed across multiple storage systems. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 A flowchart illustrating a data query method provided in an embodiment of this application;
[0058] Figure 2 This is a schematic diagram illustrating an exemplary application scenario provided in an embodiment of this application;
[0059] Figure 3 This is a schematic diagram illustrating another exemplary application scenario provided in the embodiments of this application;
[0060] Figure 4 This is a schematic diagram of the structure of a data query device provided in an embodiment of this application. Detailed Implementation
[0061] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0062] The inventors of this application discovered through research that when data generated by a business system is distributed and stored across multiple storage systems, the efficiency of retrieving data from these systems is low. This is because different storage systems support different query methods. These differences can be reflected in the different formats of the query statements.
[0063] Currently, when querying data (such as a specific parameter), users (e.g., R&D or operations personnel) can first manually confirm which storage system and corresponding storage file the parameter is stored in. They can then write a query statement applicable to that storage file to retrieve the parameter. Furthermore, considering that a given parameter can be applied to different data analysis scenarios, it can be stored in multiple storage systems.
[0064] However, this approach's query efficiency heavily relies on the user's familiarity with the storage system corresponding to the business system. In practice, however, users are unlikely to be thoroughly familiar with the storage files containing all parameters. This makes the aforementioned process of "manually confirming which storage file in which storage system the parameter is stored in, in order to further write a query statement applicable to that storage file" time-consuming, resulting in low data query efficiency.
[0065] Furthermore, for a given query requirement, when multiple query solutions exist, traditional techniques often randomly select one from these solutions. This random selection can result in significant query overhead. In other words, traditional techniques not only have low data query efficiency but also high data query costs.
[0066] To address the aforementioned issues, this application provides a data query method and apparatus.
[0067] The various non-limiting embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0068] Exemplary methods
[0069] See Figure 1 This figure is a flowchart illustrating a data query method provided in an embodiment of this application. The data query method provided in this embodiment can be applied to both server-side and client-side applications; this embodiment does not impose any specific limitations.
[0070] In this embodiment, the method may include, for example, the following steps: S101-S104.
[0071] S101: Obtain query requirements, which include: the index parameters used in the query and the target parameters for the query based on the index parameters.
[0072] In this embodiment of the application, the query request can be input by the user. As an example, the data query page includes a query request input area where the user can input their query request.
[0073] In this embodiment, the query requirement may include index parameters used for the query and target parameters queried based on those index parameters. As an example, the query requirement can be described in natural language. In other words, users can enter a query requirement described in natural language in the aforementioned query requirement input area, without needing to follow software code standards. For example, the query requirement could be: input a product identifier (ID), query the product's click-through rate, and the product's supplier.
[0074] S102: Match the index parameter and the target parameter with a pre-built correspondence to determine the storage file to be queried, wherein the correspondence is the correspondence between the parameter and the storage file including the parameter, and the storage file to be queried includes the storage file storing the index parameter and the storage file storing the target parameter.
[0075] After obtaining the query requirements, the pre-built correspondence can be used to determine the storage file to be queried that can meet the query requirements, so that the storage file to be queried can be used for subsequent queries.
[0076] In this embodiment, the correspondence is between a parameter and a storage file that stores the parameter. For example, during the data storage stage, the storage file that stores the parameter can be recorded, and the correspondence between the parameter and the storage file can be further preserved.
[0077] In one example, the correspondence between a parameter and the storage file that stores the parameter can be a correspondence between the identifier of the parameter and the identifier of the storage file. The identifier of the parameter can be, for example, the parameter name, and the identifier of the storage file can include two parts: one part is the storage system to which the storage file belongs, and the other part is the name of the storage file.
[0078] In this embodiment, the index parameter and the target parameter can be matched with a pre-built correspondence to determine the storage file to be queried. It is easy to understand that matching the index parameter with the aforementioned correspondence determines the storage file containing the index parameter. Matching the target parameter with the aforementioned correspondence determines the storage file containing the target parameter. The storage file to be queried may include both the storage file containing the index parameter and the storage file containing the target parameter. The storage file containing the target parameter and the storage file containing the index parameter may be the same or different; this embodiment does not impose specific limitations.
[0079] In one example, the aforementioned storage file to be queried may include multiple storage files, and each storage file stores both the index parameters and the query parameters.
[0080] In another example, where the target parameters include multiple parameters, the stored file may include an index parameter and some or all of the multiple parameters. Taking the target parameters including a first parameter and a second parameter as an example, in one example, the aforementioned stored file to be queried may include a first stored file, a second stored file, and a third stored file. The first stored file stores the index parameter and the first parameter; the second stored file stores the index parameter and the second parameter; and the third stored file stores the index parameter, the first parameter, and the second parameter.
[0081] In another example, the aforementioned storage file storing the index parameters and the storage file storing the target parameters can be different storage files. In a specific example, the target parameters include a third parameter, and the storage files to be queried include a fourth storage file and a fifth storage file. The fourth storage file stores the index parameters, and the fifth storage file stores the third parameter. Furthermore, in addition to storing the index parameters, the fourth storage file also stores intermediate parameters; similarly, the fifth storage file, in addition to storing the third parameter, also stores the intermediate parameters, which can serve as a bridge connecting the index parameters and the third parameter.
[0082] S103: Based on the storage file to be queried, at least one query scheme that meets the query requirements is obtained, wherein each of the at least one query scheme is used to indicate the storage file to be queried based on the index parameters to obtain the target parameters, and the storage file to be queried based on the index parameters to obtain the target parameters is part or all of the storage files included in the storage file to be queried.
[0083] After determining the storage file to be queried, a query scheme that meets the query requirements can be determined based on the storage file. As described above, considering that a certain parameter can be applied to different data analysis scenarios, this parameter can be stored in multiple storage systems. Therefore, based on the storage file to be queried, at least one query scheme that meets the query requirements can be determined.
[0084] For each of the at least one query scheme, it can be used to indicate the storage file required to fulfill the query requirement; that is, it can be used to indicate the storage file required to obtain the target parameter based on the index parameter. For any query scheme, the storage file to be queried can be part or all of the aforementioned storage files to be queried. For any query scheme, it can include three elements: query input, query file, and query result.
[0085] As described in S102, in one example, the storage file to be queried may include multiple storage files that store both the index parameters and the target parameters. In this case, a query scheme can be determined based on each of the multiple storage files. In this scenario, the query input for each query scheme is the index parameters, the query file is the storage file, and the query result is the target parameters.
[0086] For example: The query requirement is to input a product ID and query the product click-through rate. Storage system A's file A1 stores both the product ID and the product click-through rate, and storage system B's file B1 stores both the product ID and the product click-through rate. Therefore, we can determine query scheme 1: query storage system A's file A1. Query scheme 2: query storage system B's file B1.
[0087] As described in S102, in another example, the storage file to be queried may include a first storage file, a second storage file, and a third storage file. In this case, a first query scheme and a second query scheme can be determined based on the first storage file, the second storage file, and the third storage file. Specifically, the first query scheme can be determined based on the first storage file and the second storage file, and the first query scheme is used to indicate how to query the target parameter based on the first storage file and the second storage file. Specifically, the first query scheme is used to indicate how to query the first parameter based on the first storage file and how to query the second parameter based on the second storage file. The second query scheme is used to indicate how to query the first parameter and the second parameter based on the third storage file.
[0088] As described in S102, in another example, the storage file to be queried includes a fourth storage file and a fifth storage file. In this case, a fourth query scheme can be obtained based on the fourth and fifth storage files. Specifically, the query order of the fourth storage file and the fifth query file can be determined based on the dependency relationship between the index parameters, intermediate parameters, and the third parameter, thereby obtaining a fourth query scheme that reflects the query order and fulfills the query requirements. Specifically, the fourth query scheme can be used to instruct that the fourth storage file is queried first based on the index parameters, and then the fifth storage file is queried based on the intermediate parameters obtained from querying the fourth storage file to obtain the third parameter. It is easy to understand that the fourth query scheme includes two query steps executed sequentially. The first query step is to query the fourth storage file based on the index parameters to obtain the intermediate parameters. The query input of the first query step is the index parameters, the query file is the fourth storage file, and the query result is the intermediate parameters. The second query step is to query the fifth storage file based on the intermediate parameters to obtain the third parameter. The query input of the second query step is the intermediate parameters, the query file is the fifth storage file, and the query result is the third parameter.
[0089] S104: Execute the query scheme with the lowest query cost among the at least one query schemes to obtain the target parameter, wherein the query cost of each query scheme is determined according to the storage system associated with the query scheme, and the storage system associated with the query scheme includes the storage system corresponding to the storage file involved in the query scheme.
[0090] After determining the at least one query scheme, in order to minimize the query overhead used to obtain the target parameter, the query scheme with the lowest query overhead among the at least one query schemes can be executed to obtain the target parameter.
[0091] In one example, executing the query scheme with the lowest query cost can be implemented by outputting the query scheme with the lowest query cost, manually writing the query statement corresponding to the query scheme, and then running the query statement. In another example, the query statement corresponding to the query scheme with the lowest query cost can be automatically generated and executed to retrieve the target parameter. In the automatic generation of the query statement, the storage files involved in the query scheme can be determined first. Then, for each storage file, based on the three elements of the storage file (i.e., the aforementioned query input, query file, and query result) and the query statement format supported by the storage file, a query statement corresponding to each storage file can be generated. Accordingly, when executing the query statements corresponding to each storage file, the query order of each storage file can be considered when executing the corresponding query statement.
[0092] In one example, before executing S104, the query cost corresponding to each query scheme in the at least one query scheme can be determined. Then, the query costs corresponding to each query scheme are compared to determine the query scheme with the minimum query cost among the at least one query schemes.
[0093] In this embodiment, the query cost of each query scheme can be determined based on the storage system associated with that query scheme. As mentioned above, each query scheme can be used to instruct the query to obtain the storage file required to retrieve the target parameter based on the index parameters, and the storage file is stored in the storage system. Therefore, the storage system associated with the query scheme can be the storage system corresponding to the storage file involved in the query scheme. The storage file involved in the query scheme can be the storage file that the query scheme indicates needs to be queried. The storage system corresponding to the storage file refers to the storage system that stores the storage file.
[0094] In one example, a query scheme can be associated with at least one storage system. For instance, when all the storage files involved in the query scheme belong to the first storage system, the storage system associated with the query scheme can be the first storage system. As another example, when the storage files involved in the query scheme correspond to multiple storage systems, the storage systems associated with the query scheme can include multiple storage systems. For example, if the query scheme indicates a query for storage file 1 and storage file 2, where storage file 1 belongs to the first storage system and storage file 2 belongs to the second storage system, then the storage systems associated with the query scheme can include both the first and second storage systems.
[0095] In one example, at least one query scheme can be output, and the query cost of each query scheme in the at least one query scheme can be determined by manual analysis.
[0096] In another example, for any one of the at least one query schemes, the query cost of that query scheme can be determined based on the query cost value of the storage file involved in that query scheme. Here, the storage file involved in the query scheme refers to the storage file required to query for the target parameter based on the index parameters, as indicated by the query scheme. The cost value of the storage file can be used to indicate the cost required to query that storage file.
[0097] In a specific example, if the query plan involves a single storage file, the query cost of that single storage file can be determined as the query cost corresponding to the query plan. In another specific example, if the query plan involves multiple storage files, the sum of the query costs of all multiple storage files can be determined as the query cost corresponding to the query plan.
[0098] For ease of description, any storage file involved in the query scheme is referred to as the "target storage file." It is readily understood that the target storage file can be one of the aforementioned first, second, third, fourth, or fifth storage files. In this embodiment, the query overhead value of the target storage file can be determined based on the storage system corresponding to the target storage file.
[0099] In one example, the query cost value for the target storage file can be an empirical value, the setting of which can depend on the storage system corresponding to the target storage file.
[0100] In another example, the target storage file may include at least one dimension of metrics, which may be related to query cost. In this case, the query cost value of the target storage file can be determined based on the statistical values and weights of each of the at least one dimension of metrics. For example, for any metric, the query cost value can be obtained by multiplying the statistical value and the weight of the metric, and then summing the query cost values of each metric to obtain the query cost value of the target storage file.
[0101] In this embodiment, the weights corresponding to each indicator can be determined based on the storage system corresponding to the target stored file. For the same indicator, since the query performance of different storage systems is different, the weight value of the indicator corresponding to different storage systems is also different.
[0102] This application does not specifically limit the aforementioned metrics, which include, but are not limited to, query concurrency, query time, query accuracy, number of times selected, and storage cost. Next, with reference to Table 1 below, the query overhead for the target stored file will be explained. Table 1
[0103] index Statistical value Weight Query cost value Query concurrency 0.1 100 10 Query time 0.5 -50 -25 Query accuracy 1 1000 1000 Number of times selected 0.1 100 10 Storage costs 0.5 -100 -50
[0104] According to Table 1, the query cost values corresponding to each indicator are summed to obtain the query cost value of the target file as 945.
[0105] As described above, the solution of this application embodiment eliminates the need for manually sorting through the storage files containing the target parameters to determine the query scheme. Instead, the storage file to be queried can be determined based on the aforementioned correspondence. Correspondingly, at least one query scheme is determined based on the storage file to be queried, thereby improving the efficiency of determining the query scheme. After obtaining the at least one query scheme, in order to minimize query overhead while achieving the query objective, the query scheme with the lowest corresponding query overhead among the aforementioned at least one query scheme can be executed to retrieve the target parameter. In summary, the solution of this application embodiment can both improve query efficiency and save query overhead.
[0106] The data query method provided by the embodiments of this application has been described above. Next, the data query method provided by the embodiments of this application will be described in conjunction with specific scenarios. In the following scenario, a stored file will be used as an example for illustration.
[0107] See Figure 2 This figure is a schematic diagram of an exemplary application scenario provided by an embodiment of this application.
[0108] like Figure 2As shown, storage system 1 stores product tables A and B. Product table A stores product ID, click-through rate, and exposure rate. Product table B stores product ID and sales volume. Storage system 2 stores product table C, which stores product ID, click-through rate, and sales volume.
[0109] The query requirement is: input a product ID, and query the click-through rate and transaction volume.
[0110] Based on product ID, click-through rate, and transaction volume, query to obtain product tables A, B, and C, and get... Figure 2 The two query schemes are shown.
[0111] Query scheme 1 is as follows: Based on the product ID, query the click rate from product A table, and based on the product ID, query the transaction volume from product B table.
[0112] Query option 2 is to retrieve the click-through rate and sales volume from product table C based on the product ID.
[0113] Calculate the query costs of query scheme 1 and query scheme 2. The calculation results indicate that the query cost of query scheme 1 is less than that of query scheme 2. Therefore, query scheme 1 can be executed to obtain the corresponding query results.
[0114] See Figure 3 This figure is a schematic diagram of another exemplary application scenario provided by the embodiments of this application.
[0115] like Figure 3 As shown, storage system 1 stores product tables A and B. Product table A stores product ID, click-through rate, and exposure rate. Product table B stores product ID and sales volume. Storage system 2 stores product table C, which stores product ID, click-through rate, and sales volume. Additionally, storage system 1 also stores product tables D and E. Product table D stores product ID and merchant ID, while product table E stores merchant ID and merchant name.
[0116] The query requirement is: input a product ID, and query the click-through rate, transaction volume, and merchant name.
[0117] Based on product ID, click-through rate, and transaction volume, queries retrieve product tables A, B, C, D, and E, and obtain... Figure 3 The two query schemes are shown.
[0118] Query scheme 1 is as follows: Based on the product ID, retrieve the click-through rate from product table A, and based on the product ID, retrieve the sales volume from product table B (click-through rate and sales volume correspond). Figure 3The output result shown is 1). Additionally, first, the merchant ID is obtained by querying the product table D based on the product ID; then, the merchant name is obtained by querying the product table E based on the merchant ID. Figure 3 The output result shown is 2). Finally, output result 1 and output result 2 are merged to obtain the final output result.
[0119] Query option 2 is: Based on the product ID, retrieve the click-through rate and sales volume (corresponding to...) from product table C. Figure 3 The output result shown is 1). Additionally, first, the merchant ID is obtained by querying the product table D based on the product ID; then, the merchant name is obtained by querying the product table E based on the merchant ID. Figure 3 The output result shown is 2). Finally, output result 1 and output result 2 are merged to obtain the final output result.
[0120] Calculate the query costs of query scheme 1 and query scheme 2. The calculation results indicate that the query cost of query scheme 1 is less than that of query scheme 2. Therefore, query scheme 1 can be executed to obtain the corresponding query results.
[0121] Exemplary device
[0122] Based on the methods provided in the above embodiments, this application also provides an apparatus, which will be described below with reference to the accompanying drawings.
[0123] See Figure 4 The figure is a schematic diagram of the structure of a data query device provided in an embodiment of this application. The device 400 may specifically include, for example, an acquisition unit 401, a matching unit 402, a first determination unit 403, and a query unit 404.
[0124] The acquisition unit 401 is used to acquire query requirements, which include: the index parameters used for the query and the target parameters queried based on the index parameters.
[0125] The matching unit 402 is used to match the index parameter and the target parameter with a pre-built correspondence to determine the storage file to be queried, wherein: the correspondence is the correspondence between the parameter and the storage file storing the parameter, and the storage file to be queried includes the storage file storing the index parameter and the storage file storing the target parameter;
[0126] The first determining unit 403 is used to obtain at least one query scheme that meets the query requirements based on the storage file to be queried, wherein each of the at least one query scheme is used to indicate the storage file to be queried based on the index parameters to obtain the target parameters, and the storage file to be queried based on the index parameters to obtain the target parameters is part or all of the storage files included in the storage file to be queried.
[0127] The query unit 404 is used to execute the query scheme with the lowest query cost among the at least one query schemes to query and obtain the target parameter. The query cost of each query scheme is determined according to the storage system associated with the query scheme. The storage system associated with the query scheme includes the storage system corresponding to the storage file involved in the query scheme.
[0128] Optional,
[0129] The matching unit 402 is used for:
[0130] The index parameters and the target parameters are matched with the pre-built correspondence to obtain multiple storage files that store both the index parameters and the target parameters, and these multiple storage files are determined as the storage files to be queried.
[0131] The first determining unit 403 is used for:
[0132] Determine the query scheme corresponding to each of the multiple storage files.
[0133] Optionally, the target parameter includes a first parameter and a second parameter;
[0134] The matching unit 402 is used for:
[0135] The index parameter and the target parameter are matched with a pre-built correspondence to obtain a first storage file, a second storage file, and a third storage file. The first storage file stores the index parameter and the first parameter, the second storage file stores the index adoption number and the second parameter, and the third storage file stores the index parameter, the first parameter, and the second parameter.
[0136] The first determining unit 403 is used for:
[0137] Based on the first storage file, the second storage file, and the third storage file, a first query scheme and a second query scheme are obtained. The first query scheme indicates how to query the target parameter based on the first storage file and the second storage file, and the third query scheme indicates how to query the target parameter based on the third storage file.
[0138] Optionally, the target parameter includes a third parameter;
[0139] The matching unit 402 is used for:
[0140] The index parameter and the target parameter are matched with the pre-built correspondence to obtain a fourth storage file containing the index parameter and the intermediate parameter, and a fifth storage file containing the intermediate parameter and the third parameter.
[0141] The first determining unit 403 is used for:
[0142] Based on the fourth storage file and the fifth storage file, a fourth query scheme is obtained. The fourth query scheme indicates that the fourth storage file is first queried based on the index parameters, and then the fifth storage file is queried based on the intermediate parameters obtained from querying the fourth storage file, so as to obtain the third parameter.
[0143] Optionally, the device further includes:
[0144] The second determining unit is configured to, before executing the query scheme with the minimum query cost among the at least one query schemes to obtain the target parameter, determine the query cost corresponding to each query scheme based on the query cost value of the storage file involved in the query scheme, wherein the storage file involved in the query scheme includes the target storage file, and the query cost value of the target storage file is determined according to the storage system corresponding to the target storage file.
[0145] Optionally, the target storage file includes at least one dimension of indicators, and the query cost value of the target storage file is determined based on the statistical values of each indicator in the at least one dimension of indicators and the weights of each indicator. The weights of each indicator are determined based on the storage system corresponding to the target storage file.
[0146] Optionally, the query unit 404 is used for:
[0147] Based on the query statement format supported by each storage file involved in the query scheme, a query statement corresponding to each storage file is generated, and the query statement is executed to obtain the target parameter.
[0148] Since the device 400 is a device corresponding to the data query method provided in the above method embodiments, the specific implementation of each unit of the device 400 is based on the same concept as in the above method embodiments. Therefore, the specific implementation of each unit of the device 400 can be referred to the relevant descriptions in the above method embodiments, and will not be repeated here.
[0149] This application also provides an electronic device, which includes a processor and a memory;
[0150] The processor is used to execute instructions stored in the memory so that the device performs the data query method provided in the above method embodiments.
[0151] This application provides a computer-readable storage medium including instructions that instruct a device to execute the data query method provided in the above method embodiments.
[0152] This application also provides a computer program product that, when run on a computer, causes the computer to execute the data query method provided in the above method embodiments.
[0153] 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.
[0154] 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.
[0155] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A data query method, characterized by, The method comprises: obtaining a query requirement, the query requirement comprising an index parameter used for querying and a target parameter queried based on the index parameter, wherein the target parameter comprises a first parameter and a second parameter; matching the index parameter and the target parameter with a pre-constructed corresponding relationship respectively to determine a to-be-queried storage file, comprising: matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to obtain a first storage file, a second storage file and a third storage file, wherein the corresponding relationship is a corresponding relationship between a parameter and a storage file storing the parameter, the to-be-queried storage file comprises a storage file storing the index parameter and a storage file storing the target parameter, the first storage file stores the index parameter and the first parameter, the second storage file stores the index parameter and the second parameter, and the third storage file stores the index parameter, the first parameter and the second parameter; obtaining at least one query scheme meeting the query requirement according to the to-be-queried storage file, comprising: obtaining a first query scheme and a second query scheme according to the first storage file, the second storage file and the third storage file, the first query scheme indicating that the target parameter is queried based on the first storage file and the second storage file, and the second query scheme indicating that the target parameter is queried based on the third storage file, wherein each query scheme in the at least one query scheme is used for indicating a storage file required for querying the target parameter based on the index parameter, and the storage file required for querying the target parameter based on the index parameter is part or all of the to-be-queried storage file; executing a query scheme with minimum query overhead in the at least one query scheme to query the target parameter, wherein the query overhead of each query scheme is determined according to a storage system associated with the query scheme, the storage system associated with the query scheme comprises a storage system corresponding to a storage file involved in the query scheme, the storage file involved in the query scheme comprises a target storage file, the target storage file comprises at least one dimension indicator, and a query overhead value of the target storage file is determined according to statistical values corresponding to each indicator in the at least one dimension indicator and weights corresponding to each indicator respectively, and the weights corresponding to each indicator are determined according to a storage system corresponding to the target storage file.
2. The method of claim 1, wherein, The matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to determine a to-be-queried storage file comprises: matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to obtain a plurality of storage files storing both the index parameter and the target parameter, and determining the plurality of storage files as the to-be-queried storage file; obtaining at least one query scheme meeting the query requirement according to the to-be-queried storage file comprises: obtaining a first query scheme and a second query scheme according to the first storage file, the second storage file and the third storage file, the first query scheme indicating that the target parameter is queried based on the first storage file and the second storage file, and the second query scheme indicating that the target parameter is queried based on the third storage file, wherein each query scheme in the at least one query scheme is used for indicating a storage file required for querying the target parameter based on the index parameter, and the storage file required for querying the target parameter based on the index parameter is part or all of the to-be-queried storage file; respectively determine a query scheme corresponding to each of the plurality of storage files respectively.
3. The method of claim 1, wherein, The target parameter comprises a third parameter, and the matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to determine a storage file to be queried comprises: matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to obtain a fourth storage file storing the index parameter and an intermediate parameter, and a fifth storage file storing the intermediate parameter and the third parameter; obtaining at least one query scheme meeting the query requirement according to the storage file to be queried comprises: obtaining a fourth query scheme according to the fourth storage file and the fifth storage file, the fourth query scheme indicating that the fourth storage file is queried based on the index parameter first, and then the fifth storage file is queried based on the intermediate parameter obtained by querying the fourth storage file, to obtain the third parameter.
4. The method of claim 1, wherein, Before executing the query scheme corresponding to the minimum query overhead in the at least one query scheme to query the target parameter, the method further comprises: for each query scheme in the at least one query scheme, determining the query overhead corresponding to the query scheme based on the query overhead value of the storage file involved in the query scheme, and the query overhead value of the target storage file is determined according to the storage system corresponding to the target storage file.
5. The method of claim 1, wherein, The execution of the query scheme corresponding to the minimum query overhead in the at least one query scheme to query the target parameter comprises: generating a query statement corresponding to each of the storage files according to the query statement format supported by each of the storage files involved in the query scheme, and executing the query statement to query the target parameter.
6. A data query apparatus, characterized by comprising: The device comprises: an acquisition unit configured to acquire a query requirement, the query requirement comprising an index parameter used for querying and a target parameter queried based on the index parameter, wherein the target parameter comprises a first parameter and a second parameter; a matching unit configured to match the index parameter and the target parameter with a pre-constructed corresponding relationship respectively to determine a storage file to be queried, wherein the matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to determine the storage file to be queried comprises matching the index parameter and the target parameter with the pre-constructed corresponding relationship respectively to obtain a first storage file, a second storage file and a third storage file, wherein the corresponding relationship is a corresponding relationship between a parameter and a storage file storing the parameter, the storage file to be queried comprises a storage file storing the index parameter and a storage file storing the target parameter, the first storage file stores the index parameter and the first parameter, the second storage file stores the index parameter and the second parameter, and the third storage file stores the index parameter, the first parameter and the second parameter; The first determining unit is configured to obtain at least one query scheme meeting the query requirement according to the to-be-queried storage file; the obtaining of the at least one query scheme meeting the query requirement according to the to-be-queried storage file comprises: obtaining a first query scheme and a second query scheme according to the first storage file, the second storage file and the third storage file, the first query scheme indicating that the target parameter is obtained by querying based on the first storage file and the second storage file, and the second query scheme indicating that the target parameter is obtained by querying based on the third storage file, wherein each query scheme in the at least one query scheme is used to indicate a storage file required by querying to obtain the target parameter based on the index parameter, and the storage file required by querying to obtain the target parameter based on the index parameter is part or all of the storage files included in the to-be-queried storage file; The querying unit is configured to execute a query scheme with minimum query overhead in the at least one query scheme to obtain the target parameter, wherein the query overhead of each query scheme is determined according to a storage system associated with the query scheme, the storage system associated with the query scheme comprises a storage system corresponding to a storage file involved in the query scheme, the storage file involved in the query scheme comprises a target storage file, the target storage file includes at least one dimension index, and a query overhead value of the target storage file is determined according to statistical values of each index in the at least one dimension index and respective weights of each index, and the respective weights of each index are determined according to a storage system corresponding to the target storage file.
7. An electronic device, comprising: The device comprises a processor and a memory; The processor is configured to execute instructions stored in the memory, so that the device executes the method in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The instructions instruct the device to execute the method in any one of claims 1-5.
Citation Information
Patent Citations
DOT in-fragment secondary index method and DOT in-fragment secondary index system
CN104133867A
Data storage method, device and equipment and computer readable storage medium
CN116821140A