A database query request control method and device, and an electronic device
By adjusting the estimated pressure value of database query requests in real time, and combining the number of query requests with the system pressure value, the execution of query requests is dynamically controlled, which solves the problem of low accuracy of system pressure value in existing technologies and achieves optimized performance and throughput of the database in high-concurrency scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-09-22
- Publication Date
- 2026-05-08
AI Technical Summary
Existing database query or access flow control mechanisms have low accuracy in determining system pressure values, which has a significant impact on the control mechanism. They cannot control database pressure and performance in real time and accurately, especially in high-concurrency user query and access scenarios. This may lead to a mismatch between the lag in obtaining system pressure and the pressure brought by real-time access requests.
By adjusting the estimated pressure value of database query requests in the request queue in real time, and combining the current number of query requests with the database system pressure value, the priority and execution order of query requests are dynamically adjusted. By comparing the estimated pressure value with the system pressure value in real time, it is ensured that query requests are executed only when the conditions are met within the waiting time, thus avoiding system pressure exceeding the limit.
It improves the performance and throughput of the database under normal stress load, ensures that the database is maintained within the normal load range, provides optimal query performance and throughput, reduces waste of system resources, and rejects unnecessary query requests.
Smart Images

Figure CN115455045B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data management technology, and in particular to a method and apparatus for controlling database query requests, and an electronic device. Background Technology
[0002] In current database query or access flow control mechanisms, during high-concurrency user query and access scenarios, a sudden increase in system pressure may occur within 5 seconds, precisely at which point the peak query and access traffic is reached. In the following period, the system pressure may not be as high, and the system actually has sufficient processing capacity most of the time. However, if the system's performance metrics within those 5 seconds are used to determine that database query and access requests exceed a threshold, and subsequent query and access requests are rejected, situations arise where query access is rejected even when subsequent system pressure is not high. The root cause is the mismatch between the lag in obtaining system pressure and the pressure from real-time query and access requests. Therefore, the accuracy of the system pressure value determined in the current database query or access flow control mechanism is low, significantly impacting the control mechanism itself. Summary of the Invention
[0003] The purpose of this application is to provide a method, apparatus, and electronic device for controlling database query requests. This addresses the problem that existing database query or access flow control mechanisms suffer from low accuracy in determining system pressure values, which significantly impacts the control mechanism.
[0004] In a first aspect, embodiments of this application provide a method for training a temperature prediction model, the method comprising:
[0005] For any database query request in the request queue, the estimated pressure value of the database query request is adjusted at least once; wherein, the request queue includes unexecuted database query requests, and the database query requests included in the request queue are added after a first judgment value determined by the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value meets a first preset condition; each time the estimated pressure value of the database query request is adjusted, it is based on the current number of query requests in the request queue and the current database system pressure value.
[0006] If the second judgment value determined based on the adjusted estimated pressure value and the current database system pressure value satisfies the first preset condition, and the duration of the database query request in the request queue does not exceed the waiting time, then the query request is executed.
[0007] In some possible embodiments, the first preset condition includes:
[0008] The sum of the estimated pressure value corresponding to the database query request and the currently obtained database system pressure value is greater than a preset threshold.
[0009] In some possible embodiments, the estimated pressure value of the database query requests is adjusted based on the current number of query requests in the request queue and the current database system pressure value, including:
[0010] If the number of query requests in the current request queue and the current database system pressure value meet the second preset condition, the estimated pressure value of the database query requests will be reduced based on the first coefficient.
[0011] If the number of query requests in the current request queue and the current database system pressure value do not meet the second preset condition, the estimated pressure value of the database query requests will be increased based on the second coefficient.
[0012] In some possible embodiments, the second preset condition includes:
[0013] The number of query requests in the current request queue is greater than a preset request threshold, while the current database system pressure is less than a preset pressure threshold.
[0014] In some possible embodiments, adjusting the estimated pressure value of any database query request in the request queue at least once further includes:
[0015] For any database query request in the request queue, if the number of query requests in the current request queue is less than a preset waiting threshold and / or the current database system pressure value is equal to the preset pressure threshold, then the adjustment of the estimated pressure value of the database query request will end.
[0016] In some possible embodiments, the estimated pressure value of the database query request is determined in the following manner:
[0017] Based on the request conditions of the database query request, the proportion of the data volume of the target table in the database query request to the total data volume of the database, and the query type pressure value of the database query request, the estimated pressure value of the database query request is determined.
[0018] In some possible embodiments, the database system stress value is determined in the following manner:
[0019] The database system pressure value is determined based on system load and database CPU utilization.
[0020] Secondly, embodiments of this application provide a control device for database query requests, the device comprising:
[0021] The estimated pressure value adjustment module for query requests is used to adjust the estimated pressure value of any database query request in the request queue at least once. The request queue includes unexecuted database query requests, and these requests are added after a first preset condition is met by a first judgment value determined based on the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value. Each adjustment to the estimated pressure value of a database query request is based on the current number of query requests in the request queue and the current database system pressure value.
[0022] The query request execution module is used to execute the query request if the second judgment value determined based on the adjusted estimated pressure value and the current database system pressure value meets the first preset condition, and the duration of the database query request in the request queue does not exceed the waiting time.
[0023] Thirdly, embodiments of this application provide an electronic device, including at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the control method for database query requests provided in the first aspect above.
[0024] Fourthly, embodiments of this application provide a computer storage medium storing a computer program for causing a computer to execute the control method for a database query request provided in the first aspect.
[0025] This application addresses the problem that the accuracy of the determined system pressure value is low in database query or access flow control mechanisms, which significantly impacts the control mechanism. This application proposes a database query request control method, apparatus, and electronic device that ensures the database provides optimal performance and throughput within normal load conditions.
[0026] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0027] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is an application architecture diagram of a database query request control method according to an embodiment of this application;
[0029] Figure 2 This is a flowchart illustrating a control method for a database query request according to an embodiment of this application;
[0030] Figure 3 This is a schematic diagram illustrating the specific control process in a database query request control method according to an embodiment of this application;
[0031] Figure 4 This is a schematic diagram illustrating the specific process adjustments in the database query request control method according to an embodiment of this application;
[0032] Figure 5 This is a schematic diagram of the control device structure for a database query request according to an embodiment of this application;
[0033] Figure 6 This is a schematic diagram of an electronic device structure according to an embodiment of this application. Detailed Implementation
[0034] The technical solutions in the embodiments of this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or", for example, A / B can mean A or B; "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0035] In the description of the embodiments of this application, unless otherwise stated, the term "multiple" refers to two or more, and other quantifiers are similarly understood. The preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0036] To further illustrate the technical solutions provided in the embodiments of this application, a detailed description is provided below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiments of this application provide method operation steps as shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on conventional or non-inventive effort. For steps that do not logically have a necessary causal relationship, the execution order of these steps is not limited to the execution order provided in the embodiments of this application. In actual processing or when the control device executes the method, it may be executed sequentially or in parallel according to the method shown in the embodiments or drawings.
[0037] Currently, some database query or access flow control mechanisms only control access to individual records in the database, without considering the differences in query performance and throughput between different records, potentially lowering the database's performance ceiling. Other technologies rely on the lag of database load pressure indicators, limiting queries in the subsequent period based on the increased pressure caused by queries in the previous period, failing to provide real-time and precise control over database pressure and performance. Still others require database request rule sets designed based on experience and manually specified, which is overly complex and difficult to implement, and cannot identify the real-time control effect of rules on database pressure, potentially failing to achieve the desired results. Specifically, a crucial approach in current database query or access flow control mechanisms is to detect database operating pressure indicators and then restrict or allow access requests based on the current database performance. This involves detecting pressure at a specific moment to control the flow threshold. In high-concurrency user scenarios, a sudden increase in database system pressure may only occur within 5 seconds, precisely at the peak of database query request traffic, while the pressure may lessen in the following period. In reality, the system has sufficient processing capacity to handle database query requests most of the time. Based on database system performance metrics within these 5 seconds, if a database request exceeds a threshold and subsequent requests are rejected, situations can arise where database query requests are refused even when subsequent database system pressure is low. The root cause is the mismatch between the lag in database system pressure assessment and the pressure from real-time access requests. Another common approach is to set rate limiting rules for certain query interfaces or specific statements based on usage and design experience. This method aims to define priorities and throughput at the interface or statement level based on experience, ensuring database stability while minimizing impact on critical database query functionality. However, this approach heavily relies on the rule designer's technical skill and experience, making implementation difficult. Furthermore, even if a rate limiting rule is designed and performs well initially, it may become ineffective with increased data volume, changes in the data model, or significant changes in business implementation, necessitating rule modifications. This requires database administrators to frequently intervene manually in real time to re-evaluate each rate limiting rule. Moreover, it cannot be guaranteed that these pre-defined rules will play their expected role in new business situations, data volumes, and data model designs. They must be adjusted repeatedly, increasing manpower investment and failing to effectively protect the normal operation of the database.
[0038] Given the low accuracy of system pressure values determined in database query or access flow control mechanisms in related technologies, which significantly impacts the control mechanism, this application proposes a database query request control method, apparatus, and electronic device that can ensure the database provides optimal performance and throughput within normal load conditions.
[0039] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings.
[0040] The control method for database query requests in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0041] Figure 1 This diagram illustrates an application architecture diagram of a database query request control method according to an embodiment of this application. The application server sends a database query request to an intermediate server; the intermediate server executes the database query request control method provided in this application; and the database server receives the query request sent by the intermediate server. It should be noted that this architecture is not limited to this specific implementation. Figure 1 The application architecture diagram is merely an illustrative example, and this application is not limited to it. Figure 1 Application architecture diagram.
[0042] Figure 2 This application illustrates a schematic flowchart of a database query request control method according to an embodiment of the present application, including:
[0043] Step 201: For any database query request in the request queue, adjust the estimated pressure value of the database query request at least once.
[0044] The request queue includes unexecuted database query requests;
[0045] The database query requests included in the request queue are added after a first judgment value determined based on the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value meets a first preset condition.
[0046] Each time the estimated pressure value of the database query request is adjusted, it is based on the number of query requests in the current request queue and the current database system pressure value.
[0047] Specifically, the request queue in this application is mainly used to, when a database query request is received, enter the request queue instead of being directly rejected if the estimated pressure value corresponding to the database query request and the first judgment value determined by the currently obtained database system pressure value meet a first preset condition. After the estimated pressure value corresponding to the database query request and the first judgment value determined by the currently obtained database system pressure value meet the first preset condition, it is determined whether the estimated pressure value corresponding to the database query request with the highest priority (in this application, the earliest database query request to enter the request queue is defined as having the highest priority) in the current request queue meets the first preset condition. If it does, it will continue to be added to the request queue. Until the duration of the database query request in the request queue does not exceed the waiting time, a message indicating that the database query request is rejected (due to waiting timeout) is returned. Then, the next database query access request is determined. The waiting time is a pre-set threshold used to limit the waiting time of the database query request in the request queue.
[0048] As an optional implementation, the first preset condition includes: the sum of the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value is greater than a preset threshold.
[0049] The preset threshold is the maximum sum of the estimated pressure value corresponding to a pre-defined database query request and the obtained database system pressure value. When the sum of the estimated pressure value corresponding to a database query request and the obtained database system pressure value is greater than the preset threshold, the current database query request needs to be added to the request queue. If the sum of the estimated pressure value corresponding to a database query request and the obtained database system pressure value is less than or equal to the preset threshold, the system can directly execute the database query request.
[0050] As an optional implementation, the estimated pressure value of the database query requests is adjusted based on the current number of query requests in the request queue and the current database system pressure value, including:
[0051] If the number of query requests in the current request queue and the current database system pressure value meet the second preset condition, the estimated pressure value of the database query requests will be reduced based on the first coefficient.
[0052] If the number of query requests in the current request queue and the current database system pressure value do not meet the second preset condition, the estimated pressure value of the database query requests will be increased based on the second coefficient.
[0053] The number of query requests in the request queue corresponds to a preset request threshold, which is the maximum number of query requests the request queue can accommodate. The database system load value corresponds to a preset load threshold, which is the maximum load the database system can withstand.
[0054] As an optional implementation, the second preset condition includes: the number of query requests in the current request queue is greater than a preset request threshold and the current database system pressure value is less than a preset pressure threshold.
[0055] Specifically, this application acknowledges that the estimated pressure value for the current database query request may sometimes be too high or too low; that is, the estimated pressure value for the current database query request may sometimes be inaccurate, thus affecting the final execution result of the current database query request. Therefore, this application addresses this issue in two ways:
[0056] Scenario 1: If the number of query requests in the current request queue is greater than or equal to a preset request threshold and the current database system pressure value is less than a preset pressure threshold, the estimated pressure value of the database query requests will be reduced based on a first coefficient.
[0057] Sometimes, in a database system, the current system pressure may not reach the pressure threshold, but if a database query request is executed, the estimated pressure for that query might slightly exceed the system pressure threshold. In this case, the estimated pressure for the current query request is considered to have an excessively high error. This application reduces the estimated pressure of the database query request based on a first coefficient. As an optional implementation, the first coefficient is preset to be less than 1. Optionally, the first coefficient is 0.9.
[0058] Scenario 2: If the number of query requests in the current request queue is less than the preset request threshold and the current database system pressure value is greater than or equal to the preset pressure threshold, the estimated pressure value of the database query requests will be increased based on the second coefficient.
[0059] In database systems, sometimes the current system pressure may exceed or equal a preset pressure threshold, but the number of database query requests in the current request queue has not reached the threshold. Executing the current query request at this time would further increase the system pressure. In such cases, it is believed that the estimated pressure value for the current query request has been underestimated. This application addresses this by increasing the estimated pressure value of the database query request based on a second coefficient, causing the query request to wait longer in the request queue until the system pressure eases before execution. As an optional implementation, the second coefficient is preset to be greater than 1. Optionally, the second coefficient is 1.1.
[0060] In general, every preset time period (e.g., every second), it checks whether there are database query requests waiting to be executed in the request queue, obtains the number of database query requests waiting to be executed in the request queue, determines whether the number of query requests in the current request queue is greater than a preset request threshold, and whether the current database system pressure value is less than a preset pressure threshold. Based on the determination result, the database query request is adjusted at least once.
[0061] As an optional implementation, for any database query request in the request queue, the estimated pressure value of the database query request is adjusted at least once, further including:
[0062] For any database query request in the request queue, if the number of query requests in the current request queue is less than a preset waiting threshold and / or the current database system pressure value is equal to the preset pressure threshold, then the adjustment of the estimated pressure value of the database query request will end.
[0063] Specifically, if the current database query request is adjusted to satisfy the condition that the number of query requests in the current request queue is less than a preset waiting threshold and / or the current database system pressure value is equal to a preset pressure threshold, the adjustment of the estimated pressure value of the database query request ends. At this time, this application believes that the estimated pressure value of the current database query request is a relatively accurate estimated pressure value. Next, the estimated pressure value corresponding to the database query request is determined by the above step 201 to see if the first judgment value determined by the currently obtained database system pressure value satisfies the first preset condition.
[0064] Step 202: If the second judgment value determined based on the adjusted estimated pressure value and the current database system pressure value satisfies the first preset condition, and the duration of the database query request in the request queue does not exceed the waiting time, then the query request is executed.
[0065] Specifically, repeat the adjustment in step 201 above until the sum of the adjusted estimated pressure value and the currently obtained database system pressure value is greater than a preset threshold, and the duration of the database query request in the request queue does not exceed the waiting time, then execute the query request.
[0066] As an optional implementation, the estimated pressure value of the database query request is determined in the following manner:
[0067] Based on the request conditions of the database query request, the proportion of the data volume of the target table in the database query request to the total data volume of the database, and the query type pressure value of the database query request, the estimated pressure value of the database query request is determined.
[0068] To accurately predict the estimated load of a database query request, it's necessary to pre-connect to the database and obtain the data volume of each business table / index, as well as the total data volume of the database. It's important to note that different database engines calculate query resource consumption differently. For example, for traditional local databases, the estimated load depends on the size of the target table in the query request; for MPP distributed databases, the size of the segment containing the target table must be considered, and if partitioning is used, the size of the corresponding partition table must be taken into account; for search engine databases, the size of the index containing the target table and the different search conditions (e.g., multi-value queries consume more resources than exact queries, and wildcard and regular expression matching consume more resources than ordinary queries) can also be used to estimate load based on the complexity and time range of the query conditions. The calculation function is Qcpc. For example, the performance pressure benchmark for a full table scan without a partition key is 10, while the pressure for a range query with a partition key is 10 / N, where N is the percentage of the range query interval within the entire partition interval. Furthermore, the pressure values vary depending on the query type of the database query request. For instance, the pressure benchmark for a single-table query is 1, while the pressure for a multi-table (N tables) join query is N.
[0069] Specifically, this application uses QC to represent the request conditions of a database query request, RD to represent the proportion of data in the target table in the database query request to the total data volume of the database, QT to represent the query type pressure value of the database query request, and CQP to represent the estimated pressure value of the database query request. The estimated pressure value of the database query request is calculated using these three indicators: QC, RD, and QT. A baseline database system pressure limit of 100 is preset (i.e., the preset pressure threshold for the database system pressure in this application).
[0070] The estimated database query request pressure value (CQP) is calculated using the formula: CQP = Qcpc(QC) RD + QT.
[0071] As an optional implementation, the database system pressure value is determined in the following manner:
[0072] The database system pressure value is determined based on system load and database CPU utilization.
[0073] To assess database performance by monitoring system stress, it's necessary to obtain system-level resource usage metrics, including CPU utilization, memory utilization, memory page swapping rate, disk I / O utilization, network I / O utilization, and system load. In addition, it's essential to obtain the database's own performance metrics, such as database process CPU utilization, TPS (Transactions Per Second), QPS (Query Per Second), and RT (Response Time).
[0074] Specifically, this application uses LD (System Load) and RC (Database CPU Utilization) as two metrics to calculate database system pressure. A baseline database system pressure limit of 100 is preset (i.e., the preset pressure threshold for database system pressure in this application). The current database system pressure value CSP is calculated using the formula: CSP = (LD + RC) 100) / 2.
[0075] In this application, upon receiving a database query request, the estimated workload for that request is first calculated, i.e., how much database system resources the request will consume. A corresponding amount of resources from the database resource pool is then allocated to this resource pool until the query is completed and its allocation is released. When there are a sufficient number of query requests, the database resource pool becomes exhausted. Subsequent query requests are then placed in a first-in-first-out (FIFO) request queue with a set waiting time. If the waiting time is exceeded, the query request is rejected, and an error message is returned to the user. If, within the waiting time, a corresponding number of resources are released from the resource pool and become available for the query, the resources are acquired and allocated before being sent to the database for the actual query. After the query is completed, the resources are released. This process of actions and logic is then repeated.
[0076] This application adjusts the estimated pressure of database query requests in real time based on the database system load, ensuring that the database load remains within a normal range. It accurately identifies the impact of each query request on the database system load, and while ensuring the effectiveness of the limitation, fully utilizes the database's operational capabilities to provide optimal query performance and throughput.
[0077] See Figure 3 This describes the specific process steps in a database query request control method.
[0078] Step 301: Receive database query requests in real time and periodically obtain the current database system pressure value every second;
[0079] Step 302: Calculate the estimated pressure value corresponding to the database query request;
[0080] Step 303: Determine whether the sum of the estimated pressure value corresponding to the database query request and the currently obtained database system pressure value is greater than a preset threshold. If yes, proceed to step 304; otherwise, proceed to step 307.
[0081] Step 304: Place the database query request into the request queue;
[0082] Step 305: Determine whether the duration of the database query request in the request queue exceeds the waiting time. If yes, proceed to step 306; otherwise, proceed to step 307.
[0083] Step 306: Reject the database query request;
[0084] Step 307: Execute the database query request.
[0085] See Figure 4 The specific process steps for adjusting a database query request control method are as follows:
[0086] Step 401: Obtain the current database system pressure value;
[0087] Step 402: Detect every second whether there are any database query requests waiting to be executed in the request queue, and obtain the current number of query requests in the request queue;
[0088] Step 403: Determine whether the number of query requests in the current request queue is greater than the preset request threshold and whether the current database system pressure value is less than the preset pressure threshold. If yes, proceed to step 404; otherwise, proceed to step 405.
[0089] Step 404: Reduce the estimated pressure value of the database query request based on the first coefficient;
[0090] Step 405: Increase the estimated pressure value of the database query request based on the second coefficient.
[0091] In summary, in this application, for any database query request in the request queue, the database query request that entered the queue earlier is prioritized for execution based on the first-in-first-out principle. During the execution determination process, the estimated pressure value of the database query request is adjusted at least once in real time based on the current number of query requests in the request queue and the current database system pressure value. As the estimated pressure value of the database query request is adjusted in real time, the current database system pressure value also changes accordingly, thereby continuing to determine whether the sum of the estimated pressure value corresponding to the database query request and the currently obtained database system pressure value is greater than a preset threshold. That is, in this application, the estimated pressure value of the database query request, the database system pressure value, and the number of database query requests in the request queue are constantly changing and fluctuating in real time. The entire process is repeated cyclically until the database query request is executed or rejected.
[0092] This application supports detecting the pressure load of the database and performing rate limiting accordingly; it improves the real-time performance of database pressure detection and predicts the estimated pressure value of database query requests based on actual data, resulting in higher availability; it does not rely on pre-set interface rules and dynamically adjusts and controls in real time, increasing availability and flexibility.
[0093] Example 2
[0094] Based on the same inventive concept, this application also provides a control device for database query requests, such as... Figure 5 As shown, the device includes:
[0095] The estimated pressure value adjustment module 501 for query requests is used to adjust the estimated pressure value of any database query request in the request queue at least once. The request queue includes unexecuted database query requests, and these requests are added after a first preset condition is met by a first judgment value determined based on the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value. Each adjustment to the estimated pressure value of a database query request is based on the current number of query requests in the request queue and the current database system pressure value.
[0096] The query request execution module 502 is used to execute the query request if the second judgment value determined based on the adjusted estimated pressure value and the current database system pressure value meets the first preset condition, and the duration of the database query request in the request queue does not exceed the waiting time.
[0097] Optionally, the first preset condition includes:
[0098] The sum of the estimated pressure value corresponding to the database query request and the currently obtained database system pressure value is greater than a preset threshold.
[0099] Optionally, the estimated pressure value adjustment module 501 for the query request is specifically used for:
[0100] If the number of query requests in the current request queue and the current database system pressure value meet the second preset condition, the estimated pressure value of the database query requests will be reduced based on the first coefficient.
[0101] If the number of query requests in the current request queue and the current database system pressure value do not meet the second preset condition, the estimated pressure value of the database query requests will be increased based on the second coefficient.
[0102] Optionally, the second preset condition includes:
[0103] The number of query requests in the current request queue is greater than a preset request threshold, while the current database system pressure is less than a preset pressure threshold.
[0104] Optionally, the estimated pressure value adjustment module 501 for the query request is further configured to:
[0105] For any database query request in the request queue, if the number of query requests in the current request queue is less than a preset waiting threshold and / or the current database system pressure value is equal to the preset pressure threshold, then the adjustment of the estimated pressure value of the database query request will end.
[0106] Optionally, the estimated pressure value of the database query request is determined in the following manner:
[0107] Based on the request conditions of the database query request, the proportion of the data volume of the target table in the database query request to the total data volume of the database, and the query type pressure value of the database query request, the estimated pressure value of the database query request is determined.
[0108] Optionally, the database system pressure value is determined in the following manner:
[0109] The database system pressure value is determined based on system load and database CPU utilization.
[0110] Having described the database query request control method and apparatus according to exemplary embodiments of this application, we will now describe an electronic device according to another exemplary embodiment of this application.
[0111] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0112] In some possible implementations, the electronic device according to this application may include at least one processor and at least one memory. The memory stores program code that, when executed by the processor, causes the processor to perform the steps of the database query request control method according to various exemplary embodiments of this application described above.
[0113] The following reference Figure 6 To describe the electronic device 130 according to this embodiment of the present application, namely the temperature prediction and decision device described above. Figure 6 The electronic device 130 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0114] like Figure 6 As shown, the electronic device 130 is presented in the form of a general electronic device. The components of the electronic device 130 may include, but are not limited to: at least one processor 131, at least one memory 132, and a bus 133 connecting different system components (including memory 132 and processor 131).
[0115] Bus 133 represents one or more of several bus structures, including a memory bus or memory controller, peripheral bus, processor, or local bus using any of the various bus structures.
[0116] The memory 132 may include a readable medium in the form of volatile memory, such as random access memory (RAM) 1321 and / or cache memory 1322, and may further include read-only memory (ROM) 1323.
[0117] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.
[0118] Electronic device 130 can also communicate with one or more external devices 134 (e.g., keyboard, pointing device, etc.), and with one or more devices that enable a user to interact with electronic device 130, and / or with any device that enables electronic device 130 to communicate with one or more other electronic devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 135. Furthermore, electronic device 130 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 136. As shown, network adapter 136 communicates with other modules used in electronic device 130 via bus 133. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0119] In some possible implementations, various aspects of the database query request control method provided in this application can also be implemented as a program product, which includes program code. When the program product is run on a computer device, the program code is used to cause the computer device to perform the steps of the database query request control method according to various exemplary embodiments of this application described above.
[0120] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0121] The monitoring program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0122] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0123] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0124] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's electronic device, partially on the user's device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).
[0125] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.
[0126] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0127] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0128] This application is described with reference to flowchart illustrations and block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block and / or segment of the flowchart illustrations and block diagrams, as well as combinations of blocks and segments in the flowchart illustrations and block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0129] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and boxes Figure 1 The function specified in one or more boxes.
[0130] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and boxes Figure 1 The steps of the function specified in one or more boxes.
[0131] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0132] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for controlling database query requests, characterized in that, The method includes: For any database query request in the request queue, the estimated pressure value of the database query request is adjusted at least once. The request queue includes unexecuted database query requests, and these requests are added after a first preset condition is met, determined by a first judgment value based on the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value. The adjustment method for each adjustment of the estimated pressure value of the database query request is as follows: if the number of query requests in the current request queue and the current database system pressure value meet a second preset condition, the estimated pressure value of the database query request is decreased based on a first coefficient; if the number of query requests in the current request queue and the current database system pressure value do not meet the second preset condition, the estimated pressure value of the database query request is increased based on a second coefficient. The first preset condition includes: the sum of the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value is greater than a preset threshold. If the second judgment value determined based on the adjusted estimated pressure value and the current database system pressure value satisfies the first preset condition, and the duration of the database query request in the request queue does not exceed the waiting time, then the query request is executed.
2. The method according to claim 1, characterized in that, The second preset condition includes: The number of query requests in the current request queue is greater than a preset request threshold, while the current database system pressure is less than a preset pressure threshold.
3. The method according to claim 1, characterized in that, For any database query request in the request queue, the estimated pressure value of the database query request is adjusted at least once, and the adjustment also includes: For any database query request in the request queue, if the number of query requests in the current request queue is less than a preset waiting threshold and / or the current database system pressure value is equal to the preset pressure threshold, then the adjustment of the estimated pressure value of the database query request will end.
4. The method according to any one of claims 1-3, characterized in that, The estimated pressure value of the database query request is determined in the following way: Based on the request conditions of the database query request, the proportion of the data volume of the target table in the database query request to the total data volume of the database, and the query type pressure value of the database query request, the estimated pressure value of the database query request is determined.
5. The method according to any one of claims 1-3, characterized in that, The database system pressure value is determined in the following way: The database system pressure value is determined based on system load and database CPU utilization.
6. A control device for database query requests, characterized in that, The device includes: The estimated pressure value adjustment module for query requests is used to adjust the estimated pressure value of any database query request in the request queue at least once. The request queue includes unexecuted database query requests, and these requests are added after a first preset condition is met, determined by a first judgment value based on the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value. The adjustment method for each adjustment of the estimated pressure value of the database query request is as follows: if the number of query requests in the current request queue and the current database system pressure value meet a second preset condition, the estimated pressure value of the database query request is decreased based on a first coefficient; if the number of query requests in the current request queue and the current database system pressure value do not meet the second preset condition, the estimated pressure value of the database query request is increased based on a second coefficient. The first preset condition includes: the sum of the estimated pressure value corresponding to the database query request and the currently acquired database system pressure value is greater than a preset threshold. The query request execution module is used to execute the query request if the second judgment value determined based on the adjusted estimated pressure value and the current database system pressure value meets the first preset condition, and the duration of the database query request in the request queue does not exceed the waiting time.
7. An electronic device, characterized in that, The method includes at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method as described in any one of claims 1-5.
8. A computer storage medium, characterized in that, The computer storage medium stores a computer program that enables the computer to perform the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Method and device for controlling concurrent operation of MySQL database
CN105718474A
KR20220051574A