Data query method and device, storage medium and electronic equipment
By distinguishing the hot and cold leaves in the database system, and combining learning index and binary search method, the balance of query efficiency and storage space is solved, and the overall performance of the database system is improved.
Patent Information
- Application Number
- CN202510562539.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-09-05
AI Technical Summary
When prior art query data through learning indexes, it often ignores the overhead of storage space, resulting in the problem of query efficiency and balance of storage space.
By distinguishing between hot nodes and cold nodes from leaf nodes of the tree structure, learning index query hot node data, binary search method query cold node data, and reasonably allocate storage resources to balance query efficiency and storage space.
This improves the query efficiency of hot nodes while saving the storage space of the entire database system, achieving a balance between query efficiency and storage space.
Smart Images

Figure CN120596714A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a data query method, device, storage medium, and electronic device. Background Art
[0002] Currently, databases have been widely used in various fields. How to use databases to quickly query and process data is an eternal topic in database technology.
[0003] Learning indexing is a data indexing technology that uses index models to replace traditional index structures such as B-trees, B+ trees, and hash tables. Its core idea is to more efficiently predict the location of data by fitting the distribution patterns of stored data, reduce the computational overhead during queries, and thus improve query efficiency.
[0004] However, existing technologies often only focus on query efficiency when querying data through learning indexes, while ignoring the impact of other aspects. For example, fitting an accurate index model requires a large amount of storage space overhead.
[0005] Therefore, how to balance the query efficiency of learning indexes and other performance indicators such as storage space is an urgent problem to be solved. Summary of the Invention
[0006] The embodiments of this specification provide a data query method, device, storage medium, and electronic device to partially solve the problems existing in the above-mentioned prior art.
[0007] The embodiments of this specification adopt the following technical solutions:
[0008] This specification provides a data query method, which includes:
[0009] Determine the number of data queries that have been performed on each leaf node of the tree structure used to store data in history;
[0010] Determining a hot node in each leaf node of the tree structure according to the number of data queries performed on each leaf node;
[0011] Fitting the mapping relationship between the key and storage location of the data stored in the hot node to obtain an index model corresponding to the hot node;
[0012] When querying the data to be queried in the hot node, the index model corresponding to the hot node is used to query the data to be queried.
[0013] This specification provides a data query device, which includes:
[0014] a determination module, configured to determine the number of times data queries have been performed on each leaf node of the tree structure for storing data in the past;
[0015] a node classification module, configured to determine a hot node in each leaf node of the tree structure according to the number of data queries performed on each leaf node;
[0016] A fitting module, configured to fit the mapping relationship between the key and storage location of the data stored in the hot node to obtain an index model corresponding to the hot node;
[0017] The query module is used to query the data to be queried by using the index model corresponding to the hot node when querying the data to be queried in the hot node.
[0018] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned data query method is implemented.
[0019] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned data query method is implemented.
[0020] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:
[0021] The embodiments of this specification disclose a data query method. This method determines whether each leaf node of a tree structure is a hot node based on the number of queries to the leaf node in the past. For hot nodes, the data in the leaf node is queried using a learning index method, while for cold nodes, the data in the leaf node is still queried using the query method in the prior art. Through the above method, data can be queried using a learning index method only for hot nodes with a high query frequency to maximize the query efficiency of hot nodes, while for cold nodes with a low query frequency, data can still be queried using the query method in the prior art to save storage space of the entire database system, thereby achieving a balance between the query efficiency and storage space of the entire database system. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:
[0023] Figure 1 A flowchart of a data query method provided in an embodiment of this specification;
[0024] Figure 2 A schematic diagram of a tree structure constructed by the database system provided in the embodiments of this specification;
[0025] Figure 3 A schematic diagram of a data query device provided in an embodiment of this specification;
[0026] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0027] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.
[0028] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0029] Figure 1 A data query method flow diagram provided in an embodiment of this specification includes the following steps:
[0030] S100: Determine the number of times data queries have been performed on each leaf node of a tree structure for storing data in the past.
[0031] In the embodiments of this specification, the Figure 1 The execution subject of the data query in the method shown may be a database system, specifically a server or server cluster used to host the database system. The following description will only take the database system as an example.
[0032] Generally, a database system will first generate a tree structure according to the key of the data (the key of the data here refers to the theoretical value of the key of the data. Regardless of whether the data has been stored in the database system, as long as it is a theoretically possible value of the key of the data, it needs to be considered in the generated tree structure). There are many ways to construct a tree structure. The following only takes the bottom-up construction method as an example to illustrate.
[0033] Assuming that theoretically the value range of the data key is 1 to 80, the value range can be divided into 8 key intervals, namely 1 to 10, 11 to 20, 21 to 30, and so on. Each leaf node corresponds to a key interval, so the 8 leaf nodes corresponding to the above 8 key intervals are determined, which is the bottom layer of the tree structure. Then, the first key in the key interval corresponding to each adjacent n leaf nodes is used as the key corresponding to the parent node of these two leaf nodes to construct the parent node of the leaf node. Assuming n is 2, the parent node of the leaf nodes corresponding to 1 to 10 and 11 to 20 is (1, 11), and the parent node of the leaf nodes corresponding to 21 to 30 and 31 to 40 is (21, 31), and so on. Then use the parent node as the child node, and again use the first key in the key corresponding to each adjacent n child node as the key corresponding to the parent node of these two child nodes, until the following is constructed. Figure 2 The tree structure shown is as follows.
[0034] Those skilled in the art should understand that there are more than one method for constructing a tree structure, and any method for constructing a tree structure can achieve the effect to be achieved in this specification. This specification does not limit the method for constructing a tree structure and the topological structure of the constructed tree.
[0035] Still Figure 2 For example, after constructing the tree structure, each leaf node can be assigned a slot, or storage location. Nodes other than leaf nodes only store data keys, not the actual data. Only leaf nodes store actual data. However, it should be noted that when allocating slots to a leaf node, not every key in the key interval corresponding to that leaf node is assigned a corresponding slot. The actual number of slots allocated to a leaf node may be less than the number of keys in the key interval corresponding to that leaf node.
[0036] For example, a leaf node may have a key range of 1 to 10, meaning it can store up to 10 data items. However, only three slots are allocated for this leaf node. This is because the key range 1 to 10 represents theoretically possible keys for data. In practice, the keys for the data to be stored are not generated sequentially from smallest to largest; they exhibit a certain degree of randomness. For example, at a certain moment, the three data items to be stored are user information for Zhang San, Li Si, and Wang Wu. The keys for these three data items determined based on their IDs (e.g., by hashing the user IDs) are 2, 5, and 9, respectively. However, the data items corresponding to the other keys in the key range 1 to 10 have not yet been generated. Therefore, the keys for the three data items to be stored are not sequentially 1, 2, and 3. If the leaf node is fully allocated slots based on the key range 1 to 10, some of these slots may remain idle for extended periods, resulting in a waste of storage resources. Therefore, the number of slots actually allocated for the leaf node is less than the number of keys in the key range corresponding to the leaf node.
[0037] The index model fitted by the learning index is a function that takes the data key as input and the data storage location as output, that is, y = n × f(x), where n is the total number of keys in the key interval of the leaf node, x is the data key, y is the data storage location, and f(x) represents the CDF of the data storage location with respect to x.
[0038] The key range corresponding to the leaf node is 1 to 10. Theoretically, if a slot is assigned to each key corresponding to the leaf node, for a total of 10 slots, then the above f(x) = x / n, and the index model is y = x. From this index model, it can be seen that the data with key 1 is stored in the first storage location, and the data with key n is stored in the nth storage location. At this time, the distribution of data is a perfect linear distribution, and the above index model is the most accurate.
[0039] However, in the above example, only 3 slots are allocated to the leaf node. Zhang San's data with a key of 2 is stored in the first storage location, Li Si's data with a key of 5 is stored in the second storage location, and Wang Wu's data with a key of 9 is stored in the third storage location. This destroys the linearity of the data distribution. At this time, the index model y = n × f (x) that needs to be fitted needs to make y = 1 when x = 2, y = 2 when x = 5, and y = 3 when x = 9.
[0040] It can be seen that the more accurate the index model is, the more slots the leaf node requires. Even if many slots do not store data, in order to make the fitted index model accurate, these free slots need to be added to the leaf node. This is a method that exchanges storage space for query efficiency and query accuracy.
[0041] When querying data using the traditional B+ tree index structure, when the queried data hits a leaf node of the tree structure, the data can be directly queried in the storage space of the leaf node through the binary search method. This only requires that the data be stored in the storage location of the leaf node in ascending order of the key, and does not require too much free storage space. However, the time complexity of the binary search method is O(log n), which is much larger than the time complexity of the learning index query data O(1), so the query efficiency is low.
[0042] Therefore, in the embodiment of this specification, the leaf nodes in the above-mentioned tree structure established by the database system are divided into hot nodes and cold nodes. The hot nodes are queried for data using the learning index method, and the cold nodes are still queried for data using the binary search method to balance the query efficiency and storage space and other performance indicators of the entire database system.
[0043] To distinguish between hot and cold nodes, the database system must first determine the frequency with which each leaf node is queried. Therefore, the database system can determine the number of historical data queries for each leaf node in the tree structure used to store data. Specifically, the database system can count the number of data queries for each leaf node in the tree structure over a preset historical time period, such as the number of data queries within the past month.
[0044] S102: Determine a hot node in each leaf node of the tree structure according to the number of times data queries are performed on each leaf node.
[0045] In an embodiment of the present disclosure, hot nodes and cold nodes in a tree structure can be determined based on the statistical number of data queries performed on each leaf node. Specifically, the database system can determine, among the leaf nodes in the tree structure, leaf nodes with a data query frequency exceeding a preset threshold as hot nodes, and other leaf nodes as cold nodes. That is, leaf nodes with a high data query frequency are hot nodes, while leaf nodes with a low data query frequency are cold nodes.
[0046] S104: Fitting the mapping relationship between the key and storage location of the data stored in the hot node to obtain an index model corresponding to the hot node.
[0047] After dividing each leaf node in the tree structure into hot nodes and cold nodes, the database system can fit the CDF of the data stored in the hot node according to the distribution of the data stored in the hot node, and determine the index model corresponding to the hot node based on the fitted CDF.
[0048] Specifically, the database system can determine to use a preset function to fit the mapping relationship between the key and storage location of the data stored in the hot node based on the key of the data stored in the hot node and the storage location of the data stored in the hot node to obtain an index model.
[0049] In order to improve the accuracy of the fitted index model, the database system can expand the storage location in the hot node, but expanding the storage location in the hot node will lead to an increase in the storage cost of the entire database system. Therefore, in the embodiment of this specification, the storage location of the hot node can be expanded on the one hand, and the storage location of the cold node can be compressed on the other hand, so as to improve the accuracy of the index model corresponding to the fitted hot node while minimizing the storage cost.
[0050] Specifically, the database system can select target cold nodes from the identified cold nodes, freeing up unoccupied storage locations (i.e., slots not storing data) in the target cold nodes while also adding storage locations in the hot nodes, thereby expanding the storage capacity of the hot nodes. When selecting target cold nodes, the database system can randomly select a specified number of cold nodes from each cold node as the target cold nodes. For example, the database system can first determine the specified number based on the identified number of cold nodes and a preset ratio (e.g., 10%), and then randomly select the specified number of target cold nodes from each cold node.
[0051] S106: When querying the data to be queried in the hot node, the index model corresponding to the hot node is used to query the data to be queried.
[0052] In an embodiment of the present specification, the database system may receive a request to query the data to be queried, and the request may carry the key of the data to be queried. Therefore, the database system may determine the leaf node where the key of the data to be queried is located based on the tree structure constructed above, as the target leaf node, that is, determine the target leaf node hit by the key of the target data based on the key of the data to be queried and the tree structure constructed above.
[0053] After determining the target leaf node, the database system can determine whether the target leaf node is a hot node. If it is a hot node, the key of the data to be queried can be input into the index model corresponding to the hot node, and the storage location of the data to be queried in the hot node output by the index model can be obtained as the target storage location. Of course, the target storage location output by the index model may still have a certain deviation, but the accuracy of the index model corresponding to the hot node fitted in step S104 is sufficient. Even if there is a deviation, the actual storage location of the data to be queried must be near the target storage location output by the index model. Therefore, the database system can determine the actual storage location of the data to be queried within the preset neighborhood of the target storage location based on the target storage location output by the index model.
[0054] If the target leaf node is a cold node, the database system may still use a binary search method to query the storage location of the data to be queried in the target leaf node.
[0055] Through the above method, the database system can use the learning index method to query data only for hot nodes with higher query frequency, so as to maximize the query efficiency of hot nodes. For cold nodes with lower query frequency, the query method in the existing technology can still be used to query data, so as to save the storage space of the entire database system and achieve the purpose of balancing the query efficiency and storage space of the entire database system.
[0056] Furthermore, the database system can execute the following Figure 1 The method shown, that is, redetermines the hot nodes in each leaf node of the tree structure according to a set period. For a leaf node that evolves from a cold node to a hot node, the corresponding method of performing data query in the leaf node also evolves from the binary search method to the above-mentioned learning index query method based on the index model. For a leaf node that degenerates from a hot node to a cold node, the corresponding method of performing data query in the leaf node also degenerates from the above-mentioned learning index query method based on the index model to the binary search method.
[0057] In addition, for a leaf node, as the amount of data stored in the leaf node increases, the method of learning index query data is not necessarily higher than the binary search method in terms of query efficiency. This is because as the amount of stored data increases, the distribution of the data stored in the leaf node at each storage location may gradually no longer be suitable for fitting the index model, thereby destroying the robustness of the learned index. Moreover, in different application scenarios, the requirements for the database system are also different, such as ordinary data management scenarios and web page retrieval scenarios. Ordinary data management scenarios may require minimizing storage space consumption, while web page retrieval scenarios require maximizing query efficiency for the retrieval speed of popular web pages. Therefore, in the embodiments of this specification, in order to flexibly adapt to different scenarios and switch between different data query methods, the database system can determine the query cost for data querying each leaf node in the tree structure, and flexibly switch between different data query methods based on the query cost.
[0058] Specifically, the database system can only determine the first query cost of using the index model corresponding to the hot node to query the data to be queried in the hot node for the hot node determined in step S102, and determine the second query cost of using the binary search method to query the data to be queried in the hot node. If the first query cost is less than the second query cost, the index model corresponding to the hot node is used to query the data to be queried in the hot node. If the first query cost is not less than the second query cost, the binary search method is used to query the data to be queried in the hot node.
[0059] Among them, when determining the first query cost of querying data using the learned index method, the database system can determine the first query time required to query the data to be queried in the hot node using the index model corresponding to the hot node and the first number of storage locations required by the hot node when querying the data to be queried in the hot node using the index model corresponding to the hot node, and then determine the first query cost based on the first query time and the first number.
[0060] The first query time required to query the data to be queried in the hot node using the query method of the learned index can directly reflect the query efficiency of the hot node using the learned index. The reason why it is necessary to determine the first number of storage locations required by the hot node when querying the data to be queried in the hot node using the learned index query method is because if the accuracy of the storage location of the data to be queried output by the index model in the hot node is to be guaranteed, it may be necessary to have a certain number of storage locations in the hot node (even if some storage locations are idle) in order to fit an accurate index model, which reflects the storage cost required for the learning index to be used for the hot node. Therefore, the overall query cost of using the learning index for the hot node can be determined based on the first query time, the first number and the preset weight determined above, which is the first query cost.
[0061] The first query cost is positively correlated with the first query time and the first quantity. The first query cost can be specifically expressed as COST1=Perf1 r × Spac1, where COST1 is the first query cost, Perf1 is the first query time, Spac1 is the first quantity, and r is the preset weight. By setting the weight r, we can adapt the switching between different query methods to different scenarios. If r is greater than 1, the database system focuses on improving query efficiency; if r is less than 1, the database system focuses on saving storage space.
[0062] When determining the above-mentioned first query time, the database system can estimate the first query time required to use the index model to query the data to be queried in the hot node through a preset estimation algorithm, or it can use the index model to query the data to be queried in the hot node within a specified period of time, and record the query time for each data to be queried during this period of time, and determine the above-mentioned first query time based on the query time for each data to be queried.
[0063] Similarly, when determining the second query cost of querying data using the binary search method, the database system can determine the second query time required to query the data to be queried in the hot node using the binary search method and the second number of storage locations required by the hot node when querying the data to be queried in the hot node using the binary search method, and then determine the second query cost based on the second query time and the second number. The second query cost is positively correlated with the second query time and is also positively correlated with the second number. The second query cost can be specifically expressed as COST2 = Perf2 r ×Spac2, where COST2 is the second query cost, Perf2 is the second query time, Spac2 is the second quantity, and r is the preset weight. This is similar to the above determination of the first query cost, and will not be repeated here.
[0064] It should be noted that for a leaf node, when using a learned index to query data, if the number of storage locations in the leaf node does not change, the query cost of using the learned index to query the data in the leaf node will not change. Therefore, when the database system switches the data query method of the leaf node based on the query costs corresponding to the two data query methods determined above, it can use the above method to switch the data query method of the leaf node when the number of storage locations in the leaf node changes.
[0065] The change in the number of storage locations in a leaf node generally occurs when data is inserted into the leaf node (i.e., new data is stored in the leaf node) or when the stored data in the leaf node is deleted. Therefore, for a leaf node that has been determined to be a hot node, when the database system stores the data to be inserted into the storage location in the hot node, it needs to determine whether the storage location in the hot node needs to be expanded, that is, whether the storage location in the hot node needs to be increased. If so, the storage location in the hot node is expanded, and it is determined that the number of storage locations in the hot node has changed. Alternatively, when deleting the data to be deleted from the hot node, it is necessary to determine whether the storage location in the hot node needs to be compressed, that is, whether the storage location in the hot node needs to be reduced. If so, the storage location in the hot node is compressed, and it is determined that the number of storage locations in the hot node has changed. When the number of storage locations in the hot node changes, the data query method of the leaf node is switched based on the query costs corresponding to the two data query methods determined above.
[0066] The above is a data query method provided in an embodiment of this specification. Based on the same idea, this specification also provides corresponding devices, storage media and electronic devices.
[0067] Figure 3 A schematic diagram of a data query device provided in an embodiment of this specification, the device comprising:
[0068] A determination module 301 is used to determine the number of times data queries have been performed on each leaf node of the tree structure used to store data in the past;
[0069] A node classification module 302 is configured to determine a hot node in each leaf node of the tree structure according to the number of data queries performed on each leaf node;
[0070] A fitting module 303 is configured to fit the mapping relationship between the key and storage location of the data stored in the hot node to obtain an index model corresponding to the hot node;
[0071] The query module 304 is configured to query the data to be queried using the index model corresponding to the hot node when querying the data to be queried in the hot node.
[0072] Optionally, the node classification module 302 is also used to determine the cold nodes in each leaf node of the tree structure according to the number of data queries performed on each leaf node before the fitting module 303 fits the mapping relationship between the keys and storage locations of the data stored in the hot node; select a target cold node in each cold node; release unoccupied storage locations in the target cold node, and increase the storage locations in the hot node.
[0073] Optionally, the node classification module 302 is specifically configured to, among the leaf nodes of the tree structure, determine the leaf nodes whose data queries are greater than a preset threshold as hot nodes, and determine the leaf nodes other than the hot nodes as cold nodes.
[0074] Optionally, the node classification module 302 is specifically configured to randomly select a specified number of cold nodes from each cold node as target cold nodes.
[0075] Optionally, the query module 304 is also used to determine a first query cost of using the index model to query the data to be queried in the hot node and a second query cost of using the binary search method to query the data to be queried in the hot node before using the index model corresponding to the hot node to query the data to be queried; if the first query cost is less than the second query cost, the index model corresponding to the hot node is used to query the data to be queried.
[0076] Optionally, the query module 304 is also used to determine whether the number of storage locations in the hot node has changed before determining a first query cost for querying the data to be queried in the hot node using the index model and a second query cost for querying the data to be queried in the hot node using the binary search method.
[0077] Optionally, the query module 304 is specifically used to determine whether the storage location in the hot node needs to be expanded when the data to be inserted is stored in the storage location in the hot node; if so, expand the storage location in the hot node and determine whether the number of storage locations in the hot node has changed.
[0078] Optionally, the query module 304 is specifically used to determine the first query time required for querying the data to be queried in the hot node using the index model and the first number of storage locations required for the hot node when querying the data to be queried in the hot node using the index model, and determine a first query cost based on the first query time and the first number; wherein the first query cost is positively correlated with the first query time, and the first query cost is positively correlated with the first number; determine the second query time required for querying the data to be queried in the hot node using the binary search method and the second number of storage locations required for the hot node when querying the data to be queried in the hot node using the binary search method, and determine a second query cost based on the second query time and the second number; wherein the second query cost is positively correlated with the second query time, and the second query cost is positively correlated with the second number.
[0079] Optionally, the query module 304 is further configured to, if the first query cost is not less than the second query cost, use a binary search method to query the data to be queried.
[0080] This specification also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can be used to execute the data query method provided above.
[0081] based on Figure 1 The data query method shown in this specification also provides Figure 4 The structural diagram of the electronic device shown in FIG. Figure 4 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile storage, and may also include other hardware required for its operations. The processor reads the corresponding computer program from the non-volatile storage into the memory and then runs it to implement the above-mentioned data query method.
[0082] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.
Claims
1. A data query method, comprising: Determine the number of data queries that have been performed on each leaf node of the tree structure used to store data in history; Determining a hot node in each leaf node of the tree structure according to the number of data queries performed on each leaf node; Fitting the mapping relationship between the key and storage location of the data stored in the hot node to obtain an index model corresponding to the hot node; When querying the data to be queried in the hot node, the index model corresponding to the hot node is used to query the data to be queried.
2. The method according to claim 1, before fitting the mapping relationship between the key and storage location of the data stored in the hot node, the method further comprises: Determining a cold node in each leaf node of the tree structure according to the number of data queries performed on each leaf node; Select a target cold node from among the cold nodes; Unoccupied storage locations in the target cold node are released, and storage locations in the hot node are increased.
3. The method according to claim 1 or 2, further comprising determining a hot node in each leaf node of the tree structure according to the number of data queries performed on each leaf node, comprising: Among the leaf nodes of the tree structure, the leaf nodes whose data queries are performed more than a preset threshold are determined as hot nodes, and the leaf nodes other than the hot nodes are determined as cold nodes.
4. The method according to claim 2, wherein selecting a target cold node from among the cold nodes comprises: A specified number of cold nodes are randomly selected from each cold node as target cold nodes.
5. The method according to claim 1, before using the index model corresponding to the hot node to query the data to be queried, the method further comprises: Determine a first query cost of querying the data to be queried in the hot node using the index model and a second query cost of querying the data to be queried in the hot node using a binary search method; If the first query cost is less than the second query cost, the index model corresponding to the hot node is used to query the data to be queried.
6. The method of claim 5, before determining a first query cost for querying the data to be queried in the hot node using the index model and a second query cost for querying the data to be queried in the hot node using a binary search method, the method further comprises: A change in the number of storage locations in the hot node is determined.
7. The method of claim 6, wherein determining that the number of storage locations in the hot node has changed comprises: When storing the data to be inserted into the storage location in the hot node, determining whether the storage location in the hot node needs to be expanded; If so, the storage locations in the hot node are expanded, and it is determined that the number of storage locations in the hot node has changed.
8. The method according to claim 5, wherein determining a first query cost for querying the data to be queried in the hot node using the index model comprises: Determining a first query time required to query the data to be queried in the hot node using the index model and a first number of storage locations required by the hot node when querying the data to be queried in the hot node using the index model, and determining a first query cost based on the first query time and the first number; wherein the first query cost is positively correlated with the first query time, and the first query cost is positively correlated with the first number; Determining a second query cost for querying the data to be queried in the hot node using a binary search method specifically includes: Determine the second query time required to query the data to be queried in the hot node using the binary search method and the second number of storage locations required by the hot node when querying the data to be queried in the hot node using the binary search method, and determine the second query cost based on the second query time and the second number; wherein the second query cost is positively correlated with the second query time, and the second query cost is positively correlated with the second number.
9. The method of claim 5, further comprising: If the first query cost is not less than the second query cost, a binary search method is used to query the data to be queried.
10. A data query device, comprising: a determination module, configured to determine the number of times data queries have been performed on each leaf node of the tree structure for storing data in the past; a node classification module, configured to determine a hot node in each leaf node of the tree structure according to the number of data queries performed on each leaf node; A fitting module, configured to fit the mapping relationship between the key and storage location of the data stored in the hot node to obtain an index model corresponding to the hot node; The query module is used to query the data to be queried by using the index model corresponding to the hot node when querying the data to be queried in the hot node.
11. A computer-readable storage medium storing a computer program, wherein the computer program implements the method according to any one of claims 1 to 9 when executed by a processor.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 9 when executing the program.