Query method and device, electronic equipment and computer program product
By writing queries to the corresponding queue based on the query complexity and using their respective resources to execute queries, the problem of unbalanced computing resource occupancy in big data visual analysis is solved, and query performance is improved.
Patent Information
- Application Number
- CN202510571812.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-08-15
AI Technical Summary
In big data visual data analysis, the SQL complexity difference of different chart queries leads to uneven computing resource occupancy, and complex queries occupy too many resources affecting the query speed and overall performance of simple queries.
By determining the query complexity of structured query language queries, writing it to the corresponding preset query queue, using their respective query resources to execute queries, realizing resource isolation, and avoiding complex queries occupying too many resources to affect the speed of simple queries.
Resource isolation for queries of different complexity is realized, query performance is improved, complex queries are avoided, and the overall query efficiency is improved.
Smart Images

Figure CN120492498A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to Internet technologies, and in particular to a query method, device, electronic device, and computer program product. Background Art
[0002] Presto is an open source distributed SQL (Structured Query Language) query engine, primarily used for real-time query and analysis in the big data field. It has the ability to connect to the Hive data warehouse. The Hive data warehouse tool can map structured data files into a database table and provide SQL query capabilities, which can convert SQL statements into MapReduce tasks for execution.
[0003] Some companies' self-developed big data visualization and data analysis platforms use the Presto engine as the underlying query engine to query data in Hive data warehouses and use it for data visualization. However, different chart queries in big data visualization and data analysis query different Hive tables and execute SQL with varying complexity, resulting in significant differences in the computing resources used when submitted to the Presto engine. Complex report queries can instantly consume all of the Presto engine's computing resources, forcing simpler queries to wait for computing resources. Summary of the Invention
[0004] To solve the technical problems in related technologies, the embodiments of the present disclosure provide a query method, device, electronic device, and computer program product.
[0005] According to a first aspect of an embodiment of the present disclosure, a query method is provided, the method comprising:
[0006] receiving a structured query language query request, wherein the structured query language query request includes a query object identification code;
[0007] determining a query complexity of the structured query language query request, wherein the query complexity is used to evaluate a query efficiency of executing the structured query language query request;
[0008] According to the query complexity of the structured query language query request, writing the structured query language query request into a preset query queue corresponding to the query complexity;
[0009] The structured query language query request in the preset query queue is executed through the query resources corresponding to the preset query queue corresponding to the query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
[0010] As an embodiment of the present disclosure, determining the query complexity of the structured query language query request includes:
[0011] According to the query object identification code, querying a preset database whether there is historical execution information related to the structured query language query request;
[0012] In response to the presence of historical execution information related to the structured query language query request in the preset database, determining the query complexity of the structured query language query request based on the historical execution information;
[0013] In response to the absence of historical execution information related to the structured query language query request in the preset database, the query complexity of the structured query language query request is determined according to a query syntax tree of the structured query language query request.
[0014] As an embodiment of the present disclosure, in response to the presence of historical execution information related to the structured query language query request in the preset database, determining the query complexity of the structured query language query request based on the historical execution information includes:
[0015] In response to the presence of historical execution information related to the structured query language query request in the preset database, obtaining the historical execution information related to the structured query language query request from the preset database, the historical execution information being a plurality of execution parameters obtained during the execution of the structured query language query request;
[0016] Dividing the multiple execution parameters into multiple calculation dimensions according to the degree of influence of each execution parameter on the query complexity, wherein each calculation dimension is set with a corresponding first preset weight value, and the first preset weight value is pre-set according to the degree of influence of each execution parameter on the query complexity;
[0017] The total complexity of the multiple calculation dimensions is calculated based on the first preset weight value of each calculation dimension and the first preset score of each execution parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The first preset score is the importance of each execution parameter of any preset calculation dimension to the query complexity.
[0018] As an embodiment of the present disclosure, in response to the absence of historical execution information related to the structured query language query request in the preset database, determining the query complexity of the structured query language query request based on a query syntax tree of the structured query language query request includes:
[0019] In response to the absence of historical execution information related to the structured query language query request in the preset database, parsing the query syntax tree of the structured query language query request to obtain a plurality of query parameters of the structured query language query request;
[0020] Dividing the plurality of query parameters into a plurality of calculation dimensions according to the degree of influence of each query parameter on the query complexity, wherein each calculation dimension is set with a corresponding second preset weight value, the second preset weight value being pre-set according to the degree of influence of each query parameter on the query complexity;
[0021] The total complexity of the multiple calculation dimensions is calculated based on the second preset weight value of each calculation dimension and the second preset score of each query parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The second preset score is the importance of each query parameter of any preset calculation dimension to the query complexity.
[0022] As an embodiment of the present disclosure, writing the structured query language query request into a preset query queue corresponding to the query complexity of the structured query language query request according to the query complexity of the structured query language query request includes:
[0023] Determining a complexity level of the query complexity of the structured query language query request according to the query complexity of the structured query language query request and a preset complexity threshold;
[0024] The structured query language query request is written into a preset query queue corresponding to its complexity level.
[0025] As an embodiment of the present disclosure, determining the complexity level of the query complexity of the structured query language query request according to the query complexity of the structured query language query request and a preset complexity threshold includes:
[0026] In response to determining that the query complexity of the structured query language query request is less than or equal to a first preset complexity threshold, determining a complexity level of the query complexity of the structured query language query request to be a first complexity;
[0027] In response to determining that the query complexity of the structured query language query request is greater than the first preset complexity threshold and less than or equal to a second preset complexity threshold, determining the query complexity level of the structured query language query request to be a second complexity level;
[0028] In response to determining that the query complexity of the structured query language query request is greater than the second preset complexity threshold, determining the query complexity level of the structured query language query request to be a third complexity level;
[0029] The second preset complexity threshold is greater than the first preset complexity threshold.
[0030] As an embodiment of the present disclosure, the method includes:
[0031] After executing the structured query language query request in the preset query queue by using the query resource corresponding to the preset query queue corresponding to the query complexity thereof to obtain a target query object corresponding to the query object identification code in the structured query language query request from a preset data warehouse, obtaining execution data of the structured query language query request and writing it into a preset distributed messaging system;
[0032] Acquire the execution data from the preset distributed messaging system, and calculate and determine execution resource information of the structured query language query request based on the execution data;
[0033] The execution resource information of the structured query language query request is stored in the preset database as the historical execution information of the structured query language query request.
[0034] According to a second aspect of an embodiment of the present disclosure, a query device is provided, the device comprising:
[0035] A query request receiving module, configured to receive a structured query language query request, wherein the structured query language query request includes a query object identification code;
[0036] a complexity determination module, configured to determine the query complexity of the structured query language query request, wherein the query complexity is used to evaluate the query efficiency of executing the structured query language query request;
[0037] a queue writing module, configured to write the structured query language query request into a preset query queue corresponding to the query complexity of the structured query language query request according to the query complexity of the structured query language query request;
[0038] A query request execution module is used to execute the structured query language query request in the preset query queue through the query resources corresponding to the preset query queue corresponding to the query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
[0039] As an embodiment of the present disclosure, the complexity determination module further includes:
[0040] A query unit, configured to query a preset database for historical execution information related to the structured query language query request based on the query object identification code;
[0041] a first complexity determination unit, configured to determine the query complexity of the structured query language query request based on historical execution information related to the structured query language query request in response to the presence of historical execution information related to the structured query language query request in the preset database;
[0042] The second complexity determination unit is configured to determine the query complexity of the structured query language query request according to the query syntax tree of the structured query language query request in response to the absence of historical execution information related to the structured query language query request in the preset database.
[0043] As an embodiment of the present disclosure, the first complexity determination unit is further configured to:
[0044] In response to the presence of historical execution information related to the structured query language query request in the preset database, obtaining the historical execution information related to the structured query language query request from the preset database, the historical execution information being a plurality of execution parameters obtained during the execution of the structured query language query request;
[0045] Dividing the multiple execution parameters into multiple calculation dimensions according to the degree of influence of each execution parameter on the query complexity, wherein each calculation dimension is set with a corresponding first preset weight value, and the first preset weight value is pre-set according to the degree of influence of each execution parameter on the query complexity;
[0046] The total complexity of the multiple calculation dimensions is calculated based on the first preset weight value of each calculation dimension and the first preset score of each execution parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The first preset score is the importance of each execution parameter of any preset calculation dimension to the query complexity.
[0047] As an embodiment of the present disclosure, the second complexity determination unit is further configured to:
[0048] In response to the absence of historical execution information related to the structured query language query request in the preset database, parsing the query syntax tree of the structured query language query request to obtain a plurality of query parameters of the structured query language query request;
[0049] Dividing the plurality of query parameters into a plurality of calculation dimensions according to the degree of influence of each query parameter on the query complexity, wherein each calculation dimension is set with a corresponding second preset weight value, the second preset weight value being pre-set according to the degree of influence of each query parameter on the query complexity;
[0050] The total complexity of the multiple calculation dimensions is calculated based on the second preset weight value of each calculation dimension and the second preset score of each query parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The second preset score is the importance of each query parameter of any preset calculation dimension to the query complexity.
[0051] As an embodiment of the present disclosure, the queue writing module includes:
[0052] a complexity level determining unit, configured to determine a complexity level of the query complexity of the structured query language query request according to the query complexity of the structured query language query request and a preset complexity threshold;
[0053] The queue writing unit is used to write the structured query language query request into a preset query queue corresponding to its complexity level.
[0054] As an embodiment of the present disclosure, the complexity level determination unit is further configured to:
[0055] In response to determining that the query complexity of the structured query language query request is less than or equal to a first preset complexity threshold, determining a complexity level of the query complexity of the structured query language query request to be a first complexity;
[0056] In response to determining that the query complexity of the structured query language query request is greater than the first preset complexity threshold and less than or equal to a second preset complexity threshold, determining the query complexity level of the structured query language query request to be a second complexity level;
[0057] In response to determining that the query complexity of the structured query language query request is greater than the second preset complexity threshold, determining the query complexity level of the structured query language query request to be a third complexity level;
[0058] The second preset complexity threshold is greater than the first preset complexity threshold.
[0059] As an embodiment of the present disclosure, the device further includes:
[0060] an execution data acquisition module, configured to execute a structured query language query request in a preset query queue through a query resource corresponding to the preset query queue corresponding to the query complexity thereof, obtain a target query object corresponding to the query object identification code in the structured query language query request from a preset data warehouse, and then obtain execution data of the structured query language query request and write it into a preset distributed message system;
[0061] an execution resource information calculation module, configured to obtain the execution data from the preset distributed messaging system, and to calculate and determine the execution resource information of the structured query language query request based on the execution data;
[0062] The historical execution information storage module is configured to store the execution resource information of the structured query language query request as the historical execution information of the structured query language query request in the preset database.
[0063] According to a third aspect of an embodiment of the present disclosure, a computer program product is provided, comprising computer program instructions, which implement the method described in the first aspect when executed by a processor.
[0064] According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0065] a memory for storing a computer program product;
[0066] The processor is configured to execute the computer program product stored in the memory, and when the computer program product is executed, the method described in the first aspect above is implemented.
[0067] According to a fifth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method described in the first aspect above is implemented.
[0068] According to the technical solution of the embodiment of the present disclosure, by determining the query complexity of the structured query language query and writing the structured query language query into the query queue corresponding to its query complexity according to the query complexity, the corresponding query resources are used to process the structured query language queries of different query queues. In this way, the structured query language queries of different complexities can be isolated to achieve the purpose of query resource isolation, avoid complex structured query language queries occupying too many query (computing) resources and affecting the query speed of simple structured query language queries, and improve the query processing performance of structured query language queries.
[0069] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0071] The present disclosure can be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0072] Figure 1 This is an architectural diagram of the big data visualization analysis platform disclosed in this disclosure.
[0073] Figure 2 This is one of the flowcharts of a query method according to an embodiment of the method disclosed herein.
[0074] Figure 3 This is a second flowchart of a query method according to an embodiment of the method disclosed herein.
[0075] Figure 4 This is a structural block diagram of a query device according to an embodiment of the present invention.
[0076] Figure 5 This is a structural block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0077] Some big data visualization and data analysis platforms use the Presto engine as the underlying query engine to query data in Hive data warehouses for data visualization. However, different chart queries query different Hive tables and execute SQL with varying degrees of complexity, resulting in significant disparity in the computing resources (or query resources) used when submitted to the Presto engine. For example, some complex queries can instantly consume all of the engine's computing resources, forcing some simple queries to queue for computing resources. However, simple queries account for the vast majority of daily queries. If queries are not resource-isolated, the excessive computing resources occupied by complex queries will affect the query speed of simple queries, thereby affecting the query performance of the entire query.
[0078] Figure 1 This is the architecture diagram of the big data visualization analysis platform disclosed in this paper. Still taking the Presto engine as an example, Figure 1As shown, the data analysis visualization platform module can provide visualization configuration capabilities and chart rendering capabilities, the back-end service module can provide basic permission verification, function management, etc., and convert the configuration information of the icons submitted by the user for visualization analysis into, for example, Presto engine query SQL. The optimization module is the core part of the technical solution of the embodiment of the present disclosure, which at least includes a query optimization module and a query queue module, wherein the query optimization module can be responsible for judging the complexity of the query SQL to be executed (hereinafter referred to as the structured query language query request) and allocating the query queue module, such as the Presto engine query queue (for example, including three preset Presto cluster query queues), to be responsible for simple complexity queries (corresponding to simple query queues), general complexity queries (corresponding to general query queues) and complex complexity queries (corresponding to complex query queues), that is, each query queue can use its own computing resources or query resources to execute query SQL to obtain the corresponding visualization analysis icon from, for example, the Hive offline data warehouse. Since each query queue has its own computing resources or query resources, the query SQL can be executed in parallel to improve query performance.
[0079] As some optional embodiments, the optimization module may also include a preset distributed messaging system such as Kafka to store the execution data of the query SQL in the form of messages. Kafka, as a high-throughput, low-latency distributed messaging system, is widely used in real-time data stream processing. Storing the execution data of the query SQL therein can improve the storage and processing of the execution data. Furthermore, the optimization module may also include an open source stream processing framework such as Flink, which is mainly used to process real-time data streams, that is, to consume execution data from Kafka, to determine the computing resources or query resources of each query SQL in real time, and to write the determined computing resources or query resources into, for example, a MySQL database, so as to be queried during the next query SQL execution process. In this way, by using, for example, Kafka and Flink technology to calculate the resource occupancy information of the query SQL execution in real time (as the historical execution information of the query SQL), and storing it in the MySQL database, the historical execution information of the query SQL can be obtained in real time, so as to dynamically adjust the query SQL execution strategy, etc.
[0080] based on Figure 1 The framework structure shown in FIG. 1 is a schematic diagram of a schematic diagram of a frame structure of a computer program product. The technical solution of the embodiment of the present disclosure will be described in detail below in conjunction with the accompanying drawings.
[0081] Figure 2 This is one of the flow charts of a query method according to an embodiment of the disclosed method. Figure 2 As shown, a query method according to an embodiment of the present disclosure may include the following steps:
[0082] Step 201: Receive a structured query language query request, where the structured query language query request includes a query object identifier.
[0083] As mentioned above, the structured query language query request is the aforementioned query SQL. Taking the data analysis visualization platform providing visualization configuration capabilities and chart rendering capabilities as an example, the structured query language query request of the embodiment of the present disclosure can be the icon configuration information for visualization of charts, icons, etc. input by the user. These configuration information can have corresponding query object identification codes, such as chart IDs, icon IDs, etc., and then Figure 1 The backend service section shown converts the icon configuration information used for visualization into a structured query language query request. Taking the Presto engine as an example, this is a Presto engine query SQL.
[0084] It can be understood that the structured query language query request of the embodiment of the present disclosure may include at least the following, for example: ① SELECT statement: used to specify the columns to be selected from the database table; ② FROM clause: used to specify the table to be queried; ③ WHERE clause: used to filter the result set and only return records that meet the conditions; ④ GROUP BY clause: used to group the result set by one or more columns; ⑤ HAVING clause: used to filter the grouped records and only return the groups that meet the conditions; ⑥ ORDER BY clause: used to sort the result set; ⑦ LIMIT clause or TOP clause: used to limit the number of records returned.
[0085] Step 202 : Determine the query complexity of the structured query language query request. The query complexity is used to evaluate the query efficiency of executing the structured query language query request.
[0086] In this step, the query complexity is the query resources occupied by executing the structured query language query. The query complexity of the structured query language query request can be calculated and determined, wherein the query complexity of the structured query language query request can be based on its historical execution information, and the historical execution information such as the physical scan bytes (i.e., the total amount of bytes to be scanned when executing the structured query language query request and the database reads data pages from the disk or other storage media. In SQL Server, dynamic management views (DMVs) can be used to view the physical scan bytes when the structured query language query request is executed), the number of physical scan rows (i.e., the number of data rows read from the actual data storage device during the execution of the structured query language query request. In SQL Server, SET STATISTICS IO ON can be used to display the query output statistics and the number of physical scan rows), the execution CPU (Central Processing Execution parameters include CPU time (i.e., the time consumed by the CPU when executing a Structured Query Language (SQL) query request), the number of drivers used (i.e., the total number of database drivers or driver interfaces used to execute the SQL query request), and the number of stages used (i.e., the total number of stages in the query execution plan for the SQL query request). If multiple execution parameters are included, different weights can be assigned to different execution parameters to comprehensively calculate the query complexity of the SQL query request.
[0087] As another embodiment, for a Structured Query Language (SQL) query request for which historical execution information cannot be retrieved, the query complexity can be calculated and determined using the syntax tree of the SQL query request. For example, SQL Explain can be used to obtain query parameters such as the number of query tables involved in the SQL query request (referring to the total number of query tables involved in the SQL query request), the join depth (referring to the number of nested subqueries or the number of subqueries at each level), and the query partition range (referring to the number of Hive partitions involved in the SQL query request or the size of the range), and then the query complexity of the SQL query request can be determined based on these query parameters.
[0088] Step 203 : According to the query complexity of the structured query language query request, the structured query language query request is written into a preset query queue corresponding to the query complexity.
[0089] As mentioned above Figure 1As described in, for example, three query queues may be pre-set, so that after determining the query complexity of a structured query language query request, the structured query language query request is written into a query queue corresponding to its complexity, thereby isolating the structured query language query request.
[0090] Step 204 : Execute the structured query language query request in the preset query queue through the query resources corresponding to the preset query queue corresponding to its query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
[0091] When executing a structured query language query request, it can be processed sequentially from its corresponding query queue, for example, in a first-in-first-out manner. Each query queue can be set with corresponding query resources. For example, the first query queue is set with 5 CPUs for execution, the second query queue is set with 3 CPUs for execution, and the third query queue is set with 2 CPUs for execution. In this way, the structured query language query requests in its corresponding query queue are processed separately by each query resource, thereby achieving isolation between query resources and thus achieving parallel processing, avoiding some structured query language query requests with higher query complexity from occupying a large number of query resources, while causing some structured query language query requests with lower query complexity to be in a query resource waiting state all the time, thereby improving query efficiency and query performance.
[0092] exist Figure 2 Based on the illustrated embodiment, the present disclosure also provides another embodiment. Figure 3 This is the second flow chart of a query method according to an embodiment of the disclosed method. Figure 3 As shown, a query method according to an embodiment of the present disclosure may include the following steps:
[0093] Step 201: Receive a structured query language query request, where the structured query language query request includes a query object identifier.
[0094] For details, please refer to Figure 2 For the sake of brevity, step 201 is not described again here.
[0095] Step 2021 : querying a preset database based on the query object identification code whether there is historical execution information related to the structured query language query request.
[0096] In addition to the SQL (Structured Query Language) to be executed, a Structured Query Language (SQL) query request also includes user-entered information such as a report ID (identity document, such as an identification number, account number, unique code, or dedicated number) and a chart ID, which are used for visualization. In the disclosed embodiment, a preset database (e.g., a MySQL database) can be queried based on this configuration information (i.e., the query object identifier) to obtain historical execution information associated with the SQL query request.
[0097] Among them, a large amount of historical execution information of structured query language query requests can be stored in the preset database. For example, the query object identification code (such as report ID, chart ID, etc.) can be used as index information. In this way, when the present disclosure performs a historical execution information query, the query object identification code can be used to traverse the preset database to determine whether the preset database stores historical execution information of the structured query language query request.
[0098] If it exists, execute step 2022; if it does not exist, execute step 2023.
[0099] Step 2022: Determine the query complexity of the structured query language query request based on historical execution information.
[0100] In an embodiment of the present disclosure, illustratively, historical execution information related to a structured query language query request can be obtained from a preset database, wherein the historical execution information is a plurality of execution parameters obtained during the execution of the structured query language query request. Then, based on the degree of influence of each execution parameter on the query complexity, the plurality of execution parameters are divided into a plurality of calculation dimensions, wherein a corresponding first preset weight value is set for each calculation dimension (used to represent the degree of influence of any calculation dimension on the query complexity, which can be preset according to the degree of influence of each execution parameter on the query complexity). Then, based on the first preset weight value of each calculation dimension and the first preset score of each execution parameter in each calculation dimension, the total complexity of the plurality of calculation dimensions is calculated, wherein the total complexity of the plurality of calculation dimensions is the query complexity of the structured query language query request, and the first preset score is the importance of each execution parameter of any preset calculation dimension to the query complexity.
[0101] Exemplarily, the historical execution information of the embodiment of the present disclosure may include execution parameters such as the amount of physical scan bytes, the number of physical scan lines, the CPU time occupied by the execution, the number of drivers occupied by the execution, and the number of stages into which the execution is divided. For example, if the amount of physical scan bytes is larger, the query complexity of the structured query language query request will be more complex. The more physical scan lines there are, the longer the CPU time occupied by the execution, the more drivers occupied by the execution, and the more stages into which the execution is divided, the more complex the query complexity of the structured query language query request will be. That is, these execution parameters can reflect the query complexity of the execution of the structured query language query request. As an optional embodiment of the present disclosure, these execution parameters can be further divided into multiple calculation dimensions according to the degree of influence on the query complexity. For example, the number of drivers occupied by the execution and the number of stages divided by the execution have the greatest influence on the query complexity, and the two are divided into the first calculation dimension; the physical scan bytes and the number of materialized scan rows have the second greatest influence on the query complexity, and the two are divided into the second calculation dimension. Similarly, the CPU time occupied by the execution has a smaller influence on the query complexity, and it is divided into the third calculation dimension, that is, the five execution parameters are divided into three-dimensional calculation dimensions.
[0102] Furthermore, different weights are assigned to each calculation dimension based on their impact on query complexity. For example, a weight of 50% is assigned to the first calculation dimension (number of drivers used and number of execution stages), 30% to the second calculation dimension (physical scan bytes and materialized scan rows), and 20% to the third calculation dimension (CPU time used). Furthermore, a corresponding score is assigned to each execution parameter to indicate its importance to query complexity. For example, the scores for number of drivers used and number of execution stages are assigned to 5 and 3, respectively; the scores for physical scan bytes and materialized scan rows are assigned to 3 and 2, respectively; and the score for CPU time is assigned to 1.
[0103] Based on the settings of the score and weight value, the query complexity of the structured query language query request is further determined, for example, by the following calculation method:
[0104] Query complexity = (the score of the number of drivers occupied by the execution + the score of the number of stages divided into execution phases) * the weight value of the first calculation dimension + (the score of the number of physical scan bytes + the score of the number of materialized scan rows) * the weight value of the second calculation dimension + the score of the CPU time occupied by the execution * the weight value of the third calculation dimension.
[0105] The above calculation method, score, weight, etc. are only used as an example and are not limited in this disclosure.
[0106] In addition, the score of each execution parameter can also be dynamically adjusted periodically. For example, the impact or importance of any execution parameter on the structured query language query request can be determined based on the data of any execution parameter within a certain period, and its score can be dynamically adjusted.
[0107] Step 2023: Determine the query complexity of the structured query language query request based on the query syntax tree of the structured query language query request.
[0108] In an embodiment of the present disclosure, when historical execution information of a structured query language (SQL) query request is not stored in a preset database, a query syntax tree can be parsed to obtain query parameters, thereby using the query parameters to estimate the query complexity of the SQL query request. Exemplarily, the query syntax tree of the SQL query request is parsed to obtain multiple query parameters of the SQL query request. The multiple query parameters are then divided into multiple calculation dimensions based on the impact of each query parameter on the query complexity. Each calculation dimension is assigned a corresponding second preset weight value (preset based on the impact of each query parameter on the query complexity). The total complexity of the multiple calculation dimensions is calculated based on the second preset weight value of each calculation dimension and the second preset score of each query parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the SQL query request, wherein the second preset score represents the importance of each query parameter in any preset calculation dimension to the query complexity.
[0109] During database query optimization, SQL Explain statements are used to display the execution plan of a Structured Query Language (SQL) query statement. The execution plan describes how the database executes the SQL query, including how to access tables and indexes, and the order of execution. The SQL syntax tree (AST) is a tree-like data structure used to represent the SQL query structure and is a key output of the SQL parsing process. Thus, in the disclosed embodiments, the number of query tables, query partition range, and join depth of a Structured Query Language (SQL) query request can be obtained by parsing the SQL syntax tree or SQL Explain. The number of data partition scan bytes can then be estimated based on the query partition range (for example, if the query requires scanning all partitions, including 10GB of bytes, the worst-case estimate is that the number of data partition scan bytes is 10GB). This yields at least three query parameters: the number of query tables, the join depth, and the number of data partition scan bytes.
[0110] Furthermore, the three query parameters, namely the number of query tables, join depth, and number of bytes scanned for a data partition, can be divided into three calculation dimensions. For example, the estimated number of bytes scanned for a data partition is used as the first calculation dimension, the join depth is used as the second calculation dimension, and the number of query tables is used as the third calculation dimension. Each query parameter preset value is then assigned a corresponding score, which represents the importance or impact of the query parameter on the query complexity. For example, the score for the number of bytes scanned for a data partition is 5, the score for the join depth is 3, and the score for the number of query tables is 2. Furthermore, different weights are assigned to different calculation dimensions. For example, the weight of the first calculation dimension is 50%, the weight of the second calculation dimension is 30%, and the weight of the third calculation dimension is 20%.
[0111] Based on the settings of the score and weight value, the query complexity of the structured query language query request is further determined, for example, by the following calculation method:
[0112] Query complexity = (score of the number of bytes scanned per data partition) * weight of the first calculation dimension + (score of the join depth) * weight of the second calculation dimension + score of the number of query tables * weight of the third calculation dimension.
[0113] The above calculation method, score, weight, etc. are only used as an example and are not limited in this disclosure.
[0114] In addition, the score of each query parameter can also be dynamically adjusted periodically. For example, the influence or importance of any query parameter on the structured query language query request can be determined based on the data of any query parameter within a certain period, and its score can be dynamically adjusted.
[0115] Step 203 : According to the query complexity of the structured query language query request, the structured query language query request is written into a preset query queue corresponding to the query complexity.
[0116] As an embodiment of the present disclosure, the complexity level of the query complexity of the structured query language query request can be determined based on the query complexity of the structured query language query request and a preset complexity threshold, and then the structured query language query request is written into a preset query queue corresponding to its complexity level.
[0117] Exemplarily, when it is determined that the query complexity of the structured query language query request is less than or equal to a first preset complexity threshold, the complexity level of the query complexity of the structured query language query request is determined to be a first complexity level; when it is determined that the query complexity of the structured query language query request is greater than the first preset complexity threshold and less than or equal to a second preset complexity threshold, the complexity level of the query complexity of the structured query language query request is determined to be a second complexity level; and when it is determined that the query complexity of the structured query language query request is greater than the second preset complexity threshold, the complexity level of the query complexity of the structured query language query request is determined to be a third complexity level. The second preset complexity threshold is greater than the first preset complexity threshold.
[0118] As an example, the first preset complexity threshold is, for example, 10 points, and the second preset complexity threshold is, for example, 60 points. In this way, when the query complexity of the structured query language query request is less than or equal to 10 points, it is determined to be the first complexity, for example, it may correspond to the aforementioned simple complexity; and when the query complexity of the structured query language query request is greater than 10 points and less than or equal to 60 points, it is determined to be the second complexity, for example, it may correspond to the aforementioned general complexity; similarly, when the query complexity of the structured query language query request is greater than 60 points, it is determined to be the third complexity, for example, it may correspond to the aforementioned complex complexity.
[0119] In this way, the structured query language query requests are divided into complexity levels according to their query complexity, and then the structured query language query requests are written into preset query queues corresponding to their complexity levels according to different complexity levels. For example, the first complexity corresponds to the simple query queue, the second complexity corresponds to the general query queue, and the third complexity corresponds to the complex query queue, so as to achieve classified isolation of the structured query language query requests.
[0120] Step 204 : Execute the structured query language query request in the preset query queue through the query resources corresponding to the preset query queue corresponding to its query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
[0121] In the disclosed embodiments, the target query object is, for example, a report or icon for visualization corresponding to a query object identifier (e.g., a report ID, a chart ID, etc.). These reports, icons, etc. can be stored in the data warehouse in a partitioned manner. For example, a report ID can be stored in a corresponding manner with its corresponding report. This allows the report ID in a structured query language query request to be used to determine the query table in the data warehouse where the report is located, and then the report corresponding to the report ID can be retrieved from the query table.
[0122] Among them, the query resources corresponding to the preset query queues are computing resources corresponding to executing structured query language query requests, including but not limited to resources such as CPU, memory, and IO required for query execution. In the embodiment of the present disclosure, different query resources (or computing resources) can be pre-configured for different queues. For example, if the number of structured query language query requests in the general query queue is large, more query resources (or computing resources) can be configured to process them, while if the number of structured query language query requests in the complex query queue is small, a small number of query resources (or computing resources) can be configured to process them. In this way, reasonable allocation and resource isolation of query resources (or computing resources) are achieved, which not only avoids the structured query language query requests in the complex query queue occupying resources for a long time, causing other structured query language query requests to wait for query resources (or computing resources), but also achieves parallel processing of each query queue, improves query efficiency, and enhances query performance.
[0123] As an embodiment, the allocation of query resources can be dynamically adjusted according to the number of structured query language query requests in different query queues. For example, during the time period T1-T2, if there are more structured query language query requests in the simple query queue, more query resources will be allocated to it. During the time period T2-T3, if there are more structured query language query requests in the general query queue, more query resources will be added to it. In this way, structured query language query requests can be processed in a timely manner, thereby improving query efficiency.
[0124] Step 205: Obtain the execution data of the structured query language query request and write it into a preset distributed message system.
[0125] After completing step 204, the structured query language query request completes the query execution, and then the execution data of the query execution is obtained in step 205. For example, the execution data can be obtained using a specific function or command provided by the database management system (DBMS). Taking MySQL as an example, it can obtain the execution data through an API or a client tool (such as phpMyAdmin, MySQLWorkbench). Among them, the execution data includes but is not limited to the physical scan byte amount, the number of materialized scan rows, the CPU time occupied by the execution, the number of Drivers occupied by the execution, the number of stages divided by the execution, and other specific real-time data information corresponding to the execution parameters. Since the amount of specific real-time data information corresponding to the execution parameters is large during the query execution process, in order to ensure the reliability of the execution data and continuously and stably support the subsequent execution data calculation, a distributed messaging system with high throughput can be used in the embodiment of the present disclosure to store the execution data, such as Kafka, for subsequent calculation and consumption processing.
[0126] Step 206 : Obtain execution data from a preset distributed messaging system to calculate and determine execution resource information of the structured query language query request based on the execution data.
[0127] In this step, based on the execution data (specific real-time data corresponding to the execution parameters), further statistical calculations are performed to determine the execution resource information of the structured query language query request. The execution resource information includes, for example, statistical data of execution parameters such as the physical scan bytes, the number of materialized scan rows, the CPU time occupied by the execution, the number of drivers occupied by the execution, and the number of stages divided into which the execution is performed. For example, the total physical scan bytes are 10GB, the number of materialized scan rows is 300 rows, the CPU time occupied by the execution is 5ms, and the number of drivers occupied by the execution is 5. That is, based on the specific real-time data corresponding to the execution parameters (this data may be scattered data), the real-time data information is further statistically calculated to obtain the statistical data, which is the execution resource information of the structured query language query request.
[0128] As an optional embodiment of the present disclosure, in order to ensure the real-time performance and stability of execution data calculation, the open source stream processing framework Flink technology, which has the characteristics of high throughput, low latency and strong fault tolerance and is mainly used to process real-time data streams, can be adopted. That is, the execution data is statistically calculated through Flink technology to obtain the execution resource information of the structured query language query request.
[0129] Step 207: Store the execution resource information of the structured query language query request as historical execution information of the structured query language query request in a preset database.
[0130] As an optional embodiment of the present disclosure, the preset database can be a MySQL database, which can store a large amount of historical execution information corresponding to structured query language query requests. For example, the query object identification code (such as report ID, chart ID, etc.) in the structured query language query request can be used as index information to store the historical execution information of the structured query language query request.
[0131] The aforementioned execution resource information is statistical data on execution parameters calculated in real time after the execution of a structured query language (SQL) query request. This information is stored in a preset database to facilitate querying during subsequent data processing and utilization. Therefore, the execution resource information is stored as historical execution information for SQL query requests. For example, during the next execution of a SQL query request, the preset database can be queried to determine whether corresponding historical execution information (i.e., the statistically analyzed execution resource information) exists. This provides an effective data foundation for determining the query complexity of SQL query requests using historical execution information.
[0132] In summary, according to the technical solution of the embodiment of the present disclosure, by determining the query complexity of the structured query language query, and writing the structured query language query into the query queue corresponding to its query complexity according to the query complexity, the corresponding query resources are used to process the structured query language queries of different query queues. In this way, the structured query language queries of different complexities can be isolated to achieve the purpose of query resource isolation, avoid complex structured query language queries occupying too many query (computing) resources, and affect the query speed of simple structured query language queries, thereby improving the query processing performance of structured query language queries.
[0133] In addition, before executing the query of the structured query language query request, the query complexity of the structured query language query request in different situations is calculated and estimated by parsing the query syntax tree and the query history execution information to improve the universality of the solution. Moreover, if only the query complexity is calculated by parsing the query syntax tree, the accuracy of the query complexity obtained is highly dependent on the trained model, and the complexity estimation model is unstable, which may also lead to poor accuracy of the query complexity; and if the query complexity is calculated based on the historical execution information, the structured query language query request is required to have a certain amount of execution resource information in order to accurately evaluate the query complexity. In this way, the embodiment of the present disclosure, for different situations, respectively uses the parsing query syntax tree and the query history execution information to solve the problem of query complexity estimation, forming a complementary solution and improving the accuracy of the query complexity estimation.
[0134] Secondly, by using technologies such as Kafka and Flink to calculate in real time the resource information (execution resource information or historical execution information) occupied when executing a structured query language query request, the occupied resource information (execution resource information or historical execution information) can be updated in a timely manner to, for example, a MySQL database, so as to realize real-time calculation of the query complexity of the structured query language query request, thereby improving the query efficiency of the structured query language query request and enhancing the query performance.
[0135] Correspondingly, the embodiments of the present disclosure also provide device embodiments corresponding to the aforementioned method embodiments. Figure 4 This is a structural block diagram of a query device according to an embodiment of the present disclosure. Figure 4 As shown, a query device according to an embodiment of the present disclosure may include a query request receiving module 401, a complexity determining module 402, a queue writing module 403, and a query request executing module 404, wherein:
[0136] The query request receiving module 401 is configured to receive a structured query language query request, wherein the structured query language query request includes a query object identification code;
[0137] A complexity determination module 402 is configured to determine the query complexity of the structured query language query request, wherein the query complexity is used to evaluate the query efficiency of executing the structured query language query request;
[0138] A queue writing module 403 is configured to write the structured query language query request into a preset query queue corresponding to the query complexity of the structured query language query request according to the query complexity of the structured query language query request;
[0139] The query request execution module 404 is used to execute the structured query language query request in the preset query queue through the query resources corresponding to the preset query queue corresponding to the query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
[0140] According to the technical solution of the embodiment of the present disclosure, by determining the query complexity of the structured query language query and writing the structured query language query into the query queue corresponding to its query complexity according to the query complexity, the corresponding query resources are used to process the structured query language queries of different query queues. In this way, the structured query language queries of different complexities can be isolated to achieve the purpose of query resource isolation, avoid complex structured query language queries occupying too many query (computing) resources and affecting the query speed of simple structured query language queries, and improve the query processing performance of structured query language queries.
[0141] exist Figure 4 On the basis of the illustrated embodiment, as an embodiment of the present disclosure, the complexity determination module further includes:
[0142] A query unit, configured to query a preset database for historical execution information related to the structured query language query request based on the query object identification code;
[0143] a first complexity determination unit, configured to determine the query complexity of the structured query language query request based on historical execution information related to the structured query language query request in response to the presence of historical execution information related to the structured query language query request in the preset database;
[0144] The second complexity determination unit is configured to determine the query complexity of the structured query language query request according to the query syntax tree of the structured query language query request in response to the absence of historical execution information related to the structured query language query request in the preset database.
[0145] As an embodiment of the present disclosure, the first complexity determination unit is further configured to:
[0146] In response to the presence of historical execution information related to the structured query language query request in the preset database, obtaining the historical execution information related to the structured query language query request from the preset database, the historical execution information being a plurality of execution parameters obtained during the execution of the structured query language query request;
[0147] Dividing the multiple execution parameters into multiple calculation dimensions according to the degree of influence of each execution parameter on the query complexity, wherein each calculation dimension is set with a corresponding first preset weight value, and the first preset weight value is pre-set according to the degree of influence of each execution parameter on the query complexity;
[0148] The total complexity of the multiple calculation dimensions is calculated based on the first preset weight value of each calculation dimension and the first preset score of each execution parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The first preset score is the importance of each execution parameter of any preset calculation dimension to the query complexity.
[0149] As an embodiment of the present disclosure, the second complexity determination unit is further configured to:
[0150] In response to the absence of historical execution information related to the structured query language query request in the preset database, parsing the query syntax tree of the structured query language query request to obtain a plurality of query parameters of the structured query language query request;
[0151] Dividing the plurality of query parameters into a plurality of calculation dimensions according to the degree of influence of each query parameter on the query complexity, wherein each calculation dimension is set with a corresponding second preset weight value, the second preset weight value being pre-set according to the degree of influence of each query parameter on the query complexity;
[0152] The total complexity of the multiple calculation dimensions is calculated based on the second preset weight value of each calculation dimension and the second preset score of each query parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The second preset score is the importance of each query parameter of any preset calculation dimension to the query complexity.
[0153] As an embodiment of the present disclosure, the queue writing module includes:
[0154] a complexity level determining unit, configured to determine a complexity level of the query complexity of the structured query language query request according to the query complexity of the structured query language query request and a preset complexity threshold;
[0155] The queue writing unit is used to write the structured query language query request into a preset query queue corresponding to its complexity level.
[0156] As an embodiment of the present disclosure, the complexity level determination unit is further configured to:
[0157] In response to determining that the query complexity of the structured query language query request is less than or equal to a first preset complexity threshold, determining a complexity level of the query complexity of the structured query language query request to be a first complexity;
[0158] In response to determining that the query complexity of the structured query language query request is greater than the first preset complexity threshold and less than or equal to a second preset complexity threshold, determining the query complexity level of the structured query language query request to be a second complexity level;
[0159] In response to determining that the query complexity of the structured query language query request is greater than the second preset complexity threshold, determining the query complexity level of the structured query language query request to be a third complexity level;
[0160] The second preset complexity threshold is greater than the first preset complexity threshold.
[0161] As an embodiment of the present disclosure, the device further includes:
[0162] an execution data acquisition module, configured to execute a structured query language query request in a preset query queue through a query resource corresponding to the preset query queue corresponding to the query complexity thereof, obtain a target query object corresponding to the query object identification code in the structured query language query request from a preset data warehouse, and then obtain execution data of the structured query language query request and write it into a preset distributed message system;
[0163] an execution resource information calculation module, configured to obtain the execution data from the preset distributed messaging system, and to calculate and determine the execution resource information of the structured query language query request based on the execution data;
[0164] The historical execution information storage module is configured to store the execution resource information of the structured query language query request as the historical execution information of the structured query language query request in the preset database.
[0165] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this disclosure. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0166] Below, reference Figure 5 The electronic device according to the embodiment of the present disclosure is described. The electronic device may be either or both of the first device and the second device, or a standalone device independent of them, and the standalone device may communicate with the first device and the second device to receive collected input signals from them.
[0167] Figure 5 A block diagram of an electronic device according to an embodiment of the present disclosure is illustrated.
[0168] like Figure 5 As shown, the electronic device includes one or more processors and memory.
[0169] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0170] The memory may store one or more computer program products, and the memory may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program products may be stored on the computer-readable storage medium, and the processor may execute the computer program products to implement the query method of each embodiment of the present disclosure described above and / or other desired functions.
[0171] In one example, the electronic device may further include an input device and an output device, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0172] In addition, the input device may also include, for example, a keyboard, a mouse, and the like.
[0173] The output device can output various information to the outside, including determined distance information, direction information, etc. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0174] Of course, to simplify, Figure 5 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, the electronic device may further include any other appropriate components according to specific application scenarios.
[0175] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the query method according to various embodiments of the present disclosure described in the above part of this specification.
[0176] The computer program product may be written in any combination of one or more programming languages to implement the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, and conventional procedural programming languages such as C or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0177] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enable the processor to execute the steps of the query method according to various embodiments of the present disclosure described in the above part of this specification.
[0178] The computer-readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can, for example, include but is not limited to a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0179] The basic principles of the present disclosure have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, and effects mentioned in this disclosure are merely illustrative and not restrictive, and should not be construed as necessarily possessed by each embodiment of the present disclosure. Furthermore, the specific details disclosed above are provided for illustrative purposes and to facilitate understanding, rather than as limitations. These details do not limit the present disclosure to necessarily being implemented using these specific details.
[0180] Each embodiment in this specification is described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. References to the same or similar parts between the various embodiments are sufficient. For system embodiments, since they largely correspond to method embodiments, their description is relatively simple. For relevant parts, references to the description of the method embodiments are sufficient.
[0181] The block diagrams of the devices, devices, equipment, and systems involved in this disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, or configured in any manner. Words such as "include," "comprise," "have," and the like are open-ended words, meaning "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or" and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0182] The methods and apparatus of the present disclosure may be implemented in many ways. For example, the methods and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above unless otherwise specified. In addition, in some embodiments, the present disclosure may also be implemented as programs recorded in a recording medium, which include machine-readable instructions for implementing the methods according to the present disclosure. Thus, the present disclosure also covers recording media that store programs for executing the methods according to the present disclosure.
[0183] It should also be noted that in the apparatus, device, and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0184] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0185] The above description has been provided for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. A query method, characterized in that: The method comprises: receiving a structured query language query request, wherein the structured query language query request includes a query object identification code; determining a query complexity of the structured query language query request, wherein the query complexity is used to evaluate a query efficiency of executing the structured query language query request; According to the query complexity of the structured query language query request, writing the structured query language query request into a preset query queue corresponding to the query complexity; The structured query language query request in the preset query queue is executed through the query resources corresponding to the preset query queue corresponding to the query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
2. The method according to claim 1, characterized in that Determining the query complexity of the structured query language query request includes: According to the query object identification code, querying a preset database whether there is historical execution information related to the structured query language query request; In response to the presence of historical execution information related to the structured query language query request in the preset database, determining the query complexity of the structured query language query request based on the historical execution information; In response to the absence of historical execution information related to the structured query language query request in the preset database, the query complexity of the structured query language query request is determined according to a query syntax tree of the structured query language query request.
3. The method according to claim 2, characterized in that In response to the presence of historical execution information related to the structured query language query request in the preset database, determining the query complexity of the structured query language query request based on the historical execution information includes: In response to the presence of historical execution information related to the structured query language query request in the preset database, obtaining the historical execution information related to the structured query language query request from the preset database, the historical execution information being a plurality of execution parameters obtained during the execution of the structured query language query request; Dividing the multiple execution parameters into multiple calculation dimensions according to the degree of influence of each execution parameter on the query complexity, wherein each calculation dimension is set with a corresponding first preset weight value, and the first preset weight value is pre-set according to the degree of influence of each execution parameter on the query complexity; The total complexity of the multiple calculation dimensions is calculated based on the first preset weight value of each calculation dimension and the first preset score of each execution parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The first preset score is the importance of each execution parameter of any preset calculation dimension to the query complexity.
4. The method according to claim 2, characterized in that In response to the absence of historical execution information related to the structured query language query request in the preset database, determining the query complexity of the structured query language query request according to the query syntax tree of the structured query language query request includes: In response to the absence of historical execution information related to the structured query language query request in the preset database, parsing the query syntax tree of the structured query language query request to obtain a plurality of query parameters of the structured query language query request; Dividing the plurality of query parameters into a plurality of calculation dimensions according to the degree of influence of each query parameter on the query complexity, wherein each calculation dimension is set with a corresponding second preset weight value, the second preset weight value being pre-set according to the degree of influence of each query parameter on the query complexity; The total complexity of the multiple calculation dimensions is calculated based on the second preset weight value of each calculation dimension and the second preset score of each query parameter in each calculation dimension. The total complexity of the multiple calculation dimensions is the query complexity of the structured query language query request. The second preset score is the importance of each query parameter of any preset calculation dimension to the query complexity.
5. The method according to any one of claims 1 to 4, characterized in that Writing the structured query language query request into a preset query queue corresponding to the query complexity of the structured query language query request according to the query complexity of the structured query language query request includes: Determining a complexity level of the query complexity of the structured query language query request according to the query complexity of the structured query language query request and a preset complexity threshold; The structured query language query request is written into a preset query queue corresponding to its complexity level.
6. The method according to claim 5, characterized in that Determining the complexity level of the query complexity of the structured query language query request based on the query complexity of the structured query language query request and a preset complexity threshold includes: In response to determining that the query complexity of the structured query language query request is less than or equal to a first preset complexity threshold, determining a complexity level of the query complexity of the structured query language query request to be a first complexity; In response to determining that the query complexity of the structured query language query request is greater than the first preset complexity threshold and less than or equal to a second preset complexity threshold, determining the query complexity level of the structured query language query request to be a second complexity level; In response to determining that the query complexity of the structured query language query request is greater than the second preset complexity threshold, determining the query complexity level of the structured query language query request to be a third complexity level; The second preset complexity threshold is greater than the first preset complexity threshold.
7. The method according to any one of claims 2 to 6, characterized in that The method comprises: After executing the structured query language query request in the preset query queue by using the query resource corresponding to the preset query queue corresponding to the query complexity thereof to obtain a target query object corresponding to the query object identification code in the structured query language query request from a preset data warehouse, obtaining execution data of the structured query language query request and writing it into a preset distributed messaging system; Acquire the execution data from the preset distributed messaging system, and calculate and determine execution resource information of the structured query language query request based on the execution data; The execution resource information of the structured query language query request is stored in the preset database as the historical execution information of the structured query language query request.
8. A query device, characterized in that: The device comprises: A query request receiving module, configured to receive a structured query language query request, wherein the structured query language query request includes a query object identification code; a complexity determination module, configured to determine the query complexity of the structured query language query request, wherein the query complexity is used to evaluate the query efficiency of executing the structured query language query request; a queue writing module, configured to write the structured query language query request into a preset query queue corresponding to the query complexity of the structured query language query request according to the query complexity of the structured query language query request; A query request execution module is used to execute the structured query language query request in the preset query queue through the query resources corresponding to the preset query queue corresponding to the query complexity, so as to obtain the target query object corresponding to the query object identification code in the structured query language query request from the preset data warehouse.
9. An electronic device, characterized in that: include: a memory for storing a computer program product; A processor is configured to execute the computer program product stored in the memory, and when the computer program product is executed, implements the method described in any one of claims 1 to 7.
10. A computer program product comprising computer program instructions, characterized in that When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.