Hotspot data detection method and device for database and storage medium

By using a cache mechanism based on the least recently used algorithm in the database, the query frequency of hotspot primary keys is calculated in real time, and the problem of impossible to accurately count database QPS in the existing technology is solved, and real-time accurate statistics of hotspot primary keys in the database is realized and the system load of hotspot primary keys in the database is realized The reduction.

CN119226331AActive Publication Date: 2024-12-31BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411367703.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2024-12-31
Estimated Expiration
2044-09-27

AI Technical Summary

Technical Problem

The prior art cannot accurately count the query rate per second (QPS) of the query keys in the database in real time, especially for the non-existent or deleted primary keys, resulting in the inaccurate QPS of the hotspot primary keys being not real-time and inaccurate.

Method used

A cache mechanism based on the least recently used algorithm is adopted. The database query instruction is received to determine whether the primary key exists in the real-time hotspot primary key collection. If it does not exist, it will be added. If it exists, it will be cumulative. The hotspot primary key and its query frequency will be determined after the time period ends.

Benefits of technology

Real-time accurate statistics of the primary keys being queried in the database are realized, which reduces the system load, avoids the problem of excessive QPS attenuation period, and improves the real-time and accuracy of statistics.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226331A_ABST
    Figure CN119226331A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a hotspot data detection method and device for a database and a storage medium, and the method comprises the steps: receiving a database query instruction, and judging whether a target primary key of to-be-queried data exists in a real-time hotspot primary key set of a current time period or not; if the target primary key does not exist in the real-time hotspot primary key set, whether the target primary key is added into the real-time hotspot primary key set or not is controlled through a target cache, and the target cache is a cache based on a least recently used algorithm; if the target primary key exists in the real-time hotspot primary key set, accumulating the query frequency of the target primary key in the current time period in the real-time hotspot primary key set; and after the current time period is ended, determining the hotspot primary key of the current time period according to the real-time hotspot primary key set, and outputting the query frequency of the hotspot primary key in the current time period. According to the method and the device, the hotspot primary key and the query frequency of the hotspot primary key in the current time period can be accurately determined in real time from the queried primary keys.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer and network communication technology, and in particular, to a method, device and storage medium for detecting hotspot data in a database. Background Art

[0002] In some real-time database applications, it is usually necessary to count the query rate per second (QPS) of the hot primary keys being queried in order to optimize the system load.

[0003] However, the prior art usually cannot provide accurate QPS statistics for the primary keys queried in the database. At the same time, for some queried primary keys, if they do not exist in the database or are deleted after being written, they cannot be counted. Therefore, it is impossible to accurately count the hot primary keys and their QPS in the database in real time. Summary of the invention

[0004] The disclosed embodiments provide a method, device and storage medium for detecting hotspot data in a database, so as to accurately count the hotspot primary keys in the database and their query frequencies in the current time period in real time.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for detecting hotspot data in a database, comprising:

[0006] Receive a database query instruction and determine whether the target primary key of the data to be queried exists in the real-time hot spot primary key set corresponding to the current time period;

[0007] If the target primary key does not exist in the real-time hotspot primary key set, whether to add the target primary key to the real-time hotspot primary key set is controlled by the target cache; wherein the target cache is a cache based on a least recently used algorithm;

[0008] If the target primary key exists in the real-time hotspot primary key set, then the query frequency of the target primary key in the current time period is accumulated in the real-time hotspot primary key set;

[0009] After the current time period ends, the hotspot primary key of the current time period is determined according to the real-time hotspot primary key set, and the query frequency of the hotspot primary key of the current time period in the current time period is output.

[0010] In a second aspect, an embodiment of the present disclosure provides a hotspot data detection device for a database, comprising:

[0011] A judgment unit, used to receive a database query instruction and judge whether a target primary key of the data to be queried exists in a real-time hot spot primary key set corresponding to a current time period;

[0012] A cache unit, used for controlling whether to add the target primary key to the real-time hotspot primary key set through a target cache if the target primary key does not exist in the real-time hotspot primary key set; wherein the target cache is a cache based on a least recently used algorithm;

[0013] A recording unit, configured to accumulate the query frequency of the target primary key in the current time period in the real-time hotspot primary key set if the target primary key exists in the real-time hotspot primary key set;

[0014] The statistical unit is used to determine the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, and output the query frequency of the hotspot primary key of the current time period in the current time period.

[0015] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: at least one processor and a memory;

[0016] The memory stores computer-executable instructions;

[0017] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the hotspot data detection method of the database as described in the first aspect and various possible designs of the first aspect.

[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the hotspot data detection method of the database described in the first aspect and various possible designs of the first aspect is implemented.

[0019] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including computer execution instructions. When a processor executes the computer execution instructions, it implements the hotspot data detection method of the database as described in the first aspect and various possible designs of the first aspect.

[0020] The hot data detection method, device and storage medium of the database provided by the embodiment of the present disclosure, the hot data detection method of the database, by receiving the database query instruction, determines whether the target primary key of the data to be queried exists in the real-time hot primary key set corresponding to the current time period; if the target primary key does not exist in the real-time hot primary key set, then the target primary key is added to the real-time hot primary key set through the target cache control, wherein the target cache is a cache based on the least recently used algorithm; or if the target primary key exists in the real-time hot primary key set, the query frequency of the target primary key in the current time period is accumulated in the real-time hot primary key set; after the end of the current time period, the hot primary key of the current time period is determined according to the real-time hot primary key set, and the query frequency of the hot primary key of the current time period in the current time period is output. By using the cache based on the least recently used algorithm, low-frequency primary keys can be effectively filtered, the data scale can be reduced, thereby reducing the system load, and the hot primary key and its query frequency in the current time period can be determined from the queried primary key in real time and accurately, solving the problem of being unable to count the queried primary key that does not exist in the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0022] Figure 1 A schematic diagram of a scenario of a method for detecting hotspot data in a database provided by an embodiment of the present disclosure;

[0023] Figure 2 A schematic diagram of a hotspot data detection method for a database according to an embodiment of the present disclosure;

[0024] Figure 3 A schematic diagram of a preset queue provided in an embodiment of the present disclosure;

[0025] Figure 4 A schematic diagram of a hotspot data detection method for a database provided by another embodiment of the present disclosure;

[0026] Figure 5 A structural block diagram of a hotspot data detection device for a database provided in an embodiment of the present disclosure;

[0027] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0029] In some real-time database applications, it is usually necessary to count the query rate per second (QPS) of the hot primary keys being queried to optimize the system load. For example, Redis database is an open source memory database that is widely used in scenarios such as caching, message queues, and real-time analysis. Using Redis can help users improve system performance and reduce database load, and supports multiple data structures such as strings, lists, and collections to meet the needs of different users. In real-time applications of Redis databases, it is also necessary to count the query rate per second of the hot primary keys being queried.

[0030] However, the prior art usually cannot provide accurate QPS statistics for the primary keys queried in the database. At the same time, for some queried primary keys, if they do not exist in the database or are deleted after being written, they cannot be counted. Therefore, it is impossible to accurately count the hot primary keys and their QPS in the database in real time.

[0031] Although some cloud vendors provide hot primary keys and their QPS statistics, they are usually based on value-object statistics and can only provide QPS range values. They usually accumulate the number of queries for each primary key and calculate the ratio of the query number to the time as the QPS value. This will result in the QPS of the hot primary key not being real-time and not truly reflecting the number of queries for the primary key per second. At the same time, the QPS decay period of the hot primary key will be too long due to the ratio statistics based on the time period. In addition, it is also impossible to count the queried primary keys that do not exist in the database.

[0032] In order to solve the above technical problems, the embodiments of the present invention provide a hot data detection method for a database. The method does not perform statistics based on value-object, but directly performs statistics on the primary key of the data to be queried in the database query instruction. Therefore, whether the primary key actually exists in the database does not affect the statistics of the primary key. In addition, with the help of cache and time-sharing statistics based on the least recently used algorithm, low-frequency primary keys can be effectively filtered, the data scale can be reduced, and thus the system load can be reduced. The hot primary key and its query frequency in the current time period can be determined from the queried primary keys in real time and accurately, thereby improving real-time performance and accuracy and avoiding the problem of too long QPS decay period of the hot primary key.

[0033] The application scenarios of the hot data detection method of the database of the embodiment of the present disclosure are as follows: Figure 1 As shown, it can be applied to electronic devices such as database servers. Specifically, it can receive database query instructions to determine whether the target primary key of the data to be queried exists in the real-time hot spot primary key set corresponding to the current time period; if the target primary key does not exist in the real-time hot spot primary key set, then the target cache is used to control whether to add the target primary key to the real-time hot spot primary key set, wherein the target cache is a cache based on the least recently used algorithm; or if the target primary key exists in the real-time hot spot primary key set, then the query frequency of the target primary key in the current time period is accumulated in the real-time hot spot primary key set; after the current time period ends, the hot spot primary key of the current time period is determined according to the real-time hot spot primary key set, and the query frequency of the hot spot primary key of the current time period in the current time period is output.

[0034] The hotspot data detection method of the database disclosed in the present invention will be described in detail below in conjunction with specific embodiments.

[0035] refer to Figure 2 , Figure 2 A flowchart of a method for detecting hotspot data in a database provided by an embodiment of the present disclosure. The method of this embodiment can be applied in a terminal device or a server. The method for detecting hotspot data in a database includes:

[0036] S201, receiving a database query instruction, and determining whether a target primary key of the data to be queried exists in a real-time hotspot primary key set corresponding to a current time period.

[0037] In this embodiment, when a database query instruction is received, a target primary key of the data to be queried may be determined from the database query instruction, wherein the database query instruction may include the target primary key of the data to be queried.

[0038] A real-time hotspot primary key set can be configured for each time period, where the real-time hotspot primary key set can be used to store candidate hotspot primary keys within the corresponding time period. Candidate hotspot primary keys are frequently queried primary keys, and they need to meet certain conditions to be added to the real-time hotspot primary key set, which will be introduced in detail in the following steps.

[0039] In addition, the time period can be set according to actual needs. For example, the time period can be 1 second, that is, each second corresponds to a real-time hotspot primary key set, and hotspot primary key statistics at the second level can be achieved; of course, the time period is not limited to 1 second, it can also be other preset time lengths.

[0040] In this embodiment, after receiving a database query instruction, a real-time judgment can be made based on the real-time hot primary key set corresponding to the current time period to determine whether the target primary key of the data to be queried exists in the real-time hot primary key set corresponding to the current time period, that is, to determine whether the target primary key of the data to be queried has been determined as a candidate hot primary key within the current time period.

[0041] Furthermore, different operations may be performed according to the judgment result. Specifically, if it is determined that the target primary key does not exist in the real-time hotspot primary key set, S202 is executed; if it is determined that the target primary key exists in the real-time hotspot primary key set, S203 is executed.

[0042] S202: If the target primary key does not exist in the real-time hotspot primary key set, whether to add the target primary key to the real-time hotspot primary key set is controlled by the target cache, wherein the target cache is a cache based on a least recently used algorithm.

[0043] In this embodiment, a target cache based on a least recently used (Least Recently Used, LRU) algorithm, namely, LRU Cache, is pre-configured, which can be used to filter out some primary keys with low query frequency. The least recently used algorithm eliminates the least recently used cache data to release more cache space when the cache space is full.

[0044] In this embodiment, the primary keys that can be stored in the target cache based on the least recently used algorithm are primary keys that do not exist in the real-time hotspot primary key set and have been recently queried. Based on the least recently used algorithm, the primary keys that have not been frequently queried recently can be filtered out, and then the primary keys that do not exist in the real-time hotspot primary key set and have been frequently queried recently can be added to the real-time hotspot primary key set.

[0045] Optionally, S202 may specifically include:

[0046] S2021, determining whether the target primary key is stored in the target cache;

[0047] If the target primary key is not stored in the target cache, execute S2022; if the target primary key is stored in the target cache, execute S2023;

[0048] S2022: If the target primary key is not stored in the target cache, add the target primary key to the target cache based on a least recently used algorithm;

[0049] S2023. If the target primary key is stored in the target cache, remove the target primary key from the target cache and add it to the real-time hot spot primary key set.

[0050] In this embodiment, since the storage space of the target cache based on the least recently used algorithm is limited, that is, the number of primary keys that can be cached is limited, for the target primary key that does not exist in the real-time hot spot primary key set, if the target primary key is not stored in the target cache, it means that there may be two situations. One situation is that the target primary key has never been queried before, and this is the first time it is queried. The other situation is that the target primary key has been queried before and has been stored in the target cache, but the query frequency is not high. It is eliminated and cleared from the target cache based on the least recently used algorithm. Regardless of which situation, as long as the target primary key is not stored in the target cache, the target primary key is added to the target cache based on the least recently used algorithm. It should be noted that in this embodiment, the target cache of the least recently used algorithm may not record the number of queries, that is, the target primary key is added to the target cache based on the least recently used algorithm. Specifically, if there is a storage location in the target cache, the target primary key is directly stored in the target cache. If there is no storage location in the target cache, the earliest queried primary key stored in the target cache is eliminated without paying attention to the number of queries. As long as the target primary key is stored in the target cache, it means that the time interval between the current query of the target primary key and the last query of the target primary key may be relatively close, or there are relatively few queries on other primary keys between the current query of the target primary key and the last query of the target primary key, and the target primary key is already stored in the target cache and has not been eliminated by other primary keys, which means that the target primary key is queried frequently. The target primary key can be added to the real-time hot spot primary key set, and the target primary key can be removed from the target cache. Subsequently, you only need to use the real-time hot spot primary key set to pay attention to the query status of the target primary key, and there is no need to occupy the storage space of the target cache.

[0051] Optionally, the size of the storage space of the target cache based on the least recently used algorithm can determine the query frequency of the primary keys that can be added to the real-time hot spot primary key set. Therefore, the size of the storage space of the target cache can be determined based on the total number of queries allowed by the database in a single time period and the preset single time period query frequency threshold, that is, the number of primary keys allowed to be stored in the target cache can be determined, and then the storage space of the target cache can be configured based on the number of primary keys allowed to be stored.

[0052] For example, the total number of queries allowed by the database in a single time period is 100,000, and the preset query frequency threshold for a single time period is 3,000, that is, 3,000 queries per second is considered a hot primary key. If a primary key is a hot primary key, it will be queried once every 100,000 / 3,000≈33 queries on average. Therefore, the number of primary keys allowed to be stored in the target cache can be set to 32. If a target primary key has been stored in the target cache, if the target primary key is not a hot primary key, it is very likely that it will not be queried again in the next 32 queries. , it will be eliminated from the target cache based on the least recently used algorithm, and if the target primary key is a hotspot primary key, it is very likely to be queried again in the next 32 queries, and when the target primary key is queried again, the target primary key already stored in the target cache has not been eliminated, so it can be added to the real-time hotspot primary key set. By setting the number of primary keys allowed to be stored in the target cache based on the ratio of the total number of queries allowed by the database in a single time period to the preset single time period query frequency threshold, the initial screening of hotspot primary keys can be achieved, and primary keys with low query frequency can also be filtered out.

[0053] S203: If the target primary key exists in the real-time hotspot primary key set, the query frequency of the target primary key in the current time period is accumulated in the real-time hotspot primary key set.

[0054] In this embodiment, if the target primary key exists in the real-time hotspot primary key set, the query frequency of the target primary key in the current time period can be directly accumulated in the real-time hotspot primary key set. Specifically, when the target primary key is first added to the real-time hotspot primary key set, the query frequency of the target primary key in the current time period is recorded as 1. If the target primary key is subsequently queried within the current time period, the query frequency of the target primary key in the current time period is accumulated by 1 each time the target primary key is queried. Finally, at the end of the current time period, the query frequency of the target primary key in the current time period can be obtained. If the time period length is 1 second, the query frequency of the target primary key in the current time period is also the query rate per second (Queries-per-second, QPS) of the target primary key in the current 1 second.

[0055] S204: After the current time period ends, determine the hotspot primary key of the current time period according to the real-time hotspot primary key set, and output the query frequency of the hotspot primary key of the current time period in the current time period.

[0056] In this embodiment, after the current time period ends, the real-time hotspot primary key set records the query frequencies of all candidate hotspot primary keys in the current time period, and the hotspot primary key of the current time period can be determined based on the real-time hotspot primary key set.

[0057] Optionally, all candidate hotspot primary keys in the real-time hotspot primary key set can be sorted based on their query frequency in the current time period, and the first preset number of primary keys with the highest query frequency in the current time period can be determined as the hotspot primary keys of the current time period. For example, if the first preset number is k, then the Topk primary keys with the highest query frequency in the current time period in the real-time hotspot primary key set are determined as the hotspot primary keys of the current time period.

[0058] Furthermore, since the number of primary keys included in the real-time hot spot primary key set may be relatively large, in order to improve the sorting efficiency, a filtering can be performed first to filter out the primary keys with lower query frequency in the current time period. Specifically, the primary keys in the real-time hot spot primary key set whose query frequency in the current time period is lower than the preset single time period query frequency threshold can be filtered out, and then the remaining primary keys in the real-time hot spot primary key set can be sorted according to the query frequency in the current time period. This can reduce the amount of sorted data, improve sorting efficiency, and thus quickly determine the hot spot primary keys of the current time period.

[0059] Optionally, the real-time requirement of the process S204 is not as high as that of the aforementioned steps. The real-time hotspot primary key set corresponding to the current time period can be output, and the real-time hotspot primary key set corresponding to the current time period can be processed in an asynchronous manner to determine the hotspot primary key of the current time period, and the query frequency of the hotspot primary key of the current time period can be output, thereby reducing the performance impact of the main thread.

[0060] The hot data detection method of the database provided in the present embodiment receives a database query instruction to determine whether the target primary key of the data to be queried exists in the real-time hot primary key set corresponding to the current time period; if the target primary key does not exist in the real-time hot primary key set, then the target cache is used to control whether to add the target primary key to the real-time hot primary key set, wherein the target cache is a cache based on the least recently used algorithm; or if the target primary key exists in the real-time hot primary key set, then the query frequency of the target primary key in the current time period is accumulated in the real-time hot primary key set; after the current time period ends, the hot primary key of the current time period is determined according to the real-time hot primary key set, and the query frequency of the hot primary key of the current time period in the current time period is output. By using the cache based on the least recently used algorithm, low-frequency primary keys can be effectively filtered, the data scale can be reduced, thereby reducing the system load, and the hot primary key and its query frequency in the current time period can be determined from the queried primary key in real time and accurately, solving the problem of being unable to perform statistics on the queried primary key that does not exist in the database.

[0061] Based on any of the above embodiments, a time period may correspond to multiple real-time hotspot primary key sets, and the number of primary keys that can be stored in each real-time hotspot primary key set does not exceed the preset primary key number threshold. Parallel processing can be achieved by dividing multiple real-time hotspot primary key sets. In particular, when determining whether the target primary key exists in the real-time hotspot primary key set corresponding to the current time period, it is possible to query in parallel from the multiple real-time hotspot primary key sets corresponding to the current time period whether the target primary key exists, thereby improving the query efficiency. In addition, after the current time period ends, the multiple real-time hotspot primary key sets corresponding to the current time period can also be sorted in parallel, and then summarized and sorted, thereby improving the sorting efficiency, and thus the hotspot primary key of the current time period can be quickly determined.

[0062] Based on the above embodiment, in S202 and S2023, when adding the target primary key to the real-time hotspot primary key set, the following steps may be specifically included:

[0063] Determine whether the number of primary keys included in the first real-time hotspot primary key set corresponding to the current time period reaches a preset primary key number threshold;

[0064] If the preset primary key quantity threshold is not reached, the target primary key is added to the first real-time hot spot primary key set; or

[0065] If the preset primary key quantity threshold is reached, a second real-time hotspot primary key set corresponding to a new current time period is created, and the target primary key is added to the second real-time hotspot primary key set.

[0066] In this embodiment, since the number of primary keys that can be stored in each real-time hotspot primary key set does not exceed the preset primary key number threshold, when the target primary key is added to the first real-time hotspot primary key set corresponding to the current time period, it can be determined whether the number of primary keys included in the first real-time hotspot primary key set reaches the preset primary key number threshold. If the number of primary keys included in the first real-time hotspot primary key set does not reach the preset primary key number threshold, it means that the first real-time hotspot primary key set is not full and can continue to store the target primary key, and then the target primary key can be added to the first real-time hotspot primary key set; if the number of primary keys included in the first real-time hotspot primary key set has reached the preset primary key number threshold, it means that the first real-time hotspot primary key set is full and cannot continue to store the target primary key, and it is necessary to create a second real-time hotspot primary key set corresponding to the current time period, and add the target primary key to the second real-time hotspot primary key set.

[0067] On the basis of the above embodiment, after the current time period ends in S204, determining the hotspot primary key of the current time period according to the real-time hotspot primary key set may specifically include:

[0068] After the current time period ends, all real-time hotspot primary key sets within the current time period are merged, and the hotspot primary key of the current time period is determined according to the merged real-time hotspot primary key sets.

[0069] In this embodiment, since one time period can correspond to multiple real-time hotspot primary key sets, when determining the hotspot primary key of the current time period, all real-time hotspot primary key sets corresponding to the current time period can be merged to obtain a collection, and then the merged real-time hotspot primary key sets are sorted based on the query frequency of the current time period to determine the hotspot primary key of the current time period.

[0070] Real-time hotspot primary key set Real-time hotspot primary key set Real-time hotspot primary key set Based on any of the above embodiments, when outputting the query frequency of the hotspot primary key in the current time period in the current time period, the query frequency of the hotspot primary key in the current time period can be stored in a preset queue, such as Figure 3 As shown, the preset queue can be used to store the query frequency of the hotspot primary keys in the corresponding time period of the past second preset number of time periods. For example, the query frequency of the hotspot primary keys in the corresponding time period of the past n time periods can be stored, and the query frequency of the hotspot primary keys in the corresponding time period of the earliest time period can be continuously eliminated.

[0071] Therefore, in this embodiment, when storing the hotspot primary key of the current time period in the query frequency of the current time period in a preset queue, it can be determined first whether the preset queue is full. If the preset queue is not full, the hotspot primary key of the current time period in the query frequency of the current time period is stored in the preset queue; if the preset queue is full, the hotspot primary key of the earliest time period in the preset queue is deleted at the query frequency of the corresponding time period, and the hotspot primary key of the current time period is stored in the preset queue in the query frequency of the current time period.

[0072] In another optional embodiment, when the hotspot primary key of any target time period in the preset queue is read at the query frequency of the corresponding time period, it can also be deleted, that is, in response to a read request for the query frequency of the hotspot primary key of any target time period in the preset queue at the corresponding time period, the query frequency of the hotspot primary key of the target time period at the corresponding time period is output, and the query frequency of the hotspot primary key of the target time period at the corresponding time period is deleted from the preset queue.

[0073] Based on any of the above embodiments, Figure 4 As shown, this embodiment provides a method for detecting hotspot data in a database, which specifically includes:

[0074] S401, receiving a database query instruction;

[0075] S402, determining whether the target primary key of the data to be queried exists in the real-time hotspot primary key set corresponding to the current time period;

[0076] If it is determined that the target primary key does not exist in the real-time hotspot primary key set, S403 is executed; if it is determined that the target primary key exists in the real-time hotspot primary key set, S403 is executed.

[0077] S403, determining whether the target primary key is stored in the target cache;

[0078] The target cache is a cache based on the least recently used algorithm; if the target primary key is not stored in the target cache, S404 is executed; if the target primary key is stored in the target cache, S405 is executed;

[0079] S404, adding the target primary key to the target cache based on the least recently used algorithm;

[0080] S405, removing the target primary key from the target cache and adding it to the real-time hotspot primary key set;

[0081] S406: Accumulate the query frequency of the target primary key in the current time period in the real-time hot spot primary key set.

[0082] Further, after the current time period ends, the hotspot primary key of the current time period is determined according to the real-time hotspot primary key set, and the query frequency of the hotspot primary key of the current time period in the current time period is output (not in Figure 4 ).

[0083] Corresponding to the hotspot data detection method of the database in the above embodiment, Figure 5 This is a block diagram of a hotspot data detection device for a database provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 5 The database hotspot data detection device 500 includes: a judgment unit 501, a cache unit 502, and a recording unit 503.

[0084] The judgment unit 501 is used to receive a database query instruction and judge whether the target primary key of the data to be queried exists in the real-time hot spot primary key set corresponding to the current time period;

[0085] A cache unit 502, configured to control whether to add the target primary key to the real-time hotspot primary key set through a target cache if the target primary key does not exist in the real-time hotspot primary key set; wherein the target cache is a cache based on a least recently used algorithm;

[0086] The recording unit 503 is configured to accumulate the query frequency of the target primary key in the current time period in the real-time hotspot primary key set if the target primary key exists in the real-time hotspot primary key set;

[0087] The statistical unit is used to determine the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, and output the query frequency of the hotspot primary key of the current time period in the current time period.

[0088] In one or more embodiments of the present disclosure, when the cache unit 502 controls whether to add the target primary key to the real-time hot spot primary key set through the target cache, it is used to:

[0089] Determining whether the target primary key is stored in the target cache;

[0090] If the target primary key is not stored in the target cache, adding the target primary key to the target cache based on a least recently used algorithm; or

[0091] If the target primary key is stored in the target cache, the target primary key is removed from the target cache and added to the real-time hot spot primary key set.

[0092] In one or more embodiments of the present disclosure, the cache unit 502 is further configured to:

[0093] The number of primary keys that the target cache is allowed to store is determined according to the total number of queries allowed by the database in a single time period and a preset single time period query frequency threshold, and the storage space of the target cache is configured based on the number of primary keys allowed to be stored.

[0094] In one or more embodiments of the present disclosure, when adding the target primary key to the real-time hotspot primary key set, the recording unit 503 is used to:

[0095] Determine whether the number of primary keys included in the first real-time hotspot primary key set corresponding to the current time period reaches a preset primary key number threshold;

[0096] If the preset primary key quantity threshold is not reached, the target primary key is added to the first real-time hot spot primary key set; or

[0097] If the preset primary key quantity threshold is reached, a second real-time hotspot primary key set corresponding to the current time period is created, and the target primary key is added to the second real-time hotspot primary key set.

[0098] In one or more embodiments of the present disclosure, when the statistical unit determines the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, it is used to:

[0099] After the current time period ends, all real-time hotspot primary key sets within the current time period are merged, and the hotspot primary key of the current time period is determined according to the merged real-time hotspot primary key sets.

[0100] In one or more embodiments of the present disclosure, when the statistical unit determines the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, it is used to:

[0101] The primary keys included in the real-time hotspot primary key set are sorted according to the query frequency of the current time period, and a first preset number of primary keys with the highest query frequency in the current time period are determined as the hotspot primary keys of the current time period.

[0102] In one or more embodiments of the present disclosure, when the statistical unit sorts the primary keys included in the real-time hot spot primary key set according to the query frequency in the current time period, it is used to:

[0103] The primary keys in the real-time hotspot primary key set whose query frequency in the current time period is lower than the preset single time period query frequency threshold are screened out, and the remaining primary keys in the real-time hotspot primary key set are sorted according to the query frequency in the current time period.

[0104] In one or more embodiments of the present disclosure, when the statistical unit outputs the query frequency of the hotspot primary key in the current time period in the current time period, it is used to:

[0105] Determine whether the preset queue is full; wherein the preset queue is used to store the query frequency of the hotspot primary key in the corresponding time period in the past second preset number of time periods;

[0106] If the preset queue is not full, the query frequency of the hotspot primary key in the current time period is stored in the preset queue; or

[0107] If the preset queue is full, the hotspot primary key of the earliest time period in the preset queue is deleted from the query frequency of the corresponding time period, and the hotspot primary key of the current time period is stored in the preset queue from the query frequency of the current time period.

[0108] In one or more embodiments of the present disclosure, the statistical unit is further configured to:

[0109] In response to a read request for the query frequency of the hotspot primary key of any target time period in the preset queue in the corresponding time period, the query frequency of the hotspot primary key of the target time period in the corresponding time period is output, and the query frequency of the hotspot primary key of the target time period in the corresponding time period is deleted from the preset queue.

[0110] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.

[0111] refer to Figure 6 , which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure, and the electronic device 600 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0112] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0113] Typically, the following devices may be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 608 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0114] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0115] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0116] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0117] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0118] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0119] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0120] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".

[0121] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0122] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0123] In a first aspect, according to one or more embodiments of the present disclosure, a method for detecting hotspot data in a database is provided, comprising:

[0124] Receive a database query instruction and determine whether the target primary key of the data to be queried exists in the real-time hot spot primary key set corresponding to the current time period;

[0125] If the target primary key does not exist in the real-time hotspot primary key set, whether to add the target primary key to the real-time hotspot primary key set is controlled by the target cache; wherein the target cache is a cache based on a least recently used algorithm;

[0126] If the target primary key exists in the real-time hotspot primary key set, then the query frequency of the target primary key in the current time period is accumulated in the real-time hotspot primary key set;

[0127] After the current time period ends, the hotspot primary key of the current time period is determined according to the real-time hotspot primary key set, and the query frequency of the hotspot primary key of the current time period in the current time period is output.

[0128] According to one or more embodiments of the present disclosure, controlling whether to add the target primary key to the real-time hotspot primary key set through the target cache includes:

[0129] Determining whether the target primary key is stored in the target cache;

[0130] If the target primary key is not stored in the target cache, adding the target primary key to the target cache based on a least recently used algorithm; or

[0131] If the target primary key is stored in the target cache, the target primary key is removed from the target cache and added to the real-time hot spot primary key set.

[0132] According to one or more embodiments of the present disclosure, the method further includes:

[0133] The number of primary keys that the target cache is allowed to store is determined according to the total number of queries allowed by the database in a single time period and a preset single time period query frequency threshold, and the storage space of the target cache is configured based on the number of primary keys allowed to be stored.

[0134] According to one or more embodiments of the present disclosure, adding the target primary key to the real-time hotspot primary key set includes:

[0135] Determine whether the number of primary keys included in the first real-time hotspot primary key set corresponding to the current time period reaches a preset primary key number threshold;

[0136] If the preset primary key quantity threshold is not reached, the target primary key is added to the first real-time hot spot primary key set; or

[0137] If the preset primary key quantity threshold is reached, a second real-time hotspot primary key set corresponding to the current time period is created, and the target primary key is added to the second real-time hotspot primary key set.

[0138] According to one or more embodiments of the present disclosure, after the current time period ends, determining the hotspot primary key of the current time period according to the real-time hotspot primary key set includes:

[0139] After the current time period ends, all real-time hotspot primary key sets within the current time period are merged, and the hotspot primary key of the current time period is determined according to the merged real-time hotspot primary key sets.

[0140] According to one or more embodiments of the present disclosure, after the current time period ends, determining the hotspot primary key of the current time period according to the real-time hotspot primary key set includes:

[0141] The primary keys included in the real-time hotspot primary key set are sorted according to the query frequency of the current time period, and a first preset number of primary keys with the highest query frequency in the current time period are determined as the hotspot primary keys of the current time period.

[0142] According to one or more embodiments of the present disclosure, the step of sorting the primary keys included in the real-time hotspot primary key set according to the query frequency in the current time period includes:

[0143] The primary keys in the real-time hotspot primary key set whose query frequency in the current time period is lower than the preset single time period query frequency threshold are screened out, and the remaining primary keys in the real-time hotspot primary key set are sorted according to the query frequency in the current time period.

[0144] According to one or more embodiments of the present disclosure, the outputting the query frequency of the hotspot primary key in the current time period in the current time period includes:

[0145] Determine whether the preset queue is full; wherein the preset queue is used to store the query frequency of the hotspot primary key in the corresponding time period in the past second preset number of time periods;

[0146] If the preset queue is not full, the query frequency of the hotspot primary key in the current time period is stored in the preset queue; or

[0147] If the preset queue is full, the hotspot primary key of the earliest time period in the preset queue is deleted from the query frequency of the corresponding time period, and the hotspot primary key of the current time period is stored in the preset queue from the query frequency of the current time period.

[0148] According to one or more embodiments of the present disclosure, the method further includes:

[0149] In response to a read request for the query frequency of the hotspot primary key of any target time period in the preset queue in the corresponding time period, the query frequency of the hotspot primary key of the target time period in the corresponding time period is output, and the query frequency of the hotspot primary key of the target time period in the corresponding time period is deleted from the preset queue.

[0150] In a second aspect, according to one or more embodiments of the present disclosure, a hotspot data detection device for a database is provided, comprising:

[0151] A judgment unit, used to receive a database query instruction and judge whether a target primary key of the data to be queried exists in a real-time hot spot primary key set corresponding to a current time period;

[0152] A cache unit, used for controlling whether to add the target primary key to the real-time hotspot primary key set through a target cache if the target primary key does not exist in the real-time hotspot primary key set; wherein the target cache is a cache based on a least recently used algorithm;

[0153] A recording unit, configured to accumulate the query frequency of the target primary key in the current time period in the real-time hotspot primary key set if the target primary key exists in the real-time hotspot primary key set;

[0154] The statistical unit is used to determine the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, and output the query frequency of the hotspot primary key of the current time period in the current time period.

[0155] According to one or more embodiments of the present disclosure, when the cache unit controls whether to add the target primary key to the real-time hot spot primary key set through the target cache, it is used to:

[0156] Determining whether the target primary key is stored in the target cache;

[0157] If the target primary key is not stored in the target cache, adding the target primary key to the target cache based on a least recently used algorithm; or

[0158] If the target primary key is stored in the target cache, the target primary key is removed from the target cache and added to the real-time hot spot primary key set.

[0159] According to one or more embodiments of the present disclosure, the cache unit is further configured to:

[0160] The number of primary keys that the target cache is allowed to store is determined according to the total number of queries allowed by the database in a single time period and a preset single time period query frequency threshold, and the storage space of the target cache is configured based on the number of primary keys allowed to be stored.

[0161] According to one or more embodiments of the present disclosure, when adding the target primary key to the real-time hotspot primary key set, the recording unit is used to:

[0162] Determine whether the number of primary keys included in the first real-time hotspot primary key set corresponding to the current time period reaches a preset primary key number threshold;

[0163] If the preset primary key quantity threshold is not reached, the target primary key is added to the first real-time hot spot primary key set; or

[0164] If the preset primary key quantity threshold is reached, a second real-time hotspot primary key set corresponding to the current time period is created, and the target primary key is added to the second real-time hotspot primary key set.

[0165] According to one or more embodiments of the present disclosure, when the statistical unit determines the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, it is used to:

[0166] After the current time period ends, all real-time hotspot primary key sets within the current time period are merged, and the hotspot primary key of the current time period is determined according to the merged real-time hotspot primary key sets.

[0167] According to one or more embodiments of the present disclosure, when the statistical unit determines the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, it is used to:

[0168] The primary keys included in the real-time hotspot primary key set are sorted according to the query frequency of the current time period, and a first preset number of primary keys with the highest query frequency in the current time period are determined as the hotspot primary keys of the current time period.

[0169] According to one or more embodiments of the present disclosure, when the statistical unit sorts the primary keys included in the real-time hot spot primary key set according to the query frequency in the current time period, it is used to:

[0170] The primary keys in the real-time hotspot primary key set whose query frequency in the current time period is lower than the preset single time period query frequency threshold are screened out, and the remaining primary keys in the real-time hotspot primary key set are sorted according to the query frequency in the current time period.

[0171] According to one or more embodiments of the present disclosure, when the statistical unit outputs the query frequency of the hotspot primary key in the current time period in the current time period, it is used to:

[0172] Determine whether the preset queue is full; wherein the preset queue is used to store the query frequency of the hotspot primary key in the corresponding time period in the past second preset number of time periods;

[0173] If the preset queue is not full, the query frequency of the hotspot primary key in the current time period is stored in the preset queue; or

[0174] If the preset queue is full, the hotspot primary key of the earliest time period in the preset queue is deleted from the query frequency of the corresponding time period, and the hotspot primary key of the current time period is stored in the preset queue from the query frequency of the current time period.

[0175] According to one or more embodiments of the present disclosure, the statistical unit is further configured to:

[0176] In response to a read request for the query frequency of the hotspot primary key of any target time period in the preset queue in the corresponding time period, the query frequency of the hotspot primary key of the target time period in the corresponding time period is output, and the query frequency of the hotspot primary key of the target time period in the corresponding time period is deleted from the preset queue.

[0177] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;

[0178] The memory stores computer-executable instructions;

[0179] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the hotspot data detection method of the database as described in the first aspect and various possible designs of the first aspect.

[0180] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, the hotspot data detection method of the database as described in the first aspect and various possible designs of the first aspect is implemented.

[0181] In a fifth aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, comprising computer execution instructions. When a processor executes the computer execution instructions, the hotspot data detection method of the database as described in the first aspect and various possible designs of the first aspect is implemented.

[0182] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0183] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0184] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for detecting hotspot data in a database, characterized in that: include: Receive a database query instruction and determine whether the target primary key of the data to be queried exists in the real-time hot spot primary key set corresponding to the current time period; If the target primary key does not exist in the real-time hotspot primary key set, whether to add the target primary key to the real-time hotspot primary key set is controlled by the target cache; The target cache is a cache based on a least recently used algorithm; If the target primary key exists in the real-time hotspot primary key set, then the query frequency of the target primary key in the current time period is accumulated in the real-time hotspot primary key set; After the current time period ends, the hotspot primary key of the current time period is determined according to the real-time hotspot primary key set, and the query frequency of the hotspot primary key of the current time period in the current time period is output.

2. The method according to claim 1, characterized in that The controlling whether to add the target primary key to the real-time hotspot primary key set through the target cache includes: Determining whether the target primary key is stored in the target cache; If the target primary key is not stored in the target cache, adding the target primary key to the target cache based on a least recently used algorithm; or If the target primary key is stored in the target cache, the target primary key is removed from the target cache and added to the real-time hot spot primary key set.

3. The method according to claim 1 or 2, characterized in that: The method further comprises: The number of primary keys that the target cache is allowed to store is determined according to the total number of queries allowed by the database in a single time period and a preset single time period query frequency threshold, and the storage space of the target cache is configured based on the number of primary keys allowed to be stored.

4. The method according to claim 1 or 2, characterized in that: Adding the target primary key to the real-time hotspot primary key set includes: Determine whether the number of primary keys included in the first real-time hotspot primary key set corresponding to the current time period reaches a preset primary key number threshold; If the preset primary key quantity threshold is not reached, the target primary key is added to the first real-time hot spot primary key set; or If the preset primary key quantity threshold is reached, a second real-time hotspot primary key set corresponding to the current time period is created, and the target primary key is added to the second real-time hotspot primary key set.

5. The method according to claim 4, characterized in that After the current time period ends, determining the hotspot primary key of the current time period according to the real-time hotspot primary key set includes: After the current time period ends, all real-time hotspot primary key sets within the current time period are merged, and the hotspot primary key of the current time period is determined according to the merged real-time hotspot primary key sets.

6. The method according to claim 1, characterized in that After the current time period ends, determining the hotspot primary key of the current time period according to the real-time hotspot primary key set includes: The primary keys included in the real-time hotspot primary key set are sorted according to the query frequency of the current time period, and a first preset number of primary keys with the highest query frequency in the current time period are determined as the hotspot primary keys of the current time period.

7. The method according to claim 6, characterized in that The step of sorting the primary keys included in the real-time hotspot primary key set according to the query frequency in the current time period includes: The primary keys in the real-time hotspot primary key set whose query frequency in the current time period is lower than the preset single time period query frequency threshold are screened out, and the remaining primary keys in the real-time hotspot primary key set are sorted according to the query frequency in the current time period.

8. The method according to claim 1, characterized in that The output of the query frequency of the hotspot primary key in the current time period in the current time period includes: Determine whether the preset queue is full; wherein the preset queue is used to store the query frequency of the hotspot primary key in the corresponding time period in the past second preset number of time periods; If the preset queue is not full, the query frequency of the hotspot primary key in the current time period is stored in the preset queue; or If the preset queue is full, the hotspot primary key of the earliest time period in the preset queue is deleted from the query frequency of the corresponding time period, and the hotspot primary key of the current time period is stored in the preset queue from the query frequency of the current time period.

9. The method according to claim 8, characterized in that The method further comprises: In response to a read request for the query frequency of the hotspot primary key of any target time period in the preset queue in the corresponding time period, the query frequency of the hotspot primary key of the target time period in the corresponding time period is output, and the query frequency of the hotspot primary key of the target time period in the corresponding time period is deleted from the preset queue.

10. A hotspot data detection device for a database, characterized in that: include: A judgment unit, used to receive a database query instruction and judge whether a target primary key of the data to be queried exists in a real-time hot spot primary key set corresponding to a current time period; A cache unit, used for controlling whether to add the target primary key to the real-time hotspot primary key set through the target cache if the target primary key does not exist in the real-time hotspot primary key set; The target cache is a cache based on a least recently used algorithm; A recording unit, configured to accumulate the query frequency of the target primary key in the current time period in the real-time hotspot primary key set if the target primary key exists in the real-time hotspot primary key set; The statistical unit is used to determine the hotspot primary key of the current time period according to the real-time hotspot primary key set after the current time period ends, and output the query frequency of the hotspot primary key of the current time period in the current time period.

11. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method according to any one of claims 1 to 9 is implemented.

13. A computer program product, characterized in that The method comprises computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Keyword processing method, apparatus and system in distributed storage system

    CN107786595A

  • Cache elimination method and system

    CN113268440A

  • Hotspot identification method and current limiting method

    CN114756544A

  • Database caching in a database system

    US20170185645A1

  • Hotspot recognition method and rate limiting method

    WO2023179414A1