Hot data detection method, device and storage medium for database

By receiving database query instructions, judging the existence of the target primary key and using the LRU cache algorithm, the hot spot primary key collection is updated in real time, solving the problem of inaccurate QPS statistics in the database, realizing real-time and accurate identification of hot spot primary keys and query frequency statistics, reducing system load.

CN119226331BActive Publication Date: 2025-07-25BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411367703.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2025-07-25
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 primary keys that do not exist or are deleted in the database, resulting in the QPS decay period of the hotspot primary keys being too long and the hotspot primary keys cannot be accurately identified in real time.

Method used

By receiving database query instructions, we can determine whether the target primary key exists in the real-time hotspot primary key collection, use the cache control primary key to join or remove based on the least recently used algorithm, accumulate query frequency, update the hotspot primary key collection in real time, and output the query frequency of the current time period.

Benefits of technology

Real-time accurate statistics of hotspot primary keys in the database are realized, which reduces system load, improves query efficiency, and avoids the problem of excessive QPS attenuation period.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226331B_ABST
    Figure CN119226331B_ABST
Patent Text Reader

Abstract

An embodiment of the present disclosure provides a method, device, and storage medium for detecting hot data in a database. The method for detecting hot data in a database includes receiving a database query instruction, and determining whether a target primary key of data to be queried exists in a real-time hot primary key set of the current time period; if the target primary key does not exist in the real-time hot primary key set, controlling whether to add the target primary key to the real-time hot primary key set through a target cache, where the target cache is a cache based on the least recently used algorithm; if the target primary key exists in the real-time hot primary key set, accumulating the query frequency of the target primary key in the current time period in the real-time hot primary key set; determining the hot primary keys of the current time period according to the real-time hot primary key set after the end of the current time period, and outputting the query frequency of the hot primary keys in the current time period. The present disclosure can accurately determine hot primary keys and their query frequencies in the current time period from the queried primary keys in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In some real-time applications of databases, it is usually necessary to count the queries per second (QPS) of the hot primary keys being queried, so as to optimize the system load.

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

[0004] Embodiments of the present disclosure provide a method, device, and storage medium for detecting hot data in a database, so as to accurately and real-time count the hot primary keys in the database and their query frequencies in the current time period.

[0005] In a first aspect, embodiments of the present disclosure provide a method for detecting hot data in a database, including:

[0006] Receiving a database query instruction, and determining 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;

[0007] If the target primary key does not exist in the real-time hot primary key set, controlling whether to add the target primary key to the real-time hot primary key set through a target cache; where the target cache is a cache based on the least recently used algorithm;

[0008] If the target primary key exists in the real-time hot primary key set, accumulating the query frequency of the target primary key in the current time period in the real-time hot primary key set;

[0009] After the current time period ends, determining the hot primary keys in the current time period according to the real-time hot primary key set, and outputting the query frequency of the hot primary keys in the current time period in the current time period.

[0010] In a second aspect, embodiments of the present disclosure provide a device for detecting hot data in a database, including:

[0011] A judgment unit, configured to receive a database query instruction, and 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;

[0012] A cache unit, configured to control whether to add the target primary key to the real-time hot primary key set through a target cache if the target primary key does not exist in the real-time hot primary key set; wherein the target cache is a cache based on the 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 hot primary key set if the target primary key exists in the real-time hot primary key set;

[0014] A statistical unit, configured to determine the hot primary keys in the current time period according to the real-time hot primary key set after the end of the current time period, and output the query frequency of the hot primary keys in 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 hot data detection method of the database as described in the first aspect and various possible designs of the first aspect above.

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

[0019] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including computer-executable instructions. When a processor executes the computer-executable instructions, the hot data detection method of the database as described in the first aspect and various possible designs of the first aspect above is implemented.

[0020] The hot data detection method, device, and storage medium for a database provided by an embodiment of the present disclosure. The hot data detection method for the database 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 by receiving a database query instruction. If the target primary key does not exist in the real-time hot primary key set, it controls whether to add the target primary key to the real-time hot primary key set through the target cache, where 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, it accumulates the query frequency of the target primary key in the current time period in the real-time hot primary key set. After the current time period ends, it determines the hot primary keys of the current time period based on the real-time hot primary key set and outputs the query frequency of the hot primary keys of the current time period in the current time period. By leveraging the cache based on the least recently used algorithm, it can effectively filter out low-frequency primary keys, reduce the data scale, thereby reducing the system load, and can accurately and real-time determine the hot primary keys and their query frequency in the current time period from the queried primary keys, solving the problem of being unable to count the queried primary keys that do not exist in the database. Brief Description of the Drawings

[0021] To more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following-described drawings are some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1 It is a schematic diagram of the scenario of the hot data detection method for a database provided by an embodiment of the present disclosure;

[0023] Figure 2 It is a schematic flowchart of the hot data detection method for a database provided by an embodiment of the present disclosure;

[0024] Figure 3 It is a schematic diagram of a preset queue provided by an embodiment of the present disclosure;

[0025] Figure 4 It is a schematic flowchart of the hot data detection method for a database provided by another embodiment of the present disclosure;

[0026] Figure 5 It is a structural block diagram of the hot data detection device for a database provided by an embodiment of the present disclosure;

[0027] Figure 6 It is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present disclosure. Detailed Embodiments

[0028] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.

[0029] In some real-time applications of databases, it is usually necessary to count the query per second (QPS) of the hot primary keys being queried, so as to optimize the system load. For example, in the Redis database, Redis is an open-source in-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, reduce database load, and support multiple data structures such as strings, lists, sets, etc., to meet the needs of different users. In the real-time application of the Redis database, it is also necessary to count the QPS of the hot primary keys being queried.

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

[0031] Although some cloud providers provide statistics on hot primary keys and their QPS, they usually count based on value-objects and can only give QPS range values. Usually, the query times of each primary key are accumulated, and the ratio of the query times to the time is calculated as the QPS value. This will result in the QPS of the hot primary keys not being real-time and not truly reflecting the query times of the primary keys per second. At the same time, due to the ratio statistics based on the time period, the QPS decay period of the hot primary keys is too long; in addition, it is also impossible to count the primary keys being queried that do not exist in the database.

[0032] To solve the above technical problems, the embodiments of the present disclosure provide a method for detecting hot data in a database. Instead of counting based on value-objects, it directly counts the primary keys of the data to be queried in the database query instructions. 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 a cache based on the least recently used algorithm and time-sharing statistics, low-frequency primary keys can be effectively filtered, the data scale can be reduced, thereby reducing the system load, and the hot primary keys and their query frequencies in the current time period can be determined accurately and real-time from the primary keys being queried, improving the real-time performance and accuracy, and avoiding the problem of too long QPS decay period of the hot primary keys.

[0033] The application scenario of the hot data detection method for the database in the embodiments of the present disclosure is as follows Figure 1 As shown, it can be applied to electronic devices such as database servers. Specifically, it can receive a database query instruction and 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, it controls whether to add the target primary key to the real-time hot primary key set through the target cache, where 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, it accumulates the query frequency of the target primary key in the current time period in the real-time hot primary key set; after the end of the current time period, it determines the hot primary keys of the current time period according to the real-time hot primary key set and outputs the query frequency of the hot primary keys of the current time period in the current time period.

[0034] The following will introduce the hot data detection method for the database of the present disclosure in detail in combination with specific embodiments.

[0035] Refer to Figure 2 , Figure 2 which is a schematic flowchart of the hot data detection method for the database provided by an embodiment of the present disclosure. The method of this embodiment can be applied to a terminal device or a server. The hot data detection method for the database includes:

[0036] S201. Receive a database query instruction and 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.

[0037] In this embodiment, when receiving a database query instruction, the target primary key (key) of the data to be queried can be determined from the database query instruction, where the database query instruction may include the target primary key of the data to be queried.

[0038] For each time period, a real-time hot primary key set can be configured. The real-time hot primary key set can be used to store the candidate hot primary keys within the corresponding time period. The candidate hot primary keys are the primary keys that are frequently queried, and their addition to the real-time hot primary key set needs to meet certain conditions, 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 hot primary key set, and second-level hot primary key statistics can be realized; of course, the time period is not limited to 1 second and can also be other preset durations.

[0040] In this embodiment, after receiving a database query instruction, real-time judgment can be performed based on the set of real-time hot primary keys corresponding to the current time period to determine whether the target primary key of the data to be queried exists in the set of real-time hot primary keys 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 can be performed according to the judgment result. Specifically, if it is determined that the target primary key does not exist in the set of real-time hot primary keys, then S202 is executed; if it is determined that the target primary key exists in the set of real-time hot primary keys, then S203 is executed.

[0042] S202. If the target primary key does not exist in the set of real-time hot primary keys, then the target cache is used to control whether to add the target primary key to the set of real-time hot primary keys, where the target cache is a cache based on the least recently used algorithm.

[0043] In this embodiment, a target cache based on the least recently used (LRU) algorithm, that is, an LRU Cache, is preconfigured, which can be used to filter out some primary keys with low query frequencies. The least recently used algorithm is to eliminate the least recently used cached 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 those that do not exist in the set of real-time hot primary keys and have been recently queried. Based on the least recently used algorithm, primary keys that have not been recently frequently queried can be filtered out, and then primary keys that do not exist in the set of real-time hot primary keys and have been recently frequently queried can be added to the set of real-time hot primary keys.

[0045] Optionally, S202 may specifically include:

[0046] S2021. Determine whether the target primary key is stored in the target cache;

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

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

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

[0050] In this embodiment, since the storage space of the target cache based on the least recently used (LRU) algorithm is limited, that is, the number of primary keys that can be cached is limited. For a target primary key that does not exist in the real-time hot primary key set, if the target primary key is not stored in the target cache, it may indicate two situations. One situation is that the target primary key has never been queried before and this is the first query. The other situation is that the target primary key has been queried before and was once stored in the target cache, but the query frequency is not high and it was eliminated and cleared from the target cache based on the LRU 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 LRU algorithm. It should be noted that in this embodiment, the target cache based on the LRU algorithm may not record the number of queries. That is, adding the target primary key to the target cache based on the LRU algorithm specifically means that 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 primary key that was queried earliest in the target cache is eliminated, without paying attention to the number of queries. And as long as the target primary key is already stored in the target cache, it indicates that the time interval between this query of the target primary key and the last query may be relatively short, or the number of queries for other primary keys between this query and the last query of the target primary key is relatively small, and the target primary key stored in the target cache has not been eliminated by other primary keys. Thus, it can be shown that the query frequency of the target primary key is relatively high. The target primary key can be added to the real-time hot primary key set, and the target primary key is removed from the target cache. Subsequently, only the query situation of the target primary key needs to be monitored through the real-time hot primary key set, without occupying the storage space of the target cache anymore.

[0051] Optionally, the size of the storage space of the target cache based on the LRU algorithm can determine the size of the query frequency of the primary keys that can be added to the real-time hot primary key set. Therefore, the size of the storage space of the target cache can be determined according to the total number of queries allowed by the database in a single time period and the preset query frequency threshold for a single time period, that is, the number of primary keys that the target cache is allowed to store is determined. Furthermore, the storage space of the target cache is 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 times, and the preset query frequency threshold for a single time period is 3,000 times, that is, querying 3,000 times per second is considered a hot primary key. Then, if a certain primary key is a hot primary key, it will be queried 1 time in every 100,000 / 3,000 ≈ 33 queries on average. Therefore, the number of primary keys that the target cache is allowed to store is 32. If a target primary key has been stored in the target cache, and if the target primary key is not a hot primary key, it is very likely that it will not be queried again in the subsequent 32 queries, and it will be eliminated from the target cache based on the least recently used algorithm. If the target primary key is a hot primary key, it is very likely that it will be queried again in the subsequent 32 queries, and when the target primary key is queried again, the target primary keys already stored in the target cache have not been eliminated, so it can be added to the real-time hot primary key set. By setting the number of primary keys that the target cache is allowed to store according to the ratio of the total number of queries allowed by the database in a single time period to the preset query frequency threshold for a single time period as described above, a preliminary screening of hot primary keys can be achieved, and at the same time, primary keys with low query frequencies can also be filtered out.

[0053] S203. If the target primary key exists in the real-time hot primary key set, then accumulate the query frequency of the target primary key in the current time period in the real-time hot primary key set.

[0054] In this embodiment, 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 can be directly accumulated in the real-time hot primary key set. Specifically, when the target primary key is first added to the real-time hot 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 incremented by 1 each time. 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 length of the time period is 1 second, the query frequency of the target primary key in the current time period is also the queries-per-second (QPS) of the target primary key in the current 1 second.

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

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

[0057] Optionally, all candidate hot primary keys in the real-time hot primary key set can be sorted based on the 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 are determined as the hot primary keys in the current time period. For example, if the first preset number is k, then the Topk primary keys with the query frequency in the current time period in the real-time hot primary key set are determined as the hot primary keys in the current time period.

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

[0059] Optionally, the process of S204 has relatively low real-time requirements compared to the foregoing steps. The real-time hot primary key set corresponding to the current time period can be output, and the real-time hot primary key set corresponding to the current time period is processed asynchronously to determine the hot primary keys in the current time period and output the query frequency of the hot primary keys in the current time period in the current time period, which can reduce the performance impact on the main thread.

[0060] The hot data detection method for the database provided in this embodiment 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 by receiving a database query instruction; if the target primary key does not exist in the real-time hot primary key set, it is determined whether to add the target primary key to the real-time hot primary key set through the target cache, where 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 current time period ends, the hot primary keys in the current time period are determined according to the real-time hot primary key set, and the query frequency of the hot primary keys in the current time period in the current time period is output. By means of 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 keys and their query frequency in the current time period can be accurately determined in real time from the queried primary keys, solving the problem that the queried primary keys that do not exist in the database cannot be counted.

[0061] Based on any of the above embodiments, one time period may correspond to multiple real-time hot primary key sets, and the number of primary keys that each real-time hot primary key set can store does not exceed a preset primary key quantity threshold. By dividing into multiple real-time hot primary key sets, parallel processing can be achieved. In particular, when determining whether a target primary key exists in the real-time hot primary key set corresponding to the current time period, it is possible to query in parallel from multiple real-time hot primary key sets corresponding to the current time period whether the target primary key exists, which can improve the query efficiency. In addition, after the current time period ends, it is also possible to sort the multiple real-time hot primary key sets corresponding to the current time period in parallel, and finally summarize the sorting, which can improve the sorting efficiency, and thus can quickly determine the hot primary keys of the current time period.

[0062] Based on the above embodiments, in S202 and S2023, when adding the target primary key to the real-time hot primary key set, it may specifically include:

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

[0064] If it does not reach the preset primary key quantity threshold, add the target primary key to the first real-time hot primary key set; or

[0065] If it has reached the preset primary key quantity threshold, create a second real-time hot primary key set corresponding to the new current time period, and add the target primary key to the second real-time hot primary key set.

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

[0067] Based on the above embodiments, after the current time period ends in S204, when determining the hot primary keys of the current time period according to the real-time hot primary key set, it may specifically include:

[0068] After the end of the current time period, merge all the real-time hot key sets within the current time period, and determine the hot keys of the current time period based on the merged real-time hot key sets.

[0069] In this embodiment, since one time period can correspond to multiple real-time hot key sets, when determining the hot keys of the current time period, all the real-time hot key sets corresponding to the current time period can be merged to obtain a combined set. Then, sort the merged real-time hot key sets based on the query frequency within the current time period to determine the hot keys of the current time period.

[0070] Based on any of the above embodiments, when outputting the query frequency of the hot keys of the current time period within the current time period, the query frequency of the hot keys of the current time period within the current time period can be stored in a preset queue, such as Figure 3 shown. The preset queue can be used to store the query frequencies of the hot keys of the second preset number of past time periods in the corresponding time periods. For example, it can store the query frequencies of the hot keys of the past n time periods in the corresponding time periods, and continuously eliminate the query frequency of the hot keys of the earliest time period in the corresponding time period.

[0071] Therefore, in this embodiment, when storing the query frequency of the hot keys of the current time period within the current time period in a preset queue, first determine whether the preset queue is full. If the preset queue is not full, store the query frequency of the hot keys of the current time period within the current time period in the preset queue; if the preset queue is full, delete the query frequency of the hot keys of the earliest time period in the preset queue in the corresponding time period, and store the query frequency of the hot keys of the current time period within the current time period in the preset queue.

[0072] In another alternative embodiment, when the query frequency of the hot keys of any target time period in the preset queue is read, it can also be deleted, that is, in response to the read request for the query frequency of the hot keys of any target time period in the preset queue, output the query frequency of the hot keys of the target time period in the corresponding time period, and delete the query frequency of the hot keys of the target time period in the corresponding time period from the preset queue.

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

[0074] S401. Receive a database query instruction;

[0075] S402. 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;

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

[0077] S403. Determine whether the target primary key is stored in the target cache;

[0078] Wherein 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, then execute S404; if the target primary key is stored in the target cache, then execute S405;

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

[0080] S405. Remove the target primary key from the target cache and add it to the real-time hot primary key set;

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

[0082] Further, after the end of the current time period, determine the hot primary keys of the current time period according to the real-time hot primary key set, and output the query frequency of the hot primary keys of the current time period in the current time period (not shown in Figure 4 ).

[0083] Corresponding to the hot data detection method of the database in the above embodiment, Figure 5 This is the structural block diagram of the hot data detection device for the database provided by the embodiments of the present disclosure. For the sake of convenience of description, only the parts related to the embodiments of the present disclosure are shown. Refer to Figure 5 , the hot data detection device 500 for the database includes: a judgment unit 501, a cache unit 502, and a recording unit 503.

[0084] Among them, the judgment unit 501 is configured to receive a database query instruction and 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;

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

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

[0087] A statistics unit, configured to, after the end of the current time period, determine the hot primary keys of the current time period according to the real-time hot primary key set, and output the query frequency of the hot primary keys 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 primary key set through the target cache, it is configured to:

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

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

[0091] 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 primary key set.

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

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

[0094] In one or more embodiments of the present disclosure, when the recording unit 503 adds the target primary key to the real-time hot primary key set, it is configured to:

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

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

[0097] If the preset primary key number threshold is reached, create a second real-time hot primary key set corresponding to the current time period, and add the target primary key to the second real-time hot primary key set.

[0098] In one or more embodiments of the present disclosure, when the statistics unit determines the hot primary keys of the current time period according to the real-time hot primary key set after the end of the current time period, it is configured to:

[0099] After the end of the current time period, all real-time hot topic primary key sets within the current time period are merged, and the hot topic primary key for the current time period is determined based on the merged real-time hot topic primary key set.

[0100] In one or more embodiments of the present disclosure, when determining the hot topic primary key for the current time period based on the real-time hot topic primary key set after the end of the current time period, the statistical unit is configured to:

[0101] Sort the primary keys included in the real-time hot topic primary key set according to the query frequency in the current time period, and determine the first preset number of primary keys with the highest query frequency in the current time period as the hot topic primary key for the current time period.

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

[0103] Filter out the primary keys in the real-time hot topic primary key set whose query frequency in the current time period is lower than the preset single-time period query frequency threshold, and sort the remaining primary keys in the real-time hot topic primary key set according to the query frequency in the current time period.

[0104] In one or more embodiments of the present disclosure, when outputting the query frequency of the hot topic primary key for the current time period in the current time period, the statistical unit is configured to:

[0105] Determine whether a preset queue is full; wherein the preset queue is used to store the query frequencies of the hot topic primary keys for the past second preset number of time periods in the corresponding time periods;

[0106] If the preset queue is not full, store the query frequency of the hot topic primary key for the current time period in the current time period into the preset queue; or

[0107] If the preset queue is full, delete the query frequency of the hot topic primary key for the earliest time period in the preset queue in the corresponding time period, and store the query frequency of the hot topic primary key for the current time period in the current time period into the preset queue.

[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 hot topic primary key for any target time period in the preset queue in the corresponding time period, output the query frequency of the hot topic primary key for the target time period in the corresponding time period, and delete the query frequency of the hot topic primary key for the target time period in the corresponding time period from the preset queue.

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

[0111] Referring to Figure 6 , which shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. The electronic device 600 can be a terminal device or a server. Among them, the terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable media players (PMPs), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.

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

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

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

[0115] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection having 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 can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium can 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 can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0116] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; or it can exist separately and not be assembled into the electronic device.

[0117] The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device is caused to perform 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 combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone 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 through 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., through the Internet using an Internet service provider).

[0119] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.

[0120] The units involved in the embodiments described in the present disclosure may be implemented in software or in hardware. Among them, the name of the unit does not constitute a limitation on the unit itself in some cases. For example, the first acquisition unit may also be described as "the 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 (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and so on.

[0122] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

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

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

[0125] If the target primary key does not exist in the real-time hot primary key set, controlling, through a target cache, 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;

[0126] If the target primary key exists in the real-time hot primary key set, accumulating the query frequency of the target primary key in the current time period in the real-time hot primary key set;

[0127] After the current time period ends, determining a hot primary key of the current time period according to the real-time hot primary key set, and outputting the query frequency of the hot primary key of the current time period in the current time period.

[0128] According to one or more embodiments of the present disclosure, the controlling, through a target cache, whether to add the target primary key to the real-time hot primary key set 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 the least recently used algorithm; or

[0131] If the target primary key is stored in the target cache, removing the target primary key from the target cache and adding it to the real-time hot primary key set.

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

[0133] Determine the number of primary keys that the target cache is allowed to store according to the total number of queries allowed by the database in a single time period and a preset query frequency threshold for a single time period, and configure the storage space of the target cache 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 hot primary key set includes:

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

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

[0137] If the preset primary key number threshold has been reached, create a second real-time hot primary key set corresponding to the current time period, and add the target primary key to the second real-time hot primary key set.

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

[0139] After the current time period ends, merge all the real-time hot primary key sets within the current time period, and determine the hot primary key of the current time period according to the merged real-time hot primary key set.

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

[0141] Sort the primary keys included in the real-time hot primary key set according to the query frequency in the current time period, and determine the first preset number of primary keys with the highest query frequency in the current time period as the hot primary key of the current time period.

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

[0143] Filter out the primary keys with a query frequency lower than the preset single-time period query frequency threshold in the current time period from the real-time hot primary key set, and sort the remaining primary keys in the real-time hot primary key set according to the query frequency in the current time period.

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

[0145] Determine whether a preset queue is full; wherein the preset queue is used to store the query frequencies of the hot primary keys in the corresponding time periods of the past second preset number of time periods;

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

[0147] If the preset queue is full, delete the query frequency of the hot primary key in the corresponding time period of the earliest time period in the preset queue, and store the query frequency of the hot primary key in the current time period in the preset queue.

[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 hot primary key in the corresponding time period of any target time period in the preset queue, output the query frequency of the hot primary key in the corresponding time period of the target time period, and delete the query frequency of the hot primary key in the corresponding time period of the target time period from the preset queue.

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

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

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

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

[0154] A statistics unit, configured to, after the current time period ends, determine the hot primary key of the current time period according to the real-time hot primary key set, and output the query frequency of the hot 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 primary key set through the target cache, it is used for:

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

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

[0158] 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 primary key set.

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

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

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

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

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

[0164] If the preset primary key number threshold has been reached, create a second real-time hot primary key set corresponding to the current time period and add the target primary key to the second real-time hot primary key set.

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

[0166] After the end of the current time period, merge all the real-time hot primary key sets within the current time period, and determine the hot primary key of the current time period according to the merged real-time hot primary key set.

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

[0168] Sort the primary keys included in the real-time hot primary key set according to the query frequency in the current time period, and determine the first preset number of primary keys with the highest query frequency in the current time period as the hot primary keys in 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 primary key set according to the query frequency in the current time period, it is used for:

[0170] Filter out the primary keys in the real-time hot primary key set whose query frequency in the current time period is lower than the preset single-time period query frequency threshold, and sort the remaining primary keys in the real-time hot primary key set 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 hot primary keys in the current time period in the current time period, it is used for:

[0172] Judge whether the preset queue is full; wherein the preset queue is used to store the query frequencies of the hot primary keys in the past second preset number of time periods in the corresponding time periods;

[0173] If the preset queue is not full, store the query frequency of the hot primary keys in the current time period in the current time period into the preset queue; or

[0174] If the preset queue is full, delete the query frequency of the hot primary keys in the earliest time period in the preset queue in the corresponding time period, and store the query frequency of the hot primary keys in the current time period in the current time period into the preset queue.

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

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

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

[0178] The memory stores computer execution instructions;

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

[0180] Fourthly, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method for detecting hot data in a database as described in the first aspect above and all possible designs of the first aspect.

[0181] Fifthly, according to one or more embodiments of the present disclosure, there is provided a computer program product including computer-executable instructions, which, when executed by a processor, implement the method for detecting hot data in a database as described in the first aspect above and all possible designs of the first aspect.

[0182] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. 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 the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.

[0183] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.

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

Claims

1. A method for detecting hot data in a database, characterized in that Including: Receiving a database query instruction, and determining 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, controlling through the target cache 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; If the target primary key exists in the real-time hot primary key set, accumulating the query frequency of the target primary key in the current time period in the real-time hot primary key set; After the current time period ends, determining the hot primary keys of the current time period according to the real-time hot primary key set, and outputting the query frequency of the hot primary keys of the current time period in the current time period; The controlling through the target cache whether to add the target primary key to the real-time hot primary key set includes: Judging 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 the least recently used algorithm; or If the target primary key is stored in the target cache, removing the target primary key from the target cache and adding it to the real-time hot primary key set.

2. The method according to claim 1, wherein The method further includes: Determining the number of primary keys allowed to be stored in the target cache according to the total number of queries allowed by the database in a single time period and a preset query frequency threshold for a single time period, and configuring the storage space of the target cache based on the number of primary keys allowed to be stored.

3. The method according to claim 1, characterized in that, Adding the target primary key to the real-time hot primary key set includes: Judging whether the number of primary keys included in the first real-time hot primary key set corresponding to the current time period reaches a preset primary key number threshold; If it does not reach the preset primary key number threshold, adding the target primary key to the first real-time hot primary key set; or If it has reached the preset primary key number threshold, creating a second real-time hot primary key set corresponding to the current time period and adding the target primary key to the second real-time hot primary key set.

4. The method according to claim 3, wherein The determining the hot primary keys of the current time period according to the real-time hot primary key set after the current time period ends includes: After the current time period ends, merging all the real-time hot primary key sets within the current time period, and determining the hot primary keys of the current time period according to the merged real-time hot primary key set.

5. The method according to claim 1, wherein The determining the hot primary keys of the current time period according to the real-time hot primary key set after the current time period ends includes: Sorting the primary keys included in the real-time hot primary key set according to the query frequency in the current time period, and determining the first preset number of primary keys with the highest query frequency in the current time period as the hot primary keys of the current time period.

6. The method according to claim 5, characterized in that The sorting the primary keys included in the real-time hot primary key set according to the query frequency in the current time period includes: Screening out the primary keys with a query frequency lower than the preset single-time period query frequency threshold in the real-time hot primary key set, and sorting the remaining primary keys in the real-time hot primary key set according to the query frequency in the current time period.

7. The method according to claim 1, characterized in that, Querying the frequency of the hot primary key in the current time period, including: Determining whether a preset queue is full; the preset queue is used to store the query frequencies of the hot primary keys in the past second preset number of time periods in the corresponding time periods; If the preset queue is not full, storing the query frequency of the hot primary key in the current time period in the preset queue; or If the preset queue is full, deleting the query frequency of the hot primary key in the earliest time period in the preset queue and storing the query frequency of the hot primary key in the current time period in the preset queue.

8. The method according to claim 7, wherein The method further includes: In response to a read request for the query frequency of the hot primary key in any target time period in the preset queue, outputting the query frequency of the hot primary key in the target time period and deleting the query frequency of the hot primary key in the target time period from the preset queue.

9. A hot data detection device for a database, characterized in that, Including: A judgment unit, configured 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 primary key set corresponding to the current time period; A cache unit, configured to, if the target primary key does not exist in the real-time hot primary key set, control whether to add the target primary key to the real-time hot primary key set through a target cache; Where the target cache is a cache based on the least recently used algorithm; A recording unit, configured to, if the target primary key exists in the real-time hot primary key set, accumulate the query frequency of the target primary key in the current time period in the real-time hot primary key set; A statistics unit, configured to, after the end of the current time period, determine the hot primary key in the current time period according to the real-time hot primary key set and output the query frequency of the hot primary key in the current time period; When the cache unit controls whether to add the target primary key to the real-time hot primary key set through the target cache, it is configured to: Judge 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 the least recently used algorithm; Or If the target primary key is stored in the target cache, removing the target primary key from the target cache and adding it to the real-time hot primary key set.

10. An electronic device, characterized in that, Including: At least one processor and a memory; The memory stores computer execution instructions; The at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the method according to any one of claims 1-8.

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

12. A computer program product, characterized in that, Including computer execution instructions, and when the processor executes the computer execution instructions, the method according to any one of claims 1-8 is implemented.

Citation Information

Patent Citations

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

    CN107786595A

  • Cache elimination method and system

    CN113268440A

  • KR20240105645A