Data query method, device, apparatus, and storage medium

CN123011970APending Publication Date: 2026-10-30TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510734296.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0004]本申请提供一种数据查询方法、装置、设备及存储介质,能够解决如何进一步优化查询计划的选择过程的问题

Benefits of technology

[0048]通过本申请提供的技术方案,在接收到来自客户端的至少一个查询请求后,确定查询请求的优先级信息,以及根据数据库系统的资源使用状态和该优先级信息,确定每个查询请求对应的至少一个候选查询计划的查询开销,进而根据至少一个候选查询计划的查询开销,确定每个查询请求的目标查询计划。因此本申请实施例通过根据数据库系统的资源使用情况和查询请求的优先级信息,来确定查询请求的目标查询计划,能够有利于优先满足高优先级的查询请求的执行。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011970A_ABST
    Figure CN123011970A_ABST
Patent Text Reader

Abstract

The application provides a data query method and device, equipment and a storage medium, and applies to the technical field of databases. The method comprises the following steps: receiving at least one query request from a client; determining priority information of the query request, the priority information being used for indicating the execution priority of the query request; determining the query overhead of at least one candidate query plan corresponding to each query request according to the resource usage state of a database system and the priority information; and determining the target query plan of each query request according to the query overhead of the at least one candidate query plan. The embodiment of the application can further optimize the selection process of the query plan.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a data query method, apparatus, device, and storage medium. Background Technology

[0002] A query plan is a detailed outline of the steps a database management system (DBMS) generates before executing a Structured Query Language (SQL) query. It guides the execution of SQL queries. Query plan analysis is a crucial step in understanding database optimization and performance optimization.

[0003] In related solutions, the database or data warehouse performs syntax parsing and semantic analysis on SQL queries, transforming them into at least one candidate query plan describing the logical operations of the query. The optimizer then selects the best execution strategy from these candidate plans based on database statistics, generating the actual execution query plan. However, because the access paths involved in the query plan are highly complex, significant effort is required for tuning, and finding the optimal path that matches system resources is difficult. Therefore, how to further optimize the query plan selection process is a problem that urgently needs to be solved. Summary of the Invention

[0004] This application provides a data query method, apparatus, device, and storage medium that can solve the problem of how to further optimize the query plan selection process.

[0005] In a first aspect, embodiments of this application provide a data query method, including:

[0006] Receive at least one query request from a client;

[0007] Determine the priority information of the query request, the priority information being used to indicate the execution priority of the query request;

[0008] Based on the resource usage status of the database system and the priority information, determine the query cost of at least one candidate query plan corresponding to each query request;

[0009] Based on the query cost of the at least one candidate query plan, a target query plan is determined for each query request.

[0010] Secondly, embodiments of this application provide a data query device, comprising:

[0011] The acquisition unit is used to receive at least one query request from the client;

[0012] The first determining unit is used to determine the priority information of the query request, wherein the priority information is used to indicate the execution priority of the query request;

[0013] The second determining unit is used to determine the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status of the database system and the priority information.

[0014] The third determining unit is used to determine the target query plan for each query request based on the query cost of the at least one candidate query plan.

[0015] In some embodiments, the at least one query request includes a first query request;

[0016] The second determining unit is configured to determine the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status of the database system and the priority information, including:

[0017] If the priority information of the first query request indicates that the first query request is of the first priority, then the query cost of at least one candidate query plan corresponding to the first query request is determined based on the current resource usage status of the first time period.

[0018] In some embodiments, the at least one query request further includes a second query request, and the second determining unit is further configured to:

[0019] If the priority information of the second query request indicates that the second query request is of the second priority, then the remaining amount of resources in the first time period is determined according to the resource usage status of the first time period and the query cost of the target query plan; wherein, the first priority is higher than the second priority;

[0020] If the remaining resource amount is greater than or equal to a preset value, then the query cost of at least one candidate query plan corresponding to the second query request is determined based on the remaining resource amount.

[0021] In some embodiments, the second determining unit is further configured to:

[0022] If the remaining resource amount is less than the preset value, then the query cost of at least one candidate query plan corresponding to the second query request is determined based on the resource usage status of the second time period after the first time period.

[0023] In some embodiments, the second determining unit is configured to determine the query cost of at least one candidate query plan corresponding to the first query request based on the current resource usage status of the first time period, including:

[0024] Based on the current resource usage status of the first time period, determine the query cost of at least one resource indicator corresponding to each candidate query plan;

[0025] The query cost of each candidate query plan is determined based on the query cost of at least one resource metric corresponding to each candidate query plan.

[0026] In some embodiments, the second determining unit is configured to determine the query cost of at least one resource indicator corresponding to each candidate query plan based on the current resource usage status of the first time period, including:

[0027] Based on the current resource usage status of the first time period, determine the latency of at least one resource indicator corresponding to each candidate query plan;

[0028] The query cost of at least one resource indicator corresponding to each candidate query plan is determined based on the usage of at least one resource indicator and the latency.

[0029] In some embodiments, the at least one resource metric includes at least one of a central processing unit (CPU), input / output, memory, storage, and network status.

[0030] In some embodiments, the first determining unit is configured to determine the priority information of the query request, including:

[0031] The priority information is determined based on the query request; wherein the query request includes at least one of the priority information and client information, and the client information includes at least one of the client identifier and service identifier.

[0032] In some embodiments, the first determining unit is configured to determine the priority information of the query request, including:

[0033] The priority information of the query request is determined based on the priority information of at least one of the data tables and indexes involved in the query request.

[0034] In some embodiments, a prediction unit is further included, for:

[0035] Based on the historical resource usage data of the database system, machine learning methods are used to predict the resource usage status of the database system in the future.

[0036] In some embodiments, the prediction unit is configured to predict the resource usage status of the database system in the future using machine learning methods based on historical resource usage data of the database system, including at least one of the following:

[0037] If the historical resource usage data is periodic data, then the random forest method is used to predict the resource usage status;

[0038] If the historical resource usage data is stable and changing, then the support vector machine method is used to predict the resource usage status.

[0039] The resource usage status is predicted using deep learning methods.

[0040] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory, the memory for storing a computer program, and the processor for calling and running the computer program stored in the memory to execute a data query method as described in the first aspect or its various implementations, including:

[0041] Receive at least one query request from a client;

[0042] Determine the priority information of the query request, the priority information being used to indicate the execution priority of the query request;

[0043] Based on the resource usage status of the database system and the priority information, determine the query cost of at least one candidate query plan corresponding to each query request;

[0044] Based on the query cost of the at least one candidate query plan, a target query plan is determined for each query request.

[0045] Fourthly, embodiments of this application provide a computer-readable storage medium for storing a computer program that causes a computer to perform the methods described in the first aspect or its various implementations.

[0046] Fifthly, embodiments of this application provide a computer program product including computer program instructions that cause a computer to perform the methods as described in the first aspect or its various implementations.

[0047] Sixthly, embodiments of this application provide a computer program that causes a computer to perform the methods described in the first aspect or its various implementations.

[0048] The technical solution provided in this application determines the priority information of each query request after receiving at least one query request from a client. Based on the resource usage status of the database system and this priority information, the query cost of at least one candidate query plan corresponding to each query request is determined. Then, based on the query costs of the at least one candidate query plan, the target query plan for each query request is determined. Therefore, by determining the target query plan for a query request based on the resource usage of the database system and the priority information of the query request, this embodiment of the application facilitates prioritizing the execution of high-priority query requests. Attached Figure Description

[0049] Figure 1 A schematic diagram of an implementation environment for the solution provided in the embodiments of this application;

[0050] Figure 2 A schematic flowchart illustrating a data query method provided in an embodiment of this application;

[0051] Figure 3 This is a schematic diagram illustrating the relationship between the application, query request, and table involved in an embodiment of this application;

[0052] Figure 4 This is a schematic diagram illustrating the relationship between the application and the query request involved in the embodiments of this application;

[0053] Figure 5 A diagram illustrating different types of resources;

[0054] Figure 6 A schematic flowchart illustrating another data query method provided in an embodiment of this application;

[0055] Figure 7 This is a schematic diagram of a target query plan involved in an embodiment of this application;

[0056] Figure 8 This is another schematic diagram illustrating the target query plan involved in the embodiments of this application;

[0057] Figure 9 This is an example of the process for optimizing a query plan involved in an embodiment of this application;

[0058] Figure 10 A schematic diagram of a data query device provided in an embodiment of this application;

[0059] Figure 11 This is a schematic block diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0060] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0061] It should be understood that in the embodiments of this application, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.

[0062] In the description of this application, unless otherwise stated, "at least one" means one or more, and "multiple" means two or more. Additionally, "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0063] It should also be understood that the descriptions of "first", "second", etc. appearing in the embodiments of this application are only for illustration and to distinguish the objects being described, and there is no order to them. They do not indicate any special limitation on the number of devices in the embodiments of this application, and cannot constitute any limitation on the embodiments of this application.

[0064] It should also be understood that specific features, structures, or characteristics relating to embodiments in the specification are included in at least one embodiment of this application. Furthermore, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0065] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products, or devices.

[0066] This application may relate to the field of cloud technology, which refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize the computation, storage, processing, and sharing of data.

[0067] First, let me explain the relevant knowledge involved in this application:

[0068] A database can be understood as an electronic filing cabinet, that is, a place to store electronic files. Users can perform operations such as adding, querying, updating, and deleting data stored in the database. A "database" is a collection of data stored together in a certain way, which can be shared by multiple users, has as little redundancy as possible, and is independent of application programs.

[0069] A data warehouse is a strategic collection of data that supports all levels of decision-making processes within an enterprise. It is a single data store created for analytical reporting and decision support purposes. It provides guidance for business process improvement, cost control, quality management, and control for enterprises that require business intelligence. Unlike databases, which typically serve the business, data warehouses typically serve analytics. Traditional databases serve business processes with small data volumes, while data warehouses serve business analytics with large data volumes.

[0070] A Database Management System (DBMS) is a computer software system designed to manage databases, generally possessing basic functions such as storage, retrieval, security, and backup. DBMSs can be classified according to the database model they support, such as relational or Extensible Markup Language (XML); or according to the type of computer they support, such as server clusters or mobile devices; or according to the query language used, such as Structured Query Language (SQL) or XQuery; or according to performance priorities, such as maximum scale or maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, simultaneously supporting multiple query languages.

[0071] Structured Query Language (SQL): The mainstream interactive language used in databases or data warehouses. It is a special-purpose programming language, a database query and programming language used to access, query, update, and manage relational database systems.

[0072] Query Plan: The internal data structure transformed from a query after it has been parsed and processed by the database / data warehouse. It defines the steps of the query execution and the input / output relationships of each step. A query plan typically includes access paths, join operations, sorting and aggregation operations, and resource consumption estimates.

[0073] The query plan includes the access path, which is a key part of the query plan. The access path refers to the data access method selected when executing the query in database query optimization, such as full table scan, index scan, sort and merge access, etc.

[0074] Databases or data warehouses perform syntax parsing and semantic analysis on SQL queries, transforming them into at least one candidate query plan describing the logical operations of the query. The optimizer then selects the best execution strategy from these candidate plans based on database statistics, generating the actual execution plan. Related solutions optimize query plans using cost calculations or expert experience to provide certain rules. However, because the access paths involved in query plans are highly complex, significant effort is required for tuning, and finding the optimal path that matches system resources is difficult. Therefore, further optimizing the query plan selection process is a pressing issue that needs to be addressed.

[0075] To address the aforementioned technical problems, embodiments of this application provide a data query method, apparatus, device, and storage medium, which can facilitate further optimization of the query plan selection process.

[0076] Specifically, in this embodiment of the application, at least one query request from a client can be received; priority information of the query request can be determined, which is used to indicate the execution priority of the query request; based on the resource usage status of the database system and the priority information, the query cost of at least one candidate query plan for each query request can be determined; based on the query cost of at least one candidate query plan, the target query plan for each query request can be determined.

[0077] Therefore, upon receiving at least one query request from a client, this embodiment determines the priority information of the query request, and based on the resource usage status of the database system and the priority information, determines the query cost of at least one candidate query plan corresponding to each query request. Then, based on the query costs of the at least one candidate query plan, it determines the target query plan for each query request. Thus, by determining the target query plan for a query request based on the resource usage of the database system and the priority information of the query request, this embodiment facilitates prioritizing the execution of high-priority query requests.

[0078] Figure 1 This is a schematic diagram of an implementation environment provided by an exemplary embodiment of this application. The implementation environment may include a terminal device 10 and a server 20. The terminal device 10 can communicate with the server 20 via a communication network. The server 20 can provide database services to the terminal device 10.

[0079] Terminal device 10 includes, but is not limited to, personal computers (PCs), mobile phones, tablets, wearable devices, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, and other electronic devices. A client running the target application is located on terminal device 10. In the field of cloud technology, terminal device 10 can also be directly referred to as a client.

[0080] The target application has database query functionality. For example, the target application provides users with database query functionality. The target application can be a standalone application, a sub-application (i.e., a mini-program) that depends on a parent application to run, or a functional webpage displayed in a browser. The types of target applications include, but are not limited to: cloud application applications, shopping applications, social application applications, interactive entertainment applications, browser applications, content sharing applications, virtual reality applications, augmented reality applications, etc., and this application embodiment does not limit these categories.

[0081] Terminal device 10 has at least data transmission and reception functions and storage functions. Optionally, terminal device 10 sends query requests to the database management system through the data transmission and reception functions. These query requests are used to request specific data from the database system or to request the database system to perform specific operations. Optionally, terminal device 10 can also receive query responses sent by the database management system through the transmission and reception functions.

[0082] Server 20 is used to provide database management services, such as distributed database management services. Server 20 can also provide database storage services. Server 20 can be implemented as a computer device. For example, if a management process runs on the computer device, the computer device is a management node; if the computer device is used to store data tables, the computer device is a data storage node.

[0083] Server 20 can be understood as the server corresponding to the target application, used to provide backend services to the clients in the target application. For example, server 20 is a cloud server used to provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The server can also be a node in the blockchain.

[0084] There may be one or more servers. When there are multiple servers, at least two servers are used to provide different services, and / or at least two servers are used to provide the same service, such as providing the same service in a load-balanced manner. This application does not limit this.

[0085] Terminal devices and servers can be connected directly or indirectly via wired or wireless communication, and this application does not limit this. This application does not limit the number of servers or terminal devices. The solution provided in this application can be implemented independently by the terminal device, independently by the server, or jointly by the terminal device and the server; this application does not limit this.

[0086] Optionally, the terminal device 10 can be used to send at least one query request to the server 20 and to display data query results. The server 20 can be used to receive at least one query request sent by the terminal device 10, and determine the query cost of at least one candidate query plan corresponding to each query request based on the priority information of the query request, and based on the resource usage status of the database system and the priority information, and then determine the target query plan for each query request based on the query cost of the at least one candidate query plan. Optionally, after determining the target query plan, the server can also execute the query request according to the target query plan and send a query response to the client based on the execution result. Therefore, this embodiment of the application, by determining the target query plan for the query request based on the resource usage status of the database system and the priority information of the query request, can facilitate the priority fulfillment of the execution of high-priority query requests.

[0087] The technical solutions of the embodiments of this application will be described in detail below through some examples. These embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0088] Figure 2 This application provides a schematic flowchart of a data query method 200, which can be executed by any electronic device with data processing capabilities, such as a server. As an example, method 200 can be performed by... Figure 1 The server 20 in the middle is executed. For example... Figure 2 As shown, the method may include steps S210 to S240.

[0089] S210, receive at least one query request from the client.

[0090] S220, determine the priority information of the query request, which is used to indicate the execution priority of the query request.

[0091] S230, based on the resource usage status and priority information of the database system, determine the query cost of at least one candidate query plan corresponding to each query request.

[0092] S240, determine the target query plan for each query request based on the query cost of at least one candidate query plan.

[0093] Therefore, upon receiving at least one query request from a client, this embodiment determines the priority information of the query request, and based on the resource usage status of the database system and the priority information, determines the query cost of at least one candidate query plan corresponding to each query request. Then, based on the query costs of the at least one candidate query plan, it determines the target query plan for each query request. Thus, by determining the target query plan for a query request based on the resource usage of the database system and the priority information of the query request, this embodiment facilitates prioritizing the execution of high-priority query requests.

[0094] For example, when the client side has a need to query, modify, or otherwise access data in the database system, it can send at least one query request to the server to request specific data from the database system or to request the database system to perform a specific operation.

[0095] For example, this query request is used to request specific data from the database system or to request the database system to perform a specific operation.

[0096] For example, a query request may include an SQL query statement. The query request is used to submit instructions to the Database Management System (DBMS) to request specific data or perform specific operations, such as data retrieval (select), data insertion (insert), data update (update), data deletion (delete), data definition, data control, and database management. The query request can specify at least one of the tables, columns, and filter conditions to be retrieved, inserted, updated, or deleted to achieve the corresponding data retrieval, insertion, update, or deletion function. Query requests can also be used to define the database structure, including creating, modifying, or deleting tables and indexes to achieve data definition functions. Query requests can also be used to control database access permissions, including granting, revoking, and checking user permissions (showgrants). Query requests can also be used to perform database management tasks, such as backup, recovery, and optimization, to achieve database management functions.

[0097] In some embodiments, a query request may include priority information. This priority information indicates the priority of the query request. For example, the priority information may indicate that the query request is of high priority, medium priority, or low priority, etc., without limitation.

[0098] In some embodiments, the query request may include client information. This client information is used to identify the source of the query request and may include, for example, at least one of a client identifier and a service identifier.

[0099] Optionally, client identifiers include, for example, client name and application name, while business identifiers include, for example, business name and session identifier. Therefore, based on the client information, relevant information about the client that sent the query request can be determined.

[0100] For example, the client may include various application clients, including but not limited to cloud application applications, shopping applications, social applications, interactive entertainment applications, browser applications, content sharing applications, virtual reality applications, augmented reality applications, etc., and this application embodiment does not limit them.

[0101] Specifically, after receiving at least one query request, the server can determine the priority information for each query request. This priority information indicates the execution priority of each query request. For example, high-priority query requests will be executed first, requesting specific data from the database system or requesting the database system to perform specific operations. Low-priority query requests can be executed while prioritizing the execution of high-priority query requests, or during periods when resources are sufficient.

[0102] In some embodiments, step S320, determining the priority information of the query request, includes:

[0103] The priority information is determined based on the query request; wherein the query request includes at least one of the priority information and client information, and the client information includes at least one of the client identifier and service identifier.

[0104] One possible approach is to determine the priority information of a query request directly based on the priority information carried in the query request when the query request includes priority information.

[0105] In another possible approach, when the query request includes client information, the priority information of the query request can be determined based on the client information carried in the query request.

[0106] Specifically, priorities can be set for clients, applications, or services, assigning specific priorities to particular clients, applications, or services. For example, real-time clients or applications, or services with real-time requirements, should be configured with high priority, such as payment clients, online interactive games, and real-time social clients or applications. Conversely, clients or applications, or services that do not require real-time processing, such as batch processing tasks, data analysis tools, and email services, can be configured with low priority and can be executed during periods of ample resource availability. Therefore, when retrieving client information from a query request, the server can determine the priority of the current query request based on the pre-configured priorities of the clients, applications, or services.

[0107] In some embodiments, determining the priority information of the query request includes:

[0108] The priority information of the query request is determined based on the priority information of at least one of the data tables and indexes involved in the query request.

[0109] In this context, the server, such as the database management system, can parse and generate a query plan based on the SQL statement in the query request, and further determine the data tables and indexes that need to be accessed when the query request is executed, that is, the data tables and indexes involved in the query request. Figure 3 This diagram illustrates the relationship between applications, query requests, and tables. For example... Figure 3 As shown, application 1 on the client side can send query request 1, query request 2, and query request 3 to the server. Query request 1 involves tables 1, 2, and 3; query request 2 involves tables 1 and 4; and query request 3 involves tables 2, 3, and 4. No query request involves tables 5 or 6.

[0110] In this embodiment, priorities can be set for data tables and indexes, giving specific tables or indexes in a database or data warehouse a specific priority. For example, tables or indexes corresponding to real-time clients or applications, or business functions, can be configured with high priority, while tables or indexes corresponding to clients or applications that do not require real-time processing, or business functions, can be configured with low priority. Therefore, when the server retrieves the data tables or indexes involved in a query request, it can determine the priority information of the current query request based on the pre-configured priorities of the tables or indexes.

[0111] For example, see continue. Figure 3You can configure tables 1 through 4 as high priority and tables 5 and 6 as low priority. This way, when application 1 sends a query request, such as any one or more of query request 1 through query request 3, it can associate with the high-priority tables 1 through 4, thus determining the high priority of the corresponding query request based on the priority information of tables 1 through 4.

[0112] For example, see Figure 4 On the client side, application 1 can send query request 1, query request 2, and query request 3 to the server. Application 2 can send query request 1, query request 2, query request 3, and query request 4 to the server. Application 3 can send query request 1 and query request 2 to the server. Each query request can correspond to a query plan. As the priority of application 1, application 2, and application 3 decreases in that order, the query requests corresponding to each application can be processed sequentially according to their priority.

[0113] Optionally, the priority information of a query request can be determined based on at least one of the priority information in the query request, client information, and data tables and / or indexes involved in the query request. This application embodiment does not limit this.

[0114] In some embodiments, the query cost of at least one candidate query plan corresponding to each query request can be determined based on the resource usage status of the database system and the priority information of the query request, thereby enabling the allocation of resource indicators for query plans of high-priority query requests to be prioritized based on the resource usage status and priority information of the database system.

[0115] The resource usage status of a database system can include the resource usage status at the current time and in the future. The resource usage status at the current time and in the future can be obtained at a time prior to the current time.

[0116] In some embodiments, machine learning methods can be used to predict the future resource usage status of the database system based on historical resource usage data.

[0117] Resource usage data is used to represent the status of resource usage, such as resource usage amount, which can also be called load status.

[0118] Specifically, since the resource usage of a database system typically follows certain patterns, this embodiment of the application uses machine learning methods based on historical resource usage data to predict the future resource status of the database system. This allows for prediction of future resource usage based on historical patterns, thus obtaining the resource usage forecast for the database system in the future. Because the resource usage of a database system can influence the allocation of resource metrics in a query plan, obtaining the future resource usage forecast enables optimization of the resource metric allocation for the query plan based on this forecast.

[0119] Optionally, the resources of the database system may include at least one of the following: central processing unit (CPU) resources, input / output (I / O) resources, memory resources, storage resources, and network resources.

[0120] One possible approach is to categorize resource usage data in a database system according to system parameters. For example, such as... Figure 5 As shown, resource usage data can include CPU time, CPU off-CPU time, memory, file system, disk ID, network, etc. Further, CPU time can include CPU on-CPU time, CPU distribution, CPU wait for CPU, Last-Level Cache Ratio (LLC ratio), system calls, etc. CPU off-CPU time can include CPU off-CPU flame graphs, CPU off-CPU distribution, etc. Memory can further include page fault flame graphs. File system can further include ext4 file distribution, page cache, etc. Disk ID can further include file ID flame graphs, ID latency, ID schedule time, etc. Network can further include retry times, send time, receive time, message sequence, etc.

[0121] In some embodiments, predicting the future resource usage status of a database system using machine learning methods based on historical resource usage data may include at least one of the following:

[0122] If the historical resource usage data is periodic data, then the random forest method is used to predict the resource usage status;

[0123] If the historical resource usage data is stable and changing, then the support vector machine method is used to predict the resource usage status.

[0124] The resource usage status is predicted using deep learning methods.

[0125] Specifically, different prediction methods can be used to predict the future resource usage status of a database system for different types of resource usage data, such as different system parameters. For example, based on the data characteristics of different types of system parameters, corresponding machine learning methods can be used to predict the resource usage for future periods.

[0126] Historical resource usage data is cyclical, such as CPU utilization and I / O usage, exhibiting periodic changes. For example, usage may be higher during the day and lower at night, or higher from Monday to Friday and lower on Saturdays and Sundays. Therefore, machine learning prediction systems based on the random forest algorithm can be used to predict these resource indicators.

[0127] For example, relevant data can first be collected, including historical data on relevant resource metrics, such as CPU utilization, I / O usage, and memory utilization, as well as the time characteristics of relevant resources, such as the corresponding date, time, day of the week, and whether it is during working hours. Then, a predictive model can be built using the random forest algorithm. The random forest algorithm can improve the accuracy and stability of predictions by constructing multiple decision trees. Training the constructed predictive model with historical data on relevant resource metrics enables the model to accurately predict the future usage of relevant resource metrics. Optionally, the execution cycle of the model can be specified, such as running predictions daily, weekly, or monthly.

[0128] For historical resource usage data that is stable and changing, such as disk usage, machine learning prediction systems based on Support Vector Machines (SVM) can be used to predict these resource indicators.

[0129] For example, relevant data can first be collected, including historical data on relevant resource metrics, such as disk usage, and optionally timestamps. Then, an SVM model can be built. For instance, for regression tasks, a Support Vector Regression (SVR) model can be used. Training the constructed predictive model with historical data on relevant resource metrics enables the model to accurately predict the future usage of those resources.

[0130] Optionally, by comparing complex historical resource usage data, such as network usage data (e.g., network traffic, network usage), deep learning methods can be used to predict the resource usage status. Deep learning models, such as neural network models, recurrent neural network models, and their variants, excel at processing time-series data and are able to capture various dependencies within the data.

[0131] For example, relevant data can be collected first, including historical data on relevant resource indicators such as network traffic, network latency, packet loss rate, and bandwidth utilization. This can be achieved by periodically collecting and storing data using network monitoring tools. Optionally, historical data can also include timestamps. Then, a deep learning model can be built. For example, for time-series data, Long Short-Term Memory (LSTM) networks or Gated Recurrent Units (GRUs) can be used. Training the constructed predictive model using historical data on relevant resource indicators allows the model to accurately predict the future usage of those resources.

[0132] Optionally, before inputting the collected historical resource usage data into the machine learning model, the historical usage data of relevant indicators can be preprocessed, including but not limited to data cleaning, extraction of useful features, standardization / normalization, etc.

[0133] After obtaining the resource usage status of the database system and the priority information of query requests, the query cost of at least one candidate query plan corresponding to each query request can be determined based on the resource usage status and priority information of the database system. This enables the allocation of resource indicators for query plans of high-priority query requests to be prioritized based on the resource usage status of the database system and the priority information of query requests.

[0134] In some embodiments, the at least one query request includes a first query request. See also Figure 6 Step S230, which determines the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status and priority information of the database system, includes the following step S231:

[0135] S231, if the priority information of the first query request indicates that the first query request is of the first priority, then the query cost of at least one candidate query plan corresponding to the first query request is determined according to the current resource usage status of the first time period.

[0136] The first priority can be the highest priority, meaning that the first query request has the highest priority in executing specific data or specific operations, or the query plan corresponding to the first query request has the highest priority in execution. For example, the first query request can be a query request corresponding to a real-time client, application, or business, or the table or index involved in the first query request can be a table or index corresponding to a real-time client, application, or business.

[0137] When the priority information of the first query request indicates that the first query request is of the first priority (i.e., the highest priority), the query cost of at least one candidate query plan corresponding to the first query request is determined according to the resource usage status of the current first time period (i.e., the current time period), which helps to prioritize the execution of the query plan of the first query request in the current time period.

[0138] The first query request, corresponding to at least one candidate query plan, can be obtained by parsing and semantically analyzing the first query request and converting it into a logical query plan. Parsing the SQL query statement checks for grammatical correctness and converts it into an internal logical structure. Semantic analysis checks whether objects involved in the query statement, such as tables, rows, or columns, exist, and whether the query conforms to semantic rules. Then, the query statement after parsing and semantic analysis is converted into a logical query plan, i.e., a candidate query plan. The logical query plan is an abstract representation describing the logical operations of the query. Finally, based on the query cost of each candidate query plan, the optimal query plan (e.g., the one with the lowest query cost) is selected as the target query plan.

[0139] Optionally, determining the query cost of at least one candidate query plan corresponding to the first query request based on the current resource usage status of the first time period includes:

[0140] Based on the current resource usage status of the first time period, determine the query cost of at least one resource indicator corresponding to each candidate query plan;

[0141] The query cost of each candidate query plan is determined based on the query cost of at least one resource metric corresponding to each candidate query plan.

[0142] Specifically, this refers to the resource usage status in the current first time period, such as the usage status of different types of resources, including CPU resources, I / O resources, memory resources, storage resources, and network resources. For example, resource usage status can include resource usage or remaining resource quantity, without limitation. Therefore, based on the current resource usage status in the first time period, i.e., the usage status of different types of resources, the query cost of at least one resource indicator corresponding to each candidate query plan can be determined. Here, query cost can refer to the resources consumed when the query plan is executed.

[0143] Optionally, the at least one resource metric includes at least one of CPU, I / O, memory, storage, and network status.

[0144] Specifically, at least one resource metric corresponds to a resource type; that is, each resource type can correspond to one resource metric. For example, CPU resources correspond to CPU resource metrics, I / O resources correspond to I / O resource metrics, memory resources correspond to memory resource metrics, storage resources correspond to storage resource metrics, and network resources correspond to network resource metrics.

[0145] In some embodiments, determining the query cost of at least one resource metric corresponding to each candidate query plan based on the current resource usage status of the first time period includes:

[0146] Based on the current resource usage status of the first time period, determine the latency of at least one resource indicator corresponding to each candidate query plan;

[0147] Based on the usage and latency of at least one resource indicator corresponding to each candidate query plan, determine the cost of at least one resource indicator corresponding to each candidate plan.

[0148] For example, the latency of at least one resource metric may include, but is not limited to, CPU latency, I / O latency, disk latency, and network latency. CPU latency is the time required to process a CPU instruction; I / O latency is the time required to complete an input / output operation; disk latency is the time required to complete a single disk read / write operation; and network latency is the time required for data units to be transmitted over a network.

[0149] The latency of resource metrics varies depending on the resource usage status. For example, when the resource usage ratio of a certain resource metric is low, it indicates that the remaining resources for that resource metric are relatively abundant, and the latency corresponding to that resource metric is low. Conversely, when the resource usage ratio of a certain resource metric is high, it indicates that the remaining resources for that resource metric are relatively scarce, and the latency corresponding to that resource metric is high. Therefore, it is necessary to determine the latency of at least one resource metric for each candidate query plan within the current first time period based on the resource usage status of that first time period. Figure 7 As shown, different resource usage states correspond to different scenarios.

[0150] The usage of at least one resource metric corresponding to the candidate query plan, such as CPU instruction count, I / O count, disk read / write count, network transfer volume, etc., is not limited. Specifically, CPU instruction count refers to the number of instructions executed by the CPU during the query plan execution, reflecting the CPU's computational burden; I / O count refers to the number of reads and writes during the query plan execution, reflecting the storage system's burden; disk read / write count refers to the number of reads and writes to the disk during the query plan execution, reflecting the disk's burden; and network transfer volume refers to the amount of data transferred over the network during the query plan execution, reflecting the network's burden.

[0151] For each resource metric, different candidate query plans correspond to different usage levels. For example, one candidate query plan may have a higher number of CPU instructions and I / O operations, and a lower amount of network data transfer, while another candidate query plan may have a lower number of CPU instructions and I / O operations, and a higher amount of network data transfer.

[0152] The query cost for each resource metric corresponding to a candidate query plan is related to the latency and usage of that resource metric; for example, it can be the product of usage and latency. Furthermore, the query cost of each candidate query plan can be obtained by summing (or weighted summing) the query costs of each resource metric, based on the query costs of the candidate query plans.

[0153] For example, see [link to previous article] Figure 7 The optimizer calculates the query cost of each candidate query path by incorporating different latency scenarios into different candidate query plans. The optimizer can then select the query plan with the lowest query cost as the final target query plan. This target query plan corresponds to one of multiple scenarios.

[0154] For example, see Figure 8For a set of candidate query plans, i.e. query plan group, the resource usage status obtained from the system resource prediction can be used to calculate the cost and plan path for each candidate query plan to obtain the final target query plan.

[0155] For at least one candidate query plan corresponding to the first high-priority query request, the usage of each resource indicator of the candidate query plan can be estimated, such as the number of CPU instructions, I / O operations, disk read / write operations, and network transmission volume. By substituting different variables according to the latency of each resource indicator in the current first time period, the query cost of each resource indicator of each candidate query plan in the current first time period scenario can be obtained. Then, the query cost of each resource indicator can be summed to obtain the query cost of each candidate query plan in the current first time period scenario.

[0156] As a concrete example, taking a query request as a read request, the query cost of a read request can include read I / O cost and CPU cost, which satisfy the following formula:

[0157] read cost = read I / O cost + CPU cost (1)

[0158] Furthermore, read I / O overhead can include open file cost, random read cost, and sequential read cost, which satisfy the following formula:

[0159] read I / O cost=Open file cost+Random Read cost+Sequential Read cost (2)

[0161] Furthermore, CPU overhead can include base cost, page read cost, page scan cost, and tuple scan cost, which satisfy the following formula:

[0162] CPU cost=base cost+Page Read cost+Page Scan cost+Tuple Scan cost (3)

[0164] The candidate query plans for the above read request can include query plan A and query plan B. According to equations (1) to (3) above, the query cost of plan A can be calculated as follows:

[0165] 4995 = 4030 + 965;

[0166] Wherein, 4030 = 1 * 30 + 3000 + 1000;

[0167] 965 = 10 * 30 + 0.01 * 11000 + 0.005 * 11000 + 11000 * 0.001 * 3.

[0168] The query cost for Plan B is calculated as follows:

[0169] 2635 = 2260 + 375;

[0170] 2260 = 1 * 10 + 1000 + 1250;

[0171] 375 = 10*10 + 0.01*11000 + 0.005*11000 + 110000*0.001.

[0172] Therefore, Plan B has a lower query cost than Plan A, and Plan B can be used as the target query plan for read requests.

[0173] Therefore, in this embodiment of the application, when the priority information of the first query request indicates that the first query request is of the first priority, the query cost of at least one candidate query plan corresponding to the first query request can be determined according to the resource usage status of the current first time period. Then, based on the query cost of each candidate query plan, the target query plan for each first query request can be determined, thereby ensuring that the first query request of the first priority is executed in the current time period.

[0174] Optionally, see [link to relevant documentation] Figure 6 The at least one query request further includes a second query request, and step S230 may further include the following steps S232 to S233:

[0175] S232, if the priority information of the second query request indicates that the second query request is of the second priority, then the remaining amount of resources in the first time period is determined according to the resource usage status of the first time period and the query cost of the target query plan; wherein, the first priority is higher than the second priority.

[0176] S233, if the remaining resource amount is greater than or equal to a preset value, then determine the query cost of at least one candidate query plan corresponding to the second query request based on the remaining resource amount.

[0177] In this context, the first priority is higher than the second priority. The second priority can be a lower priority level than the highest priority, such as medium or low priority, without limitation. In other words, the priority of the second query request—whether it requests specific data or performs a specific operation, or the priority of the query plan corresponding to the second query request—is lower than that of the first query request. For example, the second query request can be a query request from a non-real-time client, an application, or a business-related table or index, or the table or index involved in the second query request can be a table or index from a non-real-time client, application, or business.

[0178] When the priority information of the second query request indicates that the second query request is of the second priority (such as medium priority or low priority), the remaining amount of resources in the first time period can be determined based on the current resource usage status of the first time period and the query cost of the target query plan corresponding to the first query request. If the remaining amount of resources is greater than or equal to a preset value, the query cost of at least one candidate query plan corresponding to the second query request can be determined based on the remaining amount of resources.

[0179] Similarly, at least one candidate query plan corresponding to the second query request can be obtained by parsing and semantically analyzing the second query request and converting it into a logical query plan. For details, please refer to the relevant description of the first query request. Then, based on the query cost of each candidate query plan, the optimal query plan (e.g., the query plan with the lowest query cost) is selected as the target query plan.

[0180] Specifically, if the remaining resources in the current first time period are greater than or equal to a preset value, it indicates that the remaining resources are sufficient for executing the second query request. At this point, the query cost of at least one candidate query plan corresponding to the second query request can be determined based on the remaining resource amount. The predicted value can be pre-configured. Specifically, the remaining resource amount includes the remaining resources of different types of resources in the current first time period, such as the usage status of CPU resources, I / O resources, memory resources, storage resources, and network resources. Based on the remaining resources in the current first time period, i.e., the remaining resources of different types of resources, the query cost of at least one resource indicator corresponding to each candidate query plan can be determined. The query cost can refer to the resources consumed when executing the query plan.

[0181] Optionally, the latency of at least one resource indicator corresponding to each candidate query plan for the second query request can be determined based on the remaining resources in the current first time period; and the cost of at least one resource indicator corresponding to each candidate query plan for the second query request can be determined based on the usage and latency of at least one resource indicator corresponding to each candidate query plan. Specifically, the process of determining the cost of at least one resource indicator corresponding to each candidate plan for the second query request can refer to the relevant description of the first query request.

[0182] Therefore, in this embodiment of the application, when the priority information of the second query request indicates that the second query request is of the second priority, the query cost of at least one candidate query plan corresponding to the second query request can be determined based on the remaining resources in the current first time period. Then, based on the query cost of each candidate query plan, the target query plan for each second query request can be determined, thereby ensuring that the second query request continues to be executed in the current time period if the first query request is executed in the current time period.

[0183] Optionally, see [link to relevant documentation] Figure 6 The method may further include the following step S234.

[0184] S234, if the remaining resource quantity is less than the preset value, then determine the query cost of at least one candidate query plan corresponding to the second query request based on the resource usage status of the second time period after the first time period.

[0185] Specifically, if the remaining resources in the first time period are less than a preset value, it means that the remaining resources are insufficient to execute the second query request. In this case, based on the resource usage status of the second time period following the first, the query cost of at least one candidate query plan corresponding to the second query request can be determined. The remaining resources in the second time period are sufficient to execute the second query request. Then, based on the query cost of each candidate query plan, the optimal query plan (e.g., the query plan with the lowest query cost) is selected as the target query plan.

[0186] Specifically, the process of determining the query cost of at least one candidate query plan corresponding to the second query request based on the resource usage status of the second time period can refer to the process of determining the query cost of at least one candidate query plan corresponding to the first query request based on the resource usage status of the first time period.

[0187] Therefore, in this embodiment of the application, when the priority information of the second query request indicates that the second query request is of the second priority, it is possible to determine the query cost of at least one candidate query plan corresponding to the second query request based on the resource usage status of the second time period when the remaining resources in the current first time period are insufficient. Then, based on the query cost of each candidate query plan, the target query plan for each second query request is determined, thereby ensuring that the second query request continues to be executed after the current time period if the first query request is executed in the current time period.

[0188] Figure 9 An example of the process of optimizing a query plan is shown. Figure 9 As shown, historical data, such as the historical resource usage status of the database system, is first collected. Then, a machine learning model is built and trained using the historical data. The trained model is then used to predict the future resource usage status of the database system. Optionally, different machine learning models can be built for different types of resource indicators based on their data characteristics to predict the usage status of different types of resource indicators. Then, based on the resource usage status of different scenarios and the corresponding parameters, the query cost is calculated for multiple candidate query plans corresponding to the query request, and the candidate query plan with the lowest query cost is selected as the target query plan. Therefore, this embodiment of the application can dynamically select a suitable query plan based on the resource usage of the database system, thereby improving the utilization rate of system resources.

[0189] Optionally, the target query plan corresponding to the higher-priority query request can be obtained first based on the priority information of the query request. Optionally, if the execution of the query plan corresponding to the higher-priority query request can be guaranteed, the query cost can be calculated based on the remaining resource amount of the candidate query plans for the lower-priority query requests, and the query plan of the lower-priority query requests can be executed if the remaining resource amount is sufficient. Therefore, the embodiments of this application can guarantee that higher-priority queries can be responded to at a high level, maximizing the chance that higher-priority queries can be responded to.

[0190] Optionally, after the target query plan is executed, the resource usage status at the time of execution can be obtained as real-time data and fed back to the machine learning model, so that the model can be adjusted according to the actual data.

[0191] The preferred embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this application, various simple modifications can be made to the technical solutions of this application, and these simple modifications all fall within the protection scope of this application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this application will not describe the various possible combinations separately. Furthermore, various different embodiments of this application can also be arbitrarily combined, as long as they do not violate the spirit of this application, they should also be considered as the content disclosed in this application.

[0192] It should also be understood that, in the various method embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0193] The methods provided in the embodiments of this application have been described above. The apparatus provided in the embodiments of this application will be described below.

[0194] Figure 10 This is a schematic diagram of a data query device 10 provided in an embodiment of this application. Figure 10 As shown, the device 10 includes: an acquisition unit 11, a first determination unit 12, a second determination unit 13, and a third determination unit 14.

[0195] The acquisition unit 11 is used to receive at least one query request from the client;

[0196] The first determining unit 12 is used to determine the priority information of the query request, wherein the priority information is used to indicate the execution priority of the query request;

[0197] The second determining unit 13 is used to determine the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status of the database system and the priority information.

[0198] The third determining unit 14 is used to determine the target query plan for each query request based on the query cost of the at least one candidate query plan.

[0199] In some embodiments, the at least one query request includes a first query request;

[0200] The second determining unit 13 is configured to determine the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status of the database system and the priority information, including:

[0201] If the priority information of the first query request indicates that the first query request is of the first priority, then the query cost of at least one candidate query plan corresponding to the first query request is determined based on the current resource usage status of the first time period.

[0202] In some embodiments, the at least one query request further includes a second query request, and the second determining unit 13 is further configured to:

[0203] If the priority information of the second query request indicates that the second query request is of the second priority, then the remaining amount of resources in the first time period is determined according to the resource usage status of the first time period and the query cost of the target query plan; wherein, the first priority is higher than the second priority;

[0204] If the remaining resource amount is greater than or equal to a preset value, then the query cost of at least one candidate query plan corresponding to the second query request is determined based on the remaining resource amount.

[0205] In some embodiments, the second determining unit 13 is further configured to:

[0206] If the remaining resource amount is less than the preset value, then the query cost of at least one candidate query plan corresponding to the second query request is determined based on the resource usage status of the second time period after the first time period.

[0207] In some embodiments, the second determining unit 13 is configured to determine the query cost of at least one candidate query plan corresponding to the first query request based on the current resource usage status of the first time period, including:

[0208] Based on the current resource usage status of the first time period, determine the query cost of at least one resource indicator corresponding to each candidate query plan;

[0209] The query cost of each candidate query plan is determined based on the query cost of at least one resource metric corresponding to each candidate query plan.

[0210] In some embodiments, the second determining unit 13 is configured to determine the query cost of at least one resource indicator corresponding to each candidate query plan based on the current resource usage status of the first time period, including:

[0211] Based on the current resource usage status of the first time period, determine the latency of at least one resource indicator corresponding to each candidate query plan;

[0212] The query cost of at least one resource indicator corresponding to each candidate query plan is determined based on the usage of at least one resource indicator and the latency.

[0213] In some embodiments, the at least one resource metric includes at least one of a central processing unit (CPU), input / output, memory, storage, and network status.

[0214] In some embodiments, the first determining unit 12 is used to determine the priority information of the query request, including:

[0215] The priority information is determined based on the query request; wherein the query request includes at least one of the priority information and client information, and the client information includes at least one of the client identifier and service identifier.

[0216] In some embodiments, the first determining unit 12 is used to determine the priority information of the query request, including:

[0217] The priority information of the query request is determined based on the priority information of at least one of the data tables and indexes involved in the query request.

[0218] In some embodiments, the apparatus 10 further includes a prediction unit for:

[0219] Based on the historical resource usage data of the database system, machine learning methods are used to predict the resource usage status of the database system in the future.

[0220] In some embodiments, the prediction unit is configured to predict the resource usage status of the database system in the future using machine learning methods based on historical resource usage data of the database system, including at least one of the following:

[0221] If the historical resource usage data is periodic data, then the random forest method is used to predict the resource usage status;

[0222] If the historical resource usage data is stable and changing, then the support vector machine method is used to predict the resource usage status.

[0223] The resource usage status is predicted using deep learning methods.

[0224] This embodiment of the application, upon receiving at least one query request from a client, determines the priority information of the query request, and based on the resource usage status of the database system and the priority information, determines the query cost of at least one candidate query plan corresponding to each query request. Then, based on the query costs of the at least one candidate query plan, it determines the target query plan for each query request. Therefore, this embodiment of the application, by determining the target query plan for a query request based on the resource usage of the database system and the priority information of the query request, can facilitate the priority fulfillment of high-priority query requests.

[0225] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, further details will not be provided here. Specifically, Figure 10 The data query device 10 shown can execute the corresponding processes in the above method embodiments, and the aforementioned and other operations and / or functions of each module in the device 10 are respectively for implementing the corresponding processes of each of the above methods 200. For the sake of brevity, they will not be described in detail here.

[0226] The apparatus of this application embodiment has been described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that this functional module can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method embodiments in this application can be completed by integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this application embodiment can be directly embodied as being executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. Optionally, the software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.

[0227] Figure 11 This is a schematic block diagram of the electronic device 30 provided in the embodiments of this application.

[0228] like Figure 11 As shown, the electronic device 30 may include:

[0229] The system includes a memory 31 and a processor 32. The memory 31 stores computer programs and transfers the program code to the processor 32. In other words, the processor 32 can retrieve and run the computer programs from the memory 31 to implement the methods described in the embodiments of this application.

[0230] For example, the processor 32 can be used to execute the data query method of the above method embodiment according to the instructions in the computer program, including:

[0231] Receive at least one query request from a client;

[0232] Determine the priority information of the query request, the priority information being used to indicate the execution priority of the query request;

[0233] Based on the resource usage status of the database system and the priority information, determine the query cost of at least one candidate query plan corresponding to each query request;

[0234] Based on the query cost of the at least one candidate query plan, a target query plan is determined for each query request.

[0235] This embodiment of the application, upon receiving at least one query request from a client, determines the priority information of the query request, and based on the resource usage status of the database system and the priority information, determines the query cost of at least one candidate query plan corresponding to each query request. Then, based on the query costs of the at least one candidate query plan, it determines the target query plan for each query request. Therefore, this embodiment of the application, by determining the target query plan for a query request based on the resource usage of the database system and the priority information of the query request, can facilitate the priority fulfillment of high-priority query requests.

[0236] In some embodiments of this application, the processor 32 may include, but is not limited to:

[0237] General-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0238] In some embodiments of this application, the memory 31 includes, but is not limited to:

[0239] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0240] In some embodiments of this application, the computer program may be divided into one or more modules, which are stored in the memory 31 and executed by the processor 32 to perform the method provided in this application. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.

[0241] like Figure 11 As shown, the electronic device 30 may further include:

[0242] Transceiver 33, which can be connected to processor 32 or memory 31.

[0243] The processor 32 can control the transceiver 33 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 33 may include a transmitter and a receiver. The transceiver 33 may further include antennas, and the number of antennas may be one or more.

[0244] It should be understood that the various components in the electronic device are connected through a bus system, which includes a data bus, a power bus, a control bus, and a status signal bus.

[0245] This application also provides a computer storage medium storing a computer program thereon, which, when executed by a computer, enables the computer to perform the methods of the above-described method embodiments. Alternatively, embodiments of this application also provide a computer program product containing instructions that, when executed by a computer, cause the computer to perform the methods of the above-described method embodiments.

[0246] When implemented using software, it can be implemented entirely or partially as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0247] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0248] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0249] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. For example, the functional modules in the various embodiments of this application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0250] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data query method, characterized in that, include: Receive at least one query request from a client; Determine the priority information of the query request, the priority information being used to indicate the execution priority of the query request; Based on the resource usage status of the database system and the priority information, determine the query cost of at least one candidate query plan corresponding to each query request; Based on the query cost of the at least one candidate query plan, a target query plan is determined for each query request.

2. The method according to claim 1, characterized in that, The at least one query request includes a first query request; The step of determining the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status of the database system and the priority information includes: If the priority information of the first query request indicates that the first query request is of the first priority, then the query cost of at least one candidate query plan corresponding to the first query request is determined based on the current resource usage status of the first time period.

3. The method according to claim 2, characterized in that, The at least one query request further includes a second query request, and the method further includes: If the priority information of the second query request indicates that the second query request is of the second priority, then the remaining amount of resources in the first time period is determined according to the resource usage status of the first time period and the query cost of the target query plan; wherein, the first priority is higher than the second priority; If the remaining resource amount is greater than or equal to a preset value, then the query cost of at least one candidate query plan corresponding to the second query request is determined based on the remaining resource amount.

4. The method according to claim 3, characterized in that, Also includes: If the remaining resource amount is less than the preset value, then the query cost of at least one candidate query plan corresponding to the second query request is determined based on the resource usage status of the second time period after the first time period.

5. The method according to claim 2, characterized in that, The step of determining the query cost of at least one candidate query plan corresponding to the first query request based on the current resource usage status of the first time period includes: Based on the current resource usage status of the first time period, determine the query cost of at least one resource indicator corresponding to each candidate query plan; The query cost of each candidate query plan is determined based on the query cost of at least one resource metric corresponding to each candidate query plan.

6. The method according to claim 5, characterized in that, The step of determining the query cost of at least one resource indicator corresponding to each candidate query plan based on the current resource usage status of the first time period includes: Based on the current resource usage status of the first time period, determine the latency of at least one resource indicator corresponding to each candidate query plan; The query cost of at least one resource indicator corresponding to each candidate query plan is determined based on the usage of at least one resource indicator and the latency.

7. The method according to claim 5, characterized in that, The at least one resource metric includes at least one of the following: central processing unit (CPU), input / output, memory, storage, and network status.

8. The method according to any one of claims 1-7, characterized in that, The determination of the priority information for the query request includes: The priority information is determined based on the query request; wherein the query request includes at least one of the priority information and client information, and the client information includes at least one of the client identifier and service identifier.

9. The method according to any one of claims 1-7, characterized in that, The determination of the priority information for the query request includes: The priority information of the query request is determined based on the priority information of at least one of the data tables and indexes involved in the query request.

10. The method according to any one of claims 1-7, characterized in that, Also includes: Based on the historical resource usage data of the database system, machine learning methods are used to predict the resource usage status of the database system in the future.

11. The method according to claim 10, characterized in that, The step of using machine learning methods to predict the future resource usage status of the database system based on historical resource usage data includes at least one of the following: If the historical resource usage data is periodic data, then the random forest method is used to predict the resource usage status; If the historical resource usage data is stable and changing, then the support vector machine method is used to predict the resource usage status. The resource usage status is predicted using deep learning methods.

12. A data query device, characterized in that, include: The acquisition unit is used to receive at least one query request from a client, the query request being used to request specific data from the database system or to request the database system to perform a specific operation; The first determining unit is used to determine the priority information of the query request, wherein the priority information is used to indicate the execution priority of the query request; The second determining unit is used to determine the query cost of at least one candidate query plan corresponding to each query request based on the resource usage status of the database system and the priority information. The third determining unit is used to determine the target query plan for each query request based on the query cost of the at least one candidate query plan.

13. An electronic device, characterized in that, include: A processor and a memory, the memory being used to store a computer program, the processor being used to invoke and run the computer program stored in the memory to perform the method of any one of claims 1 to 11.

14. A computer storage medium, characterized in that, Used to store a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1 to 11.

15. A computer program product, characterized in that, It includes computer program code that, when executed by an electronic device, causes the electronic device to perform the method of any one of claims 1 to 11.