A data query method and device
By analyzing the number of dimensions of data query requests and selecting an appropriate database management system, Kylin solves the problem of complexity and accuracy in processing high-dimensional data queries, achieves efficient and accurate data queries, and improves user experience and development efficiency. .
Patent Information
- Application Number
- CN202011085404.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-12
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-10-12
AI Technical Summary
The Kylin OLAP tool has a bottleneck in processing the number of data dimensions, making high-dimensional data query requests complex to process or impossible to analyze, and the dimension splitting method may lead to inaccurate query results.
By analyzing the number of query condition field dimensions in the data query request, the appropriate target database management system is determined to process the query request, thereby ensuring that the query request can be accurately processed regardless of the number of dimensions, and using a combination of multiple database management systems to simplify System building and cost reduction.
It improves the efficiency of query analysis of data query requests, enhances the development efficiency and user experience of the database, and ensures the accuracy and trustworthiness of query results.
Smart Images

Figure CN112434057B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data query method and device. Background Art
[0002] Kylin is one of the widely used OLAP (Online Analytical Processing) tools. It has the ability to query and analyze data at the level of tens of billions or more, can provide a standard SQL interface, and can perform interactive real-time data analysis. Its performance is higher than that of ordinary data warehouses (such as Hive). At present, many companies have chosen Kylin for OLAP tools. However, as a leader among OLAP tools, Kylin has certain limitations in the number of dimensions of data it processes (for example, the current upper limit of the number of dimensions of data processed by Kylin is 64), that is, there is a big bottleneck in the number of dimensions supported by Kylin. Usually, the amount of data to be statistically analyzed is not large, but the dimensions of the data are very large (for example, more than one hundred dimensions). For this type of data to be statistically analyzed, Kylin cannot process it normally.
[0003] At present, in order to solve the problem that Kylin has certain limitations in processing the number of dimensions of data, Kylin is usually used to split the dimensions of the data to be statistically analyzed to solve the problem of too many dimensions of the data to be statistically analyzed. However, this method of splitting dimensions using Kylin may require splitting the query analysis request into dozens or even hundreds of cubes (a data structure defined internally by Kylin to represent data cubes) for query analysis requests with extremely many dimensions. At the same time, the data query must be accurately located on the specified cube, otherwise the query data will be inaccurate, resulting in unreliable query results. Therefore, there is an urgent need for an effective solution to the problem that there are too many dimensions in the query analysis request, which makes the analysis of big data analysis software such as Kylin too complicated or impossible to analyze. Summary of the invention
[0004] The present invention provides a data query method and device, which can improve the pain point that Kylin cannot normally process and analyze data query requests when the dimensions of the data query requests are too many, and can improve the convenience of querying and reading data in the database based on the data query request, improve the development efficiency of the database, and improve the user experience of data query.
[0005] In a first aspect, the present invention provides a data query method, which is applied to a data query system, wherein the data query system includes several different types of database management systems, and the method includes:
[0006] Get data query request;
[0007] Determine the number of dimensions of the query condition field corresponding to the data query request;
[0008] Determining a target database management system according to the number of dimensions of the query condition field, wherein the target database management system is any target database management system among several database management systems;
[0009] Based on the target database management system, a data query result corresponding to the data query request is determined.
[0010] In a second aspect, the present invention provides a data query device, which is applied to a data query system, wherein the data query system includes several different types of database management systems, and the device includes:
[0011] A request acquisition unit, used for acquiring a data query request;
[0012] A dimension determination unit, used to determine the number of dimensions of the query condition field corresponding to the data query request;
[0013] A system determination unit, configured to determine a target database management system according to the number of dimensions of the query condition field, wherein the target database management system is any one of a number of database management systems;
[0014] The result determination unit is used to determine the data query result corresponding to the data query request based on the target database management system.
[0015] In a third aspect, the present invention provides a readable medium, comprising execution instructions. When a processor of an electronic device executes the execution instructions, the electronic device executes any method described in the first aspect.
[0016] In a fourth aspect, the present invention provides an electronic device, comprising a processor and a memory storing execution instructions, wherein when the processor executes the execution instructions stored in the memory, the processor executes any method described in the first aspect.
[0017] It can be seen from the above technical scheme that the method provided by the present invention is applied to a data query system, and the data query system includes several different types of database management systems. Specifically, the method provided by the present invention can determine the number of dimensions of the query condition field corresponding to the data query request by analyzing the data query request, so that according to the number of dimensions of the query condition field, the target database management system that can process the data query request is determined, thereby ensuring that no matter how many dimensions of the query condition field corresponding to the data query request, the data query system can perform query analysis processing on the data query request to obtain the data query result corresponding to the data query request. In this way, the present invention can use a solution for the use of several different types of database management systems to improve the pain point that Kylin cannot normally process and analyze data query requests when there are too many dimensions in the data query request, and because the system construction and query method corresponding to the solution provided by the present invention are relatively simple, it can improve the query analysis efficiency for data query requests while ensuring cost reduction, thereby improving the convenience of querying and reading data in the database based on data query requests, improving the development efficiency of the database, and improving the user experience of data query.
[0018] The further effects of the above-mentioned non-conventional preferred manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the existing technical solutions, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0020] Figure 1 A schematic diagram of a framework of an exemplary application scenario provided by an embodiment of the present invention;
[0021] Figure 2 A flowchart of a data query method provided by an embodiment of the present invention;
[0022] Figure 3 A schematic diagram of a flow chart of another data query method provided by an embodiment of the present invention;
[0023] Figure 4 A schematic diagram of a flow chart of another data query method provided by an embodiment of the present invention;
[0024] Figure 5 A schematic diagram of the structure of a data query device provided by an embodiment of the present invention;
[0025] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] In order to solve the problem in the prior art that there are too many dimensions in the query analysis request to be queried, which causes the analysis of big data analysis software such as Kylin to be too complicated or unable to be analyzed. The present invention provides a data query method, which can be applied to a data query system, and the data query system includes several different types of database management systems. Specifically, the method provided by the present invention can determine the number of dimensions of the query condition field corresponding to the data query request by analyzing the data query request, so that according to the number of dimensions of the query condition field, the target database management system that can process the data query request is determined, thereby ensuring that no matter how many dimensions of the query condition field corresponding to the data query request is, it can be ensured that the data query system can perform query analysis processing on the data query request to obtain the data query result corresponding to the data query request. In this way, the present invention can use a solution used in conjunction with several different types of database management systems to improve the pain point that Kylin cannot normally process and analyze data query requests when there are too many dimensions in the data query request, and because the system construction and query method corresponding to the solution provided by the present invention are relatively simple, it can ensure that the query analysis efficiency of the data query request can be improved while ensuring the reduction of costs, thereby improving the convenience of querying and reading data in the database based on the data query request, improving the development efficiency of the database, and improving the user experience of data query.
[0028] For example, the embodiments of the present invention can be applied to Figure 1The data query system architecture scenario shown. In the system architecture scenario, a client 101 (such as various mobile terminals such as smart phones and tablet computers), a server 102 and several different types of database management systems (such as a first database management system 103 and a second database management system 104) are included, wherein the client 101 is connected to the server 102 in communication, and the server 102 is connected to the first database management system 103 and the second database management system 104 respectively. Specifically, a user can input a data query request through the client 101, and the client 101 can send the data query request to the server 102; after the server 102 receives the data query request, the server 102 can determine the number of dimensions of the query condition field corresponding to the data query request, and determine the target database management system (such as the first database management system 103 or the second database management system 104) according to the number of dimensions of the query condition field; then, the target database management system can determine the data query result corresponding to the data query request according to the data query request, and the target database management system can return the data query result to the client 101 through the server 102, so that the client 101 can display the data query result to the user. In this way, it is ensured that no matter how many dimensions the query condition fields corresponding to the data query request have, it can be ensured that the data query system can perform query analysis and processing on the data query request to obtain the data query result corresponding to the data query request.
[0029] It is understandable that, in the above application scenario, although the actions of the implementation mode of the present invention are described as being performed by the server 102 and the target database management system, these actions can also be performed by the client 101 and the target database management system (i.e., the actions performed by the server 102 are also performed by the client 101). The present invention is not limited in terms of the execution subject, as long as the actions disclosed in the implementation mode of the present invention are performed. It can be seen that the system architecture corresponding to the solution provided by the present invention is relatively simple, so that the query analysis efficiency for data query requests can be improved while ensuring cost reduction, thereby improving the convenience of querying and reading data in the database based on data query requests, improving the development efficiency of the database, and improving the user experience of data query.
[0030] Various non-limiting embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
[0031] See also Figure 2 , shows a data query method in an embodiment of the present invention, the method is applied to a data query system, and the data query system includes several different types of database management systems. In this embodiment, the method may include the following steps:
[0032] S201: Obtain a data query request.
[0033] In this embodiment, the data query request can be understood as an instruction for querying data from a database. In one possible implementation, the data query request may include the field content corresponding to the data to be queried, the data table to be queried, and / or the constraint content corresponding to the data to be queried, as well as other content (such as the grouping method of the query results, etc.). It should be emphasized that in an application scenario, the data query request may be a medical data query request, that is, the field content in the data query request may include fields related to medical data, such as consultation time, number of visits, disease type, etc.
[0034] It should be noted that, in one implementation, the statement of the data query request may be a structured query language (SQL). For example, assuming that the data query request is an SQL query request, and the data query request is "select gender, count(*) as PV from table where time> start time and time< end time group by gender", then the field content corresponding to the data to be queried in the data query request is "gender, count(*) as PV", the data table to be queried is "table", the constraint content corresponding to the data to be queried is "time> start time and time< end time", and the grouping method of the query result is "group by gender".
[0035] As an example, when a user needs to query data, the user can input a query statement that conforms to the writing rules of the data query request through the terminal according to actual needs. Thus, the terminal can determine the data query request based on the query statement, and the terminal can send the data query request to the server that processes as the middle layer so that the server can perform subsequent processing.
[0036] S202: Determine the number of dimensions of the query condition field corresponding to the data query request.
[0037] Among them, the query condition field in the data query request can be understood as the field used to query data in the data query request. It should be emphasized that the query condition field in the data query request can also be called a dimension; dimension is a term in OLAP, which represents a classification method of data. For example, common dimensions include time, age, gender, education, disease, etc.; and the number of values under a certain dimension can be called the cardinality of the dimension, referred to as the cardinality. Taking the dimension of gender as an example, the enumeration values corresponding to gender are male and female, and the cardinality under the dimension of gender is 2. Taking the dimension of disease as an example, the enumeration values corresponding to the disease may include hypertension, diabetes, nephritis, gastritis, etc. In medicine, if the disease is not classified in a standard way, there may be hundreds of thousands or millions of different names, that is, the cardinality of the disease is millions of types; the value of data under a certain dimension (such as the number of data under the dimension) can be called an indicator. Common indicators may be PV (bai Page View), UV (Unique Visitor), number of orders, number of active users, etc.
[0038] In this embodiment, after obtaining the data query request, a rule can be written based on the statement of the data query request to count the query condition fields in the data query request and determine the number of dimensions of the query condition fields in the data query request. For example, after determining the number of query condition fields in the data query request, the number of query condition fields can be used as the number of dimensions of the query condition fields in the data query request. Continue to use the data query request as an SQL query request, and the data query request is "select gender, count (*) as PV from table where time> start time and time < end time group by gender" as an example; since the fields used to query data in the data query request are gender (gender) and time, where the cardinality of the gender dimension is 2, and the indicator is the value corresponding to each enumeration value under the gender dimension, that is, PV; therefore, it can be determined that the query condition fields in the data query request are 2, and thus the number of dimensions of the query condition fields in the data query request can be determined to be 2.
[0039] S203: Determine the target database management system according to the number of dimensions of the query condition field.
[0040] In this embodiment, the data query system may include several different types of database management systems. In one implementation, the types of the multiple database management systems in the data query system in this embodiment may be different from each other, so the upper limits of the dimensions of the data processed by each database management system in the data query system may be different. It is understandable that since the upper limits of the dimensions of the data processed by each database management system in the data query system are different, it can be ensured that no matter how many dimensions of the query condition field corresponding to the data query request is, there is a database management system in the data query system that can process the number of dimensions and can perform query analysis processing on the data query request.
[0041] As an example, after determining the number of dimensions of the query condition field, the database management system that can process the data query request can be determined based on the number of dimensions of the query condition field and the upper limit of the dimensions of the data processed by each database management system in the data query system, and the database management system is used as the target database management system. It can be understood that the target database management system is any target database management system among the several database management systems.
[0042] For example, in the data query system, the server may first determine a database management system whose upper dimension limit for processing data is greater than and closest to the number of dimensions of the query condition field, then use the database management system as the target database management system, and then send the data query request to the target database management system.
[0043] S204: Determine a data query result corresponding to the data query request based on the target database management system.
[0044] In this embodiment, after receiving the data query request, the target database management system can perform data query in the database in the target database management system according to the data query conditions in the data query request, thereby obtaining the data query result corresponding to the data query request.
[0045] As an example, the target database management system may first determine the target data table according to the data table to be queried in the data query request, wherein the database in the target database management system stores several data tables, and each data table has several data items, and the table fields of the data table may have several fields. Then, the target database management system may determine the corresponding fields in the table fields in the target data table according to the field contents corresponding to the data to be queried in the data query request, so that several data items that conform to the determined fields, or several data items that conform to the determined fields and satisfy the constraint conditions corresponding to the data to be queried may be used as the data query results corresponding to the data query request.
[0046] Continuing with the example that the data query request is an SQL query request, and the data query request is "select gender, count(*) as PV from table where time> start time and time< end time group by gender"; the target database management system can first determine the table table in its database, and then determine the field "gender" in the table fields of the table table, and then extract a number of data including the value under the field "gender", and then, according to the number of data whose values under the field "gender" are "male" and "female" respectively, statistics can be performed, and the statistical result can be obtained as "male 67, female 87", and then the statistical result of "male 67, female 87" can be determined as the data query result corresponding to the data query request.
[0047] In one implementation of this embodiment, after S204, the target database management system can return the data query result to the server, and the server returns the data query result to the client, so that the client can display the data query result to the user, so that the user can obtain the data query result corresponding to the data query request.
[0048] It should be emphasized that the data stored in the respective databases of the various database management systems in the data query system may be completely the same, partially the same, partially different, or completely different. In this embodiment, no limitation is made to this.
[0049] It can be seen from the above technical scheme that the method provided by the present invention is applied to a data query system, and the data query system includes several different types of database management systems. Specifically, the method provided by the present invention can determine the number of dimensions of the query condition field corresponding to the data query request by analyzing the data query request, so that according to the number of dimensions of the query condition field, the target database management system that can process the data query request is determined, thereby ensuring that no matter how many dimensions of the query condition field corresponding to the data query request, the data query system can perform query analysis processing on the data query request to obtain the data query result corresponding to the data query request. In this way, the present invention can use a solution for the use of several different types of database management systems to improve the pain point that Kylin cannot normally process and analyze data query requests when there are too many dimensions in the data query request, and because the system construction and query method corresponding to the solution provided by the present invention are relatively simple, it can improve the query analysis efficiency for data query requests while ensuring cost reduction, thereby improving the convenience of querying and reading data in the database based on data query requests, improving the development efficiency of the database, and improving the user experience of data query.
[0050] Figure 2 What is shown is only a basic embodiment of the method of the present invention. By performing certain optimization and expansion on this basis, other preferred embodiments of the method can be obtained.
[0051] like Figure 3 FIG. 1 is another specific embodiment of the data query method of the present invention. Figure 2 Based on the corresponding embodiment, S202 and S203 are further described, that is, S202 includes S302, and S203 includes S303-S305. In this embodiment, the method specifically includes the following steps:
[0052] S301: Obtain a data query request.
[0053] It should be noted that S301 in this embodiment is Figure 2 The corresponding step S201 is the same as that in the embodiment. Therefore, in this embodiment, S301 is not described again, and the details can be found in the introduction of S201.
[0054] S302: Determine the number of dimensions of the query condition field corresponding to the data query request according to the number of field dimensions in the field selection statement of the data query request, or the number of field dimensions in the field selection statement and the constraint condition statement of the data query request.
[0055] In this embodiment, the data query request may include a field selection statement, or a field selection statement and a constraint statement, that is, the field selection statement of the data query request may include a field selection statement, or a field selection statement and a constraint statement. The field selection statement may be understood as the field content that needs to be read from the data table to be queried in the data query request, and it can be understood that the fields in the field selection statement are the fields that need to be reflected in the data query result corresponding to the data query request; the constraint statement may be understood as the data screening condition added on the basis of the field selection statement in order to improve the accuracy of the data query result.
[0056] Next, the field selection statement and constraint statement are explained by taking an example. Assuming that the data query request is an SQL query request, and the data query request is "select gender, count(*)as PV from table where time>start time and time<end time", the data query request includes a field selection statement and a constraint statement, wherein the field selection statement is "select gender, count(*)as PV from table" and the constraint statement is "where time>start time and time<end time". Assuming that the data query request is an SQL query request, and the data query request is "select gender, count(*)as PV from table", the data query request includes a field selection statement, wherein the field selection statement is "select gender, count(*)as PV from table".
[0057] As an example, when the data query request includes a field selection statement, the number of dimensions of the query condition field corresponding to the data query request can be determined according to the number of field dimensions in the field selection statement of the data query request. Specifically, the fields in the field selection statement of the data query request can be determined first, and then the number of fields can be counted, and the number of fields can be used as the number of field dimensions in the field selection statement. Then, the number of field dimensions in the field selection statement can be used as the number of dimensions of the query condition field corresponding to the data query request. Next, an example is given, assuming that the data query request is an SQL query request, and the data query request is "select gender, count(*) as PV from table", then the field selection statement of the data query request is "select gender, count(*) as PV from table", and since the field selection statement includes one field, it can be confirmed that the number of dimensions of the query condition field corresponding to the data query request is 1.
[0058] As an example, when the data query request includes a field selection statement and a constraint statement, the number of dimensions of the query condition field corresponding to the data query request can be determined according to the number of field dimensions in the field selection statement and the constraint statement of the data query request. Specifically, the fields in the field selection statement of the data query request and the fields in the constraint statement can be determined first, and then the number of fields in the field selection statement and the constraint statement can be counted, wherein it should be noted that if there is a field in the field selection statement that is repeated with a field in the constraint statement, the field is only counted as one field in the counted number of fields; then, the number of fields in the field selection statement and the constraint statement can be used as the number of dimensions of the query condition field corresponding to the data query request. Next, an example is used to illustrate. Assume that the data query request is an SQL query request, and the data query request is "select gender, count(*) as PV from table where time> start time and time< end time", then the field selection statement of the data query request is "select gender, count(*) as PV from table", and the constraint statement corresponding to the data to be queried is "time> start time and time< end time". Since the field selection statement includes one field and the constraint statement includes one field, and the two fields are not the same, it can be confirmed that the number of dimensions of the query condition field corresponding to the data query request is 2.
[0059] S303: If the number of dimensions of the query condition field is less than or equal to a preset dimension threshold, the first database management system is used as a target database management system.
[0060] S304: If the number of dimensions of the query condition field is greater than a preset dimension threshold, the second database management system is used as a target database management system.
[0061] S305: If the number of dimensions of the query condition field is less than or equal to a preset dimension threshold, determine a target database management system according to a preset configuration data management system corresponding to the table to be queried.
[0062] In an implementation of this embodiment, since the upper limits of the dimensions of data processed by each database management system in the data query system may be different, after determining the number of dimensions of the query condition field, the target database management system may be determined according to the number of dimensions of the query condition field and a preset dimension threshold. The preset dimension threshold may be determined according to the upper limits of the dimensions of data processed by each database management system in the data query system.
[0063] As an example, in this implementation, the data query system includes a first database management system and a second data management system; wherein the first database management system is an analytical database management system, and the second data management system is a relational database management system. For example, when the data query request is an SQL query request, the first database management system may be a Kylin database management system, and the second data management system may be a MySQL database management system.
[0064] In this implementation, the preset dimension threshold may be determined according to the lowest dimension upper limit among the dimension upper limits of the data processed by each database management system of the data query system. For example, assuming that the dimension upper limit of the data processed by the Kylin database management system is lower than the dimension upper limit of the data processed by the MySQL database management system, that is, the dimension upper limit of the data processed by the first database management system is lower than the dimension upper limit of the data processed by the second database management system, then the preset dimension threshold may be set to the dimension upper limit of the data processed by the Kylin database management system, or may be lower than the dimension upper limit of the data processed by the Kylin database management system. In this way, if the number of dimensions of the query condition field is less than or equal to the preset dimension threshold, the first database management system may be used as the target database management system, that is, the Kylin database management system may be used as the target database management system; if the number of dimensions of the query condition field is greater than the preset dimension threshold, the second database management system may be used as the target database management system, that is, the MySQL database management system may be used as the target database management system.
[0065] In this way, it is ensured that no matter how many dimensions of the query condition field corresponding to the data query request is, it can be ensured that the data query system can perform query analysis processing on the data query request to obtain the data query result corresponding to the data query request. It can be seen that the present invention can use a solution of using several different types of database management systems in combination, that is, using the Kylin database management system and the MySQL database management system with different upper limits of the dimension of processing data in combination, so as to improve the pain point that Kylin cannot normally process and analyze the data query request when the dimensions of the data query request are too many, and because the system construction and query method corresponding to the solution provided by the present invention are relatively simple, it can improve the query analysis efficiency of the data query request while ensuring the reduction of costs, thereby improving the convenience of querying and reading data in the database based on the data query request, improving the development efficiency of the database, and improving the user experience of data query.
[0066] In one implementation of the present embodiment, the data query request includes a table to be queried (i.e., a data table to be queried); if the number of dimensions of the query condition field is less than or equal to a preset dimension threshold, the target database management system can be determined based on the preset configuration data management system corresponding to the table to be queried. It can be understood that in the present implementation, if there are multiple database management systems in the data query system whose upper limits of the dimensions of processing data are all greater than or equal to the number of dimensions of the query condition field, that is, when the number of dimensions of the query condition field is less than or equal to the preset dimension threshold, and there are multiple database management systems that can be used as the target database management system, the preset configuration data management system corresponding to the table to be queried can be determined based on the table to be queried in the data query request, and then the preset configuration data management system can be used as the target database management system. It should be emphasized that the preset configuration data management system corresponding to the table to be queried can be preset.
[0067] As an example, in this implementation, the data query system includes a first database management system and a second data management system; wherein the first database management system is an analytical database management system, and the second data management system is a relational database management system. For example, when the data query request is an SQL query request, the first database management system may be a Kylin database management system, and the second data management system may be a MySQL database management system.
[0068] In this implementation, the preset configuration data management system corresponding to the table to be queried can be the first database management system or the second data management system. Assume that the preset configuration data management system corresponding to table tableA is the first database management system (i.e., Kylin database management system), and the preset configuration data management system corresponding to table tableB is the second database management system (i.e., MySQL database management system). If the upper limit of the dimension of the data processed by the first database management system and the second data management system is greater than or equal to the number of dimensions of the query condition field, that is, when the number of dimensions of the query condition field is less than or equal to the preset dimension threshold, the first database management system and the second data management system can both be used as the target database management system, and the table to be queried in the data query request can be determined first; then, according to the preset configuration data management system corresponding to the table to be queried as the target database management system, assuming that the table to be queried in the data query request is table tableA, the preset configuration data management system corresponding to table tableA, i.e., the first database management system (Kylin database management system) can be used as the target database management system, assuming that the table to be queried in the data query request is table tableB, the preset configuration data management system corresponding to table tableB, i.e., the second database management system (MySQL database management system) can be used as the target database management system.
[0069] It should be noted that, only one step of the above S303-S305 needs to be executed, and it is not necessary to execute all three steps.
[0070] S306: Based on the target database management system, determine a data query result corresponding to the data query request.
[0071] It should be noted that S306 in this embodiment is Figure 2 The same as S204 in the corresponding embodiment. Therefore, in this embodiment, S306 is not further described, and the details can refer to the introduction of S204.
[0072] So far, this embodiment has realized the processing process of the data query method in combination with a specific application scenario. Of course, it should be considered that the above scenario is only an exemplary scenario and does not limit the method provided by the present invention. The method provided by the present invention can be extended to other data query method processing processes with the same principle.
[0073] Figure 2 What is shown is only a basic embodiment of the method of the present invention. By performing certain optimization and expansion on this basis, other preferred embodiments of the method can be obtained.
[0074] like Figure 4 FIG. 1 is another specific embodiment of the data query method of the present invention. Figure 2 On the basis of the corresponding embodiment, further elaboration is made, that is, the method further includes S401-S403, and S204 includes S407. In this embodiment, the method specifically includes the following steps:
[0075] S401: Determine the query popularity value corresponding to each field according to the historical data query request;
[0076] S402: Determine a target field whose query heat value meets a preset condition according to the query heat value corresponding to each field;
[0077] S403: For each target field, respectively establish a database index corresponding to each target field.
[0078] In actual applications in the medical field, there are a large number of data query requests corresponding to query condition fields with hundreds or thousands of dimensions. In this case, in order to shorten the time for the database management system to query data, thereby improving the efficiency of the database management system to query data, in this embodiment, database indexes can be set for some fields (such as fields that users frequently query), so that the database management system can quickly access specific information in the database table in the database management system according to the database index corresponding to the field (for example, when the database management system is a MySQL database management system, since MySQL is relational data, the database index corresponding to the field can be used to improve the efficiency of the database management system in querying the data corresponding to the field). For example, since the index value that meets the query condition can be found in the database index corresponding to the field, the corresponding record in the table can be quickly found through the index value (equivalent to the page number) stored in the database index. In this way, the use of database indexes can shorten the time for the database management system to query data.
[0079] It should be noted that a database index (i.e., index) is a separate, physical database structure, which is a collection of values of one or more columns in a table and a corresponding list of logical pointers to data pages of physical identification values in the table. A database index can be understood as a database data structure, and further, the data structure stores all values of a column in a table, that is, the index is created based on a column in the data table; in short, an index is composed of data on a column in a table, and this data is stored in a data structure.
[0080] In this embodiment, in order to improve the user experience of querying data, a database index can be established in advance for the fields that users frequently query according to the actual usage needs or actual usage habits of the users. Specifically, the query heat value corresponding to each field can be determined according to the historical data query request. It should be emphasized that the historical data query request can reflect the actual query needs or actual query habits of the user. Among them, the query heat value corresponding to the field can be determined according to the number of times or frequency of the field appearing in the historical data query request; the query heat value of the field can reflect the frequency or probability of the user querying the field. If the query heat value of the field is larger, it means that the possibility of the field being queried by the user is greater or the frequency of the user query is higher. Conversely, if the query heat value of the field is smaller, it means that the possibility of the field being queried by the user is smaller or the frequency of the user query is lower. It should be noted that the historical data query request mentioned in this embodiment can be a historical data query request of a user, or a historical data query request of a part of users, such as a historical data query request of users in a certain area, or a historical data query request of users of a certain category, which is not limited in this embodiment.
[0081] Then, according to the query heat values corresponding to each field, the target field whose query heat value meets the preset condition can be determined. The preset condition can be any of the following conditions: when the query heat values of all fields are sorted from high to low, the query heat value is the field whose ranking in the sorting result is before the preset ranking; or the query heat value is greater than or equal to the preset query heat threshold.
[0082] Next, after determining the target field whose query heat value meets the preset conditions, the database index corresponding to each target field can be established for each target field. In other words, for each target field, the data table corresponding to the target field can be determined first, and then the database index corresponding to the target field can be established based on the target field and the data table corresponding to the target field. In this way, the database index corresponding to each target field can be obtained.
[0083] S404: Obtain a data query request.
[0084] It should be noted that S404 in this embodiment is Figure 2 The same as S201 in the corresponding embodiment. Therefore, in this embodiment, S404 is not further described, and the details can refer to the introduction of S201.
[0085] S405: Determine the number of dimensions of the query condition field corresponding to the data query request.
[0086] It should be noted that S405 in this embodiment is Figure 2 The corresponding step S202 is the same as that in the embodiment. Therefore, in this embodiment, S405 is not described again, and the details can be found in the introduction of S202.
[0087] S406: Determine the target database management system according to the number of dimensions of the query condition field.
[0088] It should be noted that S406 in this embodiment is Figure 2 The corresponding step S203 is the same as that in the embodiment. Therefore, in this embodiment, S406 is not further described, and the details can be referred to the introduction of S203.
[0089] S407: If the data query request includes a target field, determine a data query result corresponding to the data query request according to a database index corresponding to the target field and a target database management system.
[0090] In this embodiment, if all the query condition fields of the data query request are target fields, the database index corresponding to each target field can be determined first, and then the data query result corresponding to the data query request can be determined based on the database index corresponding to each target field and the target database management system.
[0091] If some fields in the query condition fields of the data query request are target fields and some fields are non-target fields, the database index corresponding to each target field can be determined first; then, a data set can be determined based on the database index corresponding to each target field and the target database management system; then, based on the non-target fields, the data set corresponding to the data query request is determined in the data set, and the data set is taken as the data query result corresponding to the data query request.
[0092] It should be noted that, in this embodiment, S401-S403 may be executed before or after any one of steps S404-S406. In this embodiment, the execution order of S401-S403 and S404-S406 is not limited.
[0093] It can be seen that in this embodiment, by determining the target field whose query heat value meets the preset conditions in advance according to the historical data query request, and establishing the database index corresponding to each target field for each target field, the data query result corresponding to the data query request can be determined according to the database index corresponding to the target field and the target database management system. Since the database index is set for the target field whose query heat value meets the preset conditions and can reflect the actual query needs or actual query habits of the user, the database management system can quickly access the specific information in the database table in the database management system according to the database index corresponding to the target field, thereby shortening the time for the database management system to determine the data query result corresponding to the data query request, thereby improving the efficiency of the database management system to determine the data query result corresponding to the data query request; in addition, since the target field whose query heat value meets the preset conditions can reflect the actual query needs or actual query habits of the user, the database index can be established in a targeted manner so that the data query request queried by the user can quickly obtain the corresponding data query result, thereby improving the user data query experience.
[0094] So far, this embodiment has realized the processing process of the data query method in combination with a specific application scenario. Of course, it should be considered that the above scenario is only an exemplary scenario and does not limit the method provided by the present invention. The method provided by the present invention can be extended to other data query method processing processes with the same principle.
[0095] like Figure 5 As shown, a specific embodiment of the data query device of the present invention is shown. The device described in this embodiment is a physical device for executing the method described in the above embodiment. Its technical solution is essentially consistent with the above embodiment, and the corresponding description in the above embodiment is also applicable to this embodiment. The device described in this embodiment is applied to a data query system, and the data query system includes several different types of database management systems. The device includes:
[0096] A request acquisition unit 501 is used to acquire a data query request;
[0097] A dimension determination unit 502, configured to determine the number of dimensions of the query condition field corresponding to the data query request;
[0098] A system determination unit 503 is used to determine a target database management system according to the number of dimensions of the query condition field, wherein the target database management system is any target database management system among several database management systems;
[0099] The result determination unit 504 is used to determine the data query result corresponding to the data query request based on the target database management system.
[0100] Optionally, the data query request includes a field selection statement; the dimension determination unit 502 is specifically configured to:
[0101] Determine the number of dimensions of the query condition field corresponding to the data query request according to the number of field dimensions in the field selection statement of the data query request; or
[0102] The data query request includes a field selection statement and a constraint statement; the dimension determination unit 502 is specifically used to:
[0103] The number of dimensions of the query condition field corresponding to the data query request is determined according to the number of field dimensions in the field selection statement and the constraint condition statement of the data query request.
[0104] Optionally, the data query system includes a first database management system and a second data management system; wherein the first database management system is an analytical database management system, and the second data management system is a relational database management system.
[0105] Optionally, the system determination unit 503 is specifically configured to:
[0106] If the number of dimensions of the query condition field is less than or equal to a preset dimension threshold, taking the first database management system as the target database management system;
[0107] If the number of dimensions of the query condition field is greater than a preset dimension threshold, the second database management system is used as the target database management system.
[0108] Optionally, the data query request includes a table to be queried; the system determination unit 503 is specifically configured to:
[0109] If the number of dimensions of the query condition field is less than or equal to the preset dimension threshold, the target database management system is determined according to the preset configuration data management system corresponding to the table to be queried; wherein the preset configuration data management system is the first database management system or the second data management system.
[0110] Optionally, the data query request is an SQL query request, the first database management system is a Kylin database management system, and the second data management system is a MySQL database management system.
[0111] Optionally, before determining the data query result corresponding to the data query request based on the target database management system, the device further includes an index establishment unit, which is used to:
[0112] According to the historical data query request, determine the query heat value corresponding to each field;
[0113] According to the query heat value corresponding to each field, determine the target field whose query heat value meets the preset conditions;
[0114] For each target field, establish a database index corresponding to each target field;
[0115] Accordingly, the result determination unit 504 is specifically configured to:
[0116] If the data query request includes a target field, a data query result corresponding to the data query request is determined according to a database index corresponding to the target field and a target database management system.
[0117] Figure 6 : is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage, etc. Of course, the electronic device may also include hardware required for other services.
[0118] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0119] The memory is used to store execution instructions. Specifically, the execution instructions are computer programs that can be executed. The memory may include internal memory and non-volatile memory, and provides execution instructions and data to the processor.
[0120] In one possible implementation, the processor reads the corresponding execution instruction from the non-volatile memory into the memory and then runs it, and can also obtain the corresponding execution instruction from other devices to form a data query device at the logical level. The processor executes the execution instruction stored in the memory to implement the data query method provided in any embodiment of the present invention through the executed execution instruction.
[0121] As described above, the present invention Figure 2 The method performed by the data query device provided in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0122] The steps of the method disclosed in the embodiment of the present invention can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0123] An embodiment of the present invention further proposes a readable storage medium, which stores execution instructions. When the stored execution instructions are executed by a processor of an electronic device, the electronic device can execute the data query method provided in any embodiment of the present invention, and is specifically used to execute the method described in the above data query.
[0124] The electronic device described in the above embodiments may be a computer.
[0125] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may be implemented in the form of a complete hardware embodiment, a complete software embodiment, or a combination of software and hardware.
[0126] The various embodiments of the present invention are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0127] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0128] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A data query method, characterized in that: The method is applied to a data query system, the data query system includes several different types of database management systems, the database management system includes a Kylin database management system, and the method includes: Obtaining a data query request; the data query request includes field content corresponding to the data to be queried, and / or constraint content corresponding to the data to be queried; Determine the number of dimensions of the query condition field corresponding to the data query request; Determine a target database management system according to the number of dimensions of the query condition field, wherein the target database management system is a target database management system among the several different types of database management systems whose upper limit of the dimension of processed data is greater than and closest to the number of dimensions of the query condition field; Based on the target database management system, determining a data query result corresponding to the data query request; The data query request includes a field selection statement; the step of determining the number of dimensions of the query condition field corresponding to the data query request includes: Determine the number of dimensions of the query condition field corresponding to the data query request according to the number of field dimensions in the field selection statement of the data query request; or The data query request includes a field selection statement and a constraint statement; the step of determining the number of dimensions of the query condition field corresponding to the data query request includes: The number of dimensions of the query condition field corresponding to the data query request is determined according to the number of field dimensions in the field selection statement and the constraint condition statement of the data query request.
2. The method according to claim 1, characterized in that The data query system includes a first database management system and a second database management system; wherein the first database management system is an analytical database management system, and the second database management system is a relational database management system.
3. The method according to claim 2, characterized in that The step of determining the target database management system according to the number of dimensions of the query condition field includes: If the number of dimensions of the query condition field is less than or equal to a preset dimension threshold, taking the first database management system as the target database management system; If the number of dimensions of the query condition field is greater than a preset dimension threshold, the second database management system is used as the target database management system.
4. The method according to claim 2, characterized in that: The data query request includes a table to be queried; and determining a target database management system according to the number of dimensions of the query condition field includes: If the number of dimensions of the query condition field is less than or equal to the preset dimension threshold, the target database management system is determined according to the preset configuration data management system corresponding to the table to be queried; wherein the preset configuration data management system is the first database management system or the second database management system.
5. The method according to any one of claims 2 to 4, characterized in that: The data query request is an SQL query request, the first database management system is a Kylin database management system, and the second database management system is a MySQL database management system.
6. The method according to claim 1, characterized in that Before determining the data query result corresponding to the data query request based on the target database management system, the method further includes: According to the historical data query request, determine the query heat value corresponding to each field; According to the query heat value corresponding to each field, determine the target field whose query heat value meets the preset conditions; For each target field, establish a database index corresponding to each target field; Accordingly, determining the data query result corresponding to the data query request based on the target database management system includes: If the data query request includes a target field, a data query result corresponding to the data query request is determined according to a database index corresponding to the target field and a target database management system.
7. A data query device, characterized in that: The device is applied to a data query system, the data query system includes several different types of database management systems, the database management system includes a Kylin database management system, and the device includes: A request acquisition unit, used to acquire a data query request; the data query request includes field content corresponding to the data to be queried, and / or constraint content corresponding to the data to be queried; A dimension determination unit, used to determine the number of dimensions of the query condition field corresponding to the data query request; A system determination unit, configured to determine a target database management system according to the number of dimensions of the query condition field, wherein the target database management system is a target database management system among the several different types of database management systems whose upper limit of the dimension of processed data is greater than and closest to the number of dimensions of the query condition field; A result determination unit, configured to determine a data query result corresponding to the data query request based on the target database management system; The data query request includes a field selection statement; the dimension determination unit is specifically used to: determine the number of dimensions of the query condition field corresponding to the data query request according to the number of field dimensions in the field selection statement of the data query request; or, The data query request includes a field selection statement and a constraint statement; the dimension determination unit is specifically used to determine the number of dimensions of the query condition field corresponding to the data query request according to the number of field dimensions in the field selection statement and the constraint statement of the data query request.
8. A readable medium comprising an execution instruction. When a processor of an electronic device executes the execution instruction, the electronic device executes the method according to any one of claims 1 to 6.
9. An electronic device, comprising a processor and a memory storing execution instructions, wherein when the processor executes the execution instructions stored in the memory, the processor executes the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data query method, apparatus and system
CN106959963A
Data access method and device and data storage method and device
CN111414403A
