Data query method and electronic equipment
Through the dynamic analysis of the data source information of the target query statement, it was decided to send the query statement to the target database or target data engine, which solved the problem of high data engine pressure and improved the efficiency of query. In particular The query performance is optimized.
Patent Information
- Application Number
- CN202411224798.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-01-28
AI Technical Summary
In the prior art, data engines bear too much pressure during the data query process, resulting in inefficient query efficiency. Especially in multi-data source scenarios, randomly selected data engines may lead to inadequate query efficiency.
By dynamically analyzing the data source information of the target query statement, it was decided to send the query statement to the target database or target data engine. For a single data source, send it directly to the database; for the number of data sources, the query query statement is split and the pressure of the database is determined according to the pressure of the database according to the sub -query statement.
The pressure of the data engine is alleviated and the efficiency of data query is improved, especially in the source of the source of the data through a reasonable post -issuing strategy.
Smart Images

Figure CN119377268A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data computing technology, and in particular to a data query method and electronic device. Background Art
[0002] Engine is the core component of developing programs or systems on electronic platforms. Using the engine, developers can quickly build and lay out the functions required by the program, or use it to assist the operation of the program. Generally speaking, the engine is the supporting part of a program or a system. Common program engines include game engines, search engines, antivirus engines, data engines, etc.
[0003] The data engine is mainly used in the field of data query. In related technologies, the data engine usually reads data into its own storage, which may be memory or disk. All subsequent processing is handled by the data engine. In this way, the data engine is under great pressure. Summary of the invention
[0004] In an exemplary embodiment of the present application, a data query method and an electronic device are provided to reduce the pressure on a data engine during a data query process and improve query efficiency.
[0005] According to a first aspect of an exemplary embodiment, a data query method is provided, the method comprising at least the following steps:
[0006] Obtain a target query statement; wherein the target query statement is a SQL statement;
[0007] According to the data source information of the target query statement, determine to send the target query statement to the target database or target data engine; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement;
[0008] If the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result;
[0009] If the target query statement is sent to the target data engine, the target data engine obtains query data from the database that matches the data source of the target query statement for query, and outputs the query result.
[0010] According to a second aspect of the exemplary implementation, there is provided an electronic device, including a processor and a memory;
[0011] Memory, configured to execute:
[0012] Stores the target query statement; the target query statement is a SQL statement
[0013] A processor configured to execute:
[0014] Get the target query statement;
[0015] According to the data source information of the target query statement, determine to send the target query statement to the target database or target data engine; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement;
[0016] If the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result;
[0017] If the target query statement is sent to the target data engine, the target data engine obtains query data from the database that matches the data source of the target query statement for query, and outputs the query result.
[0018] According to a third aspect of an exemplary implementation, a data query device is provided, the device comprising:
[0019] The data acquisition unit is used to: acquire a target query statement; wherein the target query statement is a SQL statement;
[0020] The data processing unit is used to: determine to send the target query statement to a target database or a target data engine according to the data source information of the target query statement; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement;
[0021] The data processing unit is further used to: if the target query statement is sent to the target database, respond to the target query statement through the target database and output the query result;
[0022] The data processing unit is further used for: if the target query statement is sent to the target data engine, the target data engine obtains query data from the database matching the data source of the target query statement for query, and outputs the query result.
[0023] According to a fourth aspect of the exemplary implementation, a computer storage medium is provided, in which computer program instructions are stored. When the instructions are executed on a computer, the computer executes the data query method of the first aspect.
[0024] In the embodiment of the present application, it is possible to determine whether to send the target query statement to the target database or the target data engine according to whether the data source of the target query statement is a single data source or multiple data sources. This process dynamically analyzes the characteristics of the target query statement, takes into account the data source of the target query statement, and optimizes the sending and execution of the target query statement according to the configuration strategy. Compared with the direct processing by the data engine in the related technology, a part of the processing is handed over to the target database, which relieves the pressure on the data engine and improves the query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0026] Figure 1 The overall architecture diagram of a data query system provided by an embodiment of the present application is exemplarily shown;
[0027] Figure 2 A flowchart of a data query method provided by an embodiment of the present application is exemplified;
[0028] Figure 3 A flowchart of a method for executing a plan for a single data source provided in an embodiment of the present application is exemplified;
[0029] Figure 4 A flowchart of a method for executing a plan for another single data source situation provided by an embodiment of the present application is exemplified;
[0030] Figure 5 A flowchart of a method for executing a plan for a multi-data source situation provided by an embodiment of the present application is exemplified;
[0031] Figure 6 A flowchart of a method for splitting a target query statement provided by an embodiment of the present application is exemplarily shown;
[0032] Figure 7 A flowchart of a method for executing a plan for another multi-data source situation provided by an embodiment of the present application is exemplified;
[0033] Figure 8 A flowchart of a method for executing a plan using a decision tree by a multi-data engine provided in an embodiment of the present application is exemplified;
[0034] Fig. 9 The following is a schematic diagram showing the structure of a data query device provided by an embodiment of the present application;
[0035] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is exemplarily shown. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0037] (1) Structured Query Language (SQL): A special-purpose programming language, a database query and programming language used to access data and query, update, and manage relational database systems.
[0038] (2) Federated query: A query method that can link multiple database systems to perform unified SQL queries.
[0039] With the construction of urban systems, urban transportation or other functional departments have established many business systems, and the data between different systems often use different databases. Therefore, federated queries may be applied in this scenario.
[0040] In related technologies, in federated queries, the data engine usually reads data into its own storage, which may be memory or disk. All subsequent processing is handled by the data engine. In this way, the data engine is under great pressure. In addition, when there are multiple data engines, the user usually randomly selects a data engine to execute. The randomness of the data engine determined at that time is relatively large, which may lead to low query efficiency.
[0041] To this end, an embodiment of the present application provides a data query method, in which it can be determined whether to send a query statement to a database or a data engine based on whether the data source is a single data source or multiple data sources. Among them, if the data source of the query statement is a single data source, the query statement can be directly sent to the database. If the data source of the query statement is multiple data sources, it can be further subdivided into whether the query statement is sent to the database or the data engine. The subdivision method is to split the query statement into multiple sub-query statements, and then determine whether the pressure caused by the sub-query statement on the database meets the set pressure condition. If so, the sub-query statement is sent to the database, otherwise, the sub-query statement is sent to the data engine. Compared with the direct processing by the data engine in the related art, it combines the actual situation of the data source and improves the query efficiency.
[0042] After introducing the design ideas of the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions of the embodiments of the present application can be applied. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limited. In specific implementation, the technical solutions provided by the embodiments of the present application can be flexibly applied according to actual needs.
[0043] refer to Figure 1 , showing an overall architecture diagram of a data query system, which can execute a data query method. Figure 1 In the figure, the overall architecture diagram of the data query system mainly includes the hybrid query statement SQL, the data engine layer and the database layer.
[0044] Among them, the hybrid query SQL analyzes the user's input and mainly defines the SQL of the user's query. The data engine layer is composed of a series of data engines, such as Doris, Trino, Presoto, Flink, Impala and other data engines. During deployment, at least one corresponding data engine can be included according to usage requirements or current status. The database layer is the storage location of the user's actual data, such as MySQL, Hive, Postgre, SQLServer, and ORACLE.
[0045] To further illustrate the technical solution provided by the embodiment of the present application, this is described in detail below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiment of the present application provides the method operation steps shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on routine or no creative labor. In the steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided in the embodiment of the present application.
[0046] Combine the following Figure 1 The application scenario shown is shown in Figure 2 A flow chart of a data query method is shown to illustrate the technical solution provided by an embodiment of the present application.
[0047] S201: Obtain a target query statement.
[0048] S202: Determine, based on data source information of the target query statement, whether to send the target query statement to a target database or a target data engine.
[0049] S203: If the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result;
[0050] S204: If the target query statement is sent to the target data engine, the target data engine obtains query data from a database that matches the data source of the target query statement, performs query, and outputs query results.
[0051] In the embodiment of the present application, it is possible to determine whether to send the target query statement to the target database or the target data engine according to whether the data source of the target query statement is a single data source or multiple data sources. This process dynamically analyzes the characteristics of the target query statement, takes into account the data source of the target query statement, and optimizes the sending and execution of the target query statement according to the configuration strategy. Compared with the direct processing by the data engine in the related technology, a part of the processing is handed over to the target database, which relieves the pressure on the data engine and improves the query efficiency.
[0052] In S201, a target query statement may be obtained through user input, and the target query statement is a SQL statement. The target query statement may be a mixed query SQL. The user input method may be to click the input box with a mouse or to touch the input box to confirm.
[0053] In S202, the target query statement is parsed to determine the data source information of the target query statement, that is, whether the data source of the target query statement is a single data source or multiple data sources. Then, according to the data source information of the target query statement, it is determined to send the target query statement to a target database or a target data engine. The target database is a database corresponding to the data source of the target query statement.
[0054] Next, we will explain different situations based on whether the data source is a single data source or multiple data sources:
[0055] In the first case, the data source information of the target query statement indicates that the target query statement is a single data source.
[0056] In this case, there are two ways to implement it, which are described in detail below:
[0057] The first method: You can directly send the target query statement to the target database for execution.
[0058] Figure 3 A flowchart of a method for executing a plan for a single data source provided in an embodiment of the present application. Figure 3 The process includes at least the following steps:
[0059] S301: Parsing a target query statement.
[0060] S302: Determine whether the data source of the target query statement is a single data source, and if so, execute S303.
[0061] S303: Submit the target query statement to the target database for execution.
[0062] The second method: when the pressure caused by the target query statement on the target database meets the set pressure, the target query statement is sent to the target database for execution.
[0063] In this case, you can first determine that the target query statement has a relatively small pressure on the target database, and then send the target query statement to the target database. In other words, when the target query statement does not cause excessive pressure on the target database, send the target query statement to the target database for execution.
[0064] Optionally, the method of determining whether the pressure caused by the target query statement on the target database meets the set pressure condition can be implemented by method A1 or method A2:
[0065] A1: The target database includes the index of the specified field.
[0066] The set fields may be aggregation fields, filter fields, etc. That is, indexes of these set fields are created in the target database.
[0067] In a specific example, the field is set as an aggregate field, and the target query statement is "select count(*)as num,sex from table_a group by sex". If the target database has an index on sex in table_a, the target query statement can be handed over to the target database, and the target database's index can be used to improve query efficiency. If there is no such index, in the case of a large amount of data, a temporary file may be created in the database, and the data may be stored on the disk for calculation, resulting in a slow return of data.
[0068] In another specific example, the field is set as the filter field, and the target query statement is "select * from table_b where age>12". When the field age in the where condition statement has no index, the target database needs to obtain data through a full table scan. If there is an index, the index can be used to speed up the query.
[0069] In other words, if the target query statement has an index, it can avoid scanning the entire table data, which is considered to be less stressful for the target database. When the amount of data in multiple tables is large and there is no index, it usually causes greater stress on the target database.
[0070] A2: The target database meets the set time-consuming conditions for the query results in the test data set.
[0071] The above pressure setting conditions are defined from the perspective of field index. In actual application, the pressure setting conditions can also be defined from the perspective of data volume, database performance, and database type. When the conditions are more complex, you can also enter algorithms such as decision trees to train the basic data and implement the actual judgment process by the decision tree algorithm. Among them, the decision tree algorithm is only an example and does not form a specific limitation.
[0072] Exemplarily, a test data set is constructed, and the test data set includes multiple test statements. For the test data set, different conditions are tested, and the input is SQL query statements, query plans for SQL query statement parsing, data volume, database performance, database type, overall task time, etc. At present, the test set data is trained with the overall task time being shorter as the best. The trained model is verified with the result set data until the query plan effect given by the model reaches the set time condition (for example, the query time of more than a set number of test statements in the test data set is less than the set query time, and the set number can be 95%). Finally, a better execution plan can be selected based on SQL and other environmental information.
[0073] Figure 4 A flowchart of a method for executing a plan for another single data source situation provided in an embodiment of the present application, Figure 4 The process includes at least the following steps:
[0074] S401: Parsing the target query statement.
[0075] S402: Determine whether the data source of the target query statement is a single data source, and if so, execute S403.
[0076] S403: Determine whether the set pressure condition is met, if so, execute S404.
[0077] S404: Submit the target query statement to the target database for execution.
[0078] In the second case, the data source information of the target query statement indicates that the target query statement is from multiple data sources.
[0079] In this case, there are two ways to implement it, which are described in detail below:
[0080] The first method is to directly send the target query statement to the target data engine.
[0081] Figure 5 A flowchart of a method for executing a plan for a multi-data source situation provided in an embodiment of the present application, Figure 5 The process includes at least the following steps:
[0082] S501: Parsing a target query statement.
[0083] S502: Determine whether the data source of the target query statement is a multiple data source, and if so, execute S503.
[0084] S503: Submit the target query statement to the target data engine for execution.
[0085] The second method is to split the target query statement into multiple sub-query statements, and then use the pressure caused by each sub-query statement on the target database to determine whether to send the target query statement to the target database or the target data engine.
[0086] When using the data engine for processing, it may cause the engine to be overloaded or the data may take time to be input and output on the network, slowing down the analysis. Therefore, in this method, the data engine layer will perform additional parsing to split the target query statement. In this method, the splitting process can be done by Figure 6 Steps S601-S602 in the implementation:
[0087] S601: If the data source of the target query statement is multiple data sources, the target query statement is split into multiple sub-query statements according to a splitting rule.
[0088] For example, the target query statement can be parsed into the smallest units, "SELECT COUNT(id)AS num,typeFROM Datasource1.Table1 GROUP BY type" and "SELECT COUNT(id)AS num,type FROMDatasource2.Table1 GROUP BY type".
[0089] Steps B1-B4 show a process of splitting a target query statement into multiple sub-query statements:
[0090] Step B1:
[0091] Raw SQL:
[0092] SELECT SUM(num), type FROM(
[0093] (SELECT COUNT(id)AS num,type FROM Datasource1.Table GROUP BY type)A
[0094] UNION ALL
[0095] (SELECT COUNT(id)AS num,type FROM Datasource2.Table GROUP BY type)B
[0096] )tmp GROUP BY type
[0097] Step B2-1:
[0098] The parts that need to be executed in the data source for Datasource disassembly are:
[0099] (SELECT COUNT(id)AS num,type FROM Datasourcel.Table GROUP BY type)
[0100] Step B2-2:
[0101] The parts that need to be executed in the data source for Datasource disassembly are:
[0102] (SELECT COUNT(id)AS num,type FROM Datasource2.Table GROUP BY type)
[0103] Step B3:
[0104] In the cross-data source part, associate data in the data engine:
[0105] A UNION ALL B
[0106] Step B4:
[0107] For the associated data, aggregate calculations are performed in the data engine:
[0108] SELECT SUM(num), type FROM tmp GROUP BY type.
[0109] It should be noted that the above splitting process is only an example, and it can also be expanded according to the actual target query statement, for example, by means of multi-table association calculation in the same data source.
[0110] S602: Send a target sub-query statement among the multiple sub-query statements whose pressure on the target database meets the set pressure condition to the target database; send other sub-query statements among the multiple sub-query statements except the target sub-query statement to the target data engine.
[0111] In this way, each minimum unit (subquery statement) can be analyzed separately, including indexes, to determine whether the execution efficiency in the target database will be higher and help reduce data network input and output. If it is suitable, the query will be sent to the target database for execution, otherwise the data will be read into the data engine for execution.
[0112] Figure 7 A flowchart of a method for executing a plan for a multi-data source situation provided in an embodiment of the present application, Figure 7 The process includes at least the following steps:
[0113] S701: Parsing the target query statement.
[0114] S702: Determine whether the target query statement is from multiple data sources. If so, execute S703.
[0115] S703: for each sub-query statement obtained by parsing the target query statement, determine whether the pressure caused by the sub-query statement on the target database meets the set pressure condition, if so, execute S704, otherwise execute S705.
[0116] S704: Submit the target query statement to the target database for execution.
[0117] S705: Submit the target query statement to the target data engine for execution.
[0118] In the second method, after the smallest unit is executed, the structure of each stage can be associated, analyzed and calculated in the data engine to obtain the final result. That is to say, after the target sub-query statement is sent to the target database or target data engine, each target sub-query statement can be associated; the target database or target data engine responds to the associated query statement to obtain the query result, and the association rule corresponds to the splitting rule.
[0119] In a specific example, for example, when the data has an index and an aggregation operation will be generated, refer to the statements in steps B1-B4, count is an aggregation operation, Table1 has established an index of type, then the index can improve the execution efficiency of the statement, count can aggregate the original n data into m data, m<=n, the worst case, when all data types are different, n=m, the best case, when all data types are the same, then m=1, at this time, the aggregation calculation is put into the database, the network only needs to transmit the bytes used by m data, while the calculation using the data engine requires the bytes used by n data. Therefore, using database calculation can greatly reduce network input and output.
[0120] According to the two methods in the first and second cases above, the target query statement is sent to the target database or data engine.
[0121] In S203, if the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result.
[0122] In S204, if the target query statement is sent to the target data engine, the target data engine obtains query data from a database that matches the data source of the target query statement, performs query, and outputs the query result.
[0123] Among them, the process of the target database responding to the target query statement and the process of the target data engine obtaining query data from the database matching the data source of the target query statement for query can be referred to the relevant technology and will not be repeated here.
[0124] The embodiment of the present application dynamically analyzes SQL query statements and optimizes the issuance and execution of query statements according to the configuration strategy. The calculation of a part of the target query statement can be pushed down to the database, taking advantage of the existing index and alleviating the pressure of the data engine.
[0125] In the actual application process, in production, due to the different existing construction cycles of the project, there are different data computing engines, and there may be multiple data computing engines at the same time. At this time, determine the characteristics of the data source of the query statement to be issued (such as the number of nodes, database support range, current computing pressure, etc.) and the degree of matching of the characteristics of each data engine, and determine the target data engine among multiple engines through the decision tree algorithm, and the target data engine will analyze and recursively execute the target query statement.
[0126] Therefore, compared with the related art in which a user selects a data engine to execute, the embodiments of the present application can support the target query statement to connect to multiple data engines at the same time, and the user can choose by himself.
[0127] Figure 8 A flowchart of a method for executing a plan using a decision tree for a multi-data engine provided in an embodiment of the present application. Figure 8 At least the following steps are included:
[0128] S801: Obtain the number of current data engines.
[0129] S802: If there are multiple data engines, determine the characteristics of the data source of the query statement to be issued and the matching degree of the characteristics of each data engine, and determine the target data engine among the multiple engines.
[0130] S803: The target data engine obtains query data from a database that matches the data source of the target query statement, performs query, and outputs query results.
[0131] In the embodiment of the present application, for data analysis users, when writing federal SQL query statements, there is no need to consider the actual execution data engine and execution efficiency. The system can automatically send the SQL query statement to the appropriate data engine or database based on the SQL query statement input by the user, by analyzing the database and database structure involved in the SQL query statement and the characteristics of different data engines, thereby accelerating the query.
[0132] In summary, the overall query process in the embodiment of the present application may include: the user inputs the SQL to be executed, and the system determines whether to send it to the database or the data engine through a strategy; when it needs to be processed by the data engine, the SQL is parsed; the parsed SQL part is handed over to the rule engine (or decision tree algorithm) to determine whether to read the data to the data engine for processing, or to send it to the database to read its calculation results; after all the minimum units are executed, the data engine assembles and calculates them to obtain the final result; and the final result is returned to the user for display.
[0133] like Fig. 9 As shown, based on the same inventive concept, an embodiment of the present application provides a data query device, which includes:
[0134] The data acquisition unit 91 is used to: acquire a target query statement; wherein the target query statement is a SQL statement;
[0135] The data processing unit 92 is used to: determine to send the target query statement to the target database or target data engine according to the data source information of the target query statement; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement;
[0136] The data processing unit 92 is further configured to: if the target query statement is sent to the target database, respond to the target query statement through the target database and output the query result;
[0137] The data processing unit 92 is further configured to: if the target query statement is sent to the target data engine, obtain query data from a database matching the data source of the target query statement through the target data engine for query, and output the query result.
[0138] In an optional implementation, the data processing unit 92 is specifically configured to:
[0139] If the data source of the target query statement is a single data source, the target query statement is sent to the target database.
[0140] In an optional implementation, before sending the target query statement to the target database, the data processing unit 92 is further configured to:
[0141] Determine whether the pressure caused by the target query statement on the target database meets the set pressure conditions.
[0142] In an optional implementation, the data processing unit 92 is specifically configured to:
[0143] If the data source of the target query statement is multiple data sources, the target query statement is sent to the target data engine.
[0144] In an optional implementation, the data processing unit 92 is specifically configured to:
[0145] If the data source of the target query statement is multiple data sources, the target query statement is split into multiple sub-query statements according to the splitting rule;
[0146] A target sub-query statement among the multiple sub-query statements whose pressure on the target database meets the set pressure condition is sent to the target database; and other sub-query statements among the multiple sub-query statements except the target sub-query statement are sent to the target data engine.
[0147] In an optional implementation, the data processing unit 92 is further configured to determine whether the pressure on the target database satisfies the set pressure condition in the following manner:
[0148] The target database includes an index of the set field; or;
[0149] The target database satisfies a set time-consuming condition for query results in a test data set; wherein the test data set includes multiple test statements; the set time-consuming condition is that the query time of more than a set number of test statements in the test data set is less than the set query time.
[0150] In an optional implementation, the data processing unit 92 is further configured to:
[0151] If there are multiple data engines, the characteristics of the data source of the query statement to be issued and the degree of matching of the characteristics of each data engine are determined, and the target data engine is determined among the multiple engines.
[0152] In an optional implementation, the data processing unit 92 is further configured to:
[0153] If there are multiple target sub-query statements, after sending the target sub-query statements to the target database or target data engine, the target sub-query statements are associated;
[0154] The associated query statement is responded to through the target database or target data engine to obtain the query result; wherein the association rule corresponds to the splitting rule.
[0155] Since the device is the device in the method in the embodiment of the present application, and the principle of solving the problem by the device is similar to that of the method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0156] like Fig.10 As shown, based on the same inventive concept, an embodiment of the present application provides an electronic device, including a processor 101 and a memory 102 .
[0157] The memory 102 is configured to execute:
[0158] Stores the target query statement; the target query statement is a SQL statement
[0159] The processor 101 is configured to execute:
[0160] Get the target query statement;
[0161] According to the data source information of the target query statement, determine to send the target query statement to the target database or target data engine; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement;
[0162] If the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result;
[0163] If the target query statement is sent to the target data engine, the target data engine obtains query data from the database that matches the data source of the target query statement for query, and outputs the query result.
[0164] In an optional implementation, the processor 101 is specifically configured to execute:
[0165] If the data source of the target query statement is a single data source, the target query statement is sent to the target database.
[0166] In an optional implementation, before sending the target query statement to the target database, the processor 101 is further configured to:
[0167] Determine whether the pressure caused by the target query statement on the target database meets the set pressure conditions.
[0168] In an optional implementation manner, the processor 101 is specifically configured to:
[0169] If the data source of the target query statement is multiple data sources, the target query statement is sent to the target data engine.
[0170] In an optional implementation manner, the processor 101 is specifically configured to:
[0171] If the data source of the target query statement is multiple data sources, the target query statement is split into multiple sub-query statements according to the splitting rule;
[0172] A target sub-query statement among the multiple sub-query statements whose pressure on the target database meets the set pressure condition is sent to the target database; and other sub-query statements among the multiple sub-query statements except the target sub-query statement are sent to the target data engine.
[0173] In an optional implementation, the processor 101 is further configured to determine whether the pressure caused to the target database satisfies the set pressure condition in the following manner:
[0174] The target database includes an index of the set field; or;
[0175] The target database satisfies a set time-consuming condition for query results in a test data set; wherein the test data set includes multiple test statements; the set time-consuming condition is that the query time of more than a set number of test statements in the test data set is less than the set query time.
[0176] In an optional implementation, the processor 101 is further configured to:
[0177] If there are multiple data engines, the characteristics of the data source of the query statement to be issued and the degree of matching of the characteristics of each data engine are determined, and the target data engine is determined among the multiple engines.
[0178] In an optional implementation, the processor 101 is further configured to:
[0179] If there are multiple target sub-query statements, after sending the target sub-query statements to the target database or target data engine, the target sub-query statements are associated;
[0180] The associated query statement is responded to through the target database or target data engine to obtain the query result; wherein the association rule corresponds to the splitting rule.
[0181] The embodiment of the present application also provides a computer storage medium, in which computer program instructions are stored. When the instructions are executed on a computer, the computer executes the steps of the above-mentioned data query method.
[0182] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0183] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0184] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0185] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0186] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data query method, characterized in that: include: Obtain a target query statement; wherein the target query statement is a SQL statement; According to the data source information of the target query statement, determine to send the target query statement to a target database or a target data engine; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement; If the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result; If the target query statement is sent to the target data engine, the target data engine obtains query data from a database that matches the data source of the target query statement, performs query, and outputs query results.
2. The method according to claim 1, characterized in that The step of determining, based on the data source information of the target query statement, to send the target query statement to a target database or a target data engine includes: If the data source of the target query statement is a single data source, the target query statement is sent to the target database.
3. The method according to claim 2, characterized in that Before sending the target query statement to the target database, the method further includes: It is determined that the pressure caused by the target query statement on the target database meets a set pressure condition.
4. The method according to claim 1, characterized in that: The step of determining, based on the data source information of the target query statement, to send the target query statement to a target database or a target data engine includes: If the data source of the target query statement is multiple data sources, the target query statement is sent to the target data engine.
5. The method according to claim 1, characterized in that The step of determining, based on the data source information of the target query statement, to send the target query statement to a target database or a target data engine includes: If the data source of the target query statement is multiple data sources, the target query statement is split into multiple sub-query statements according to the splitting rule; A target sub-query statement among the multiple sub-query statements, whose pressure on the target database satisfies a set pressure condition, is sent to the target database; and other sub-query statements among the multiple sub-query statements except the target sub-query statement are sent to the target data engine.
6. The method according to claim 3 or 5, characterized in that: The method further includes determining that the pressure caused to the target database satisfies a set pressure condition by: The target database includes an index of a set field; or; The target database satisfies a set time-consuming condition for a query result in a test data set; wherein the test data set includes a plurality of test statements; the set time-consuming condition is that a query time of a number of test statements greater than a set number in the test data set is less than a set query time.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: If there are multiple data engines, the characteristics of the data source of the query statement to be issued and the matching degree of the characteristics of each data engine are determined, and the target data engine is determined among the multiple engines.
8. The method according to claim 5, characterized in that The method further comprises: If there are multiple target sub-query statements, after sending the target sub-query statements to the target database or the target data engine, the target sub-query statements are associated with each other; The associated query statement is responded to through the target database or the target data engine to obtain a query result; wherein the association rule corresponds to the splitting rule.
9. An electronic device, characterized in that: including a processor and a memory; The memory is configured to execute: Store the target query statement; wherein the target query statement is a SQL statement The processor is configured to execute: Get the target query statement; According to the data source information of the target query statement, determine to send the target query statement to a target database or a target data engine; wherein the data source information is a single data source or multiple data sources; the target database is a database corresponding to the data source of the target query statement; If the target query statement is sent to the target database, the target database responds to the target query statement and outputs the query result; If the target query statement is sent to the target data engine, the target data engine obtains query data from a database that matches the data source of the target query statement, performs query, and outputs query results.
10. The electronic device according to claim 9, characterized in that: The processor is specifically configured to execute: If the data source of the target query statement is a single data source, the target query statement is sent to the target database.