A method for constructing dynamic index of database
By adopting a combination of dynamic tree structure and multiple models in the OLAP database, dynamically selecting the most suitable index model, solving the problem of poor performance of existing indexes under different data structures, and achieving more efficient and flexible database queries.
Patent Information
- Application Number
- CN202210562160.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2042-05-23
AI Technical Summary
When existing OLAP database indexes process different data structures, fixed model training may not be the optimal solution, resulting in poor query performance.
The index is constructed using a dynamic tree structure. Each node can dynamically select multiple models (including neural network model, linear model and B+ tree index) for training, select the best index model, and use the regular update characteristics of the OLAP database for adaptive updates.
It improves the query performance and scope of application of OLAP databases, and enhances the search accuracy and database retrieval efficiency.
Smart Images

Figure CN114996267B_ABST
Abstract
Description
Technical Field
[0001] The present invention applies machine learning technology to the database field, specifically a method for constructing a dynamic index of a database, which uses a machine learning algorithm to train an index model to generate a dynamic learning index. Background Art
[0002] With the development and progress of science and technology, the use of databases has become increasingly common. With the advent of the big data era, data has exploded and the query performance of databases has declined. In order to optimize the query performance of databases, indexes have emerged.
[0003] An index is a decentralized storage structure created to speed up the retrieval of rows in a table. Whenever efficient data access is required, an index structure is the answer, and a wide variety of choices exist to meet the different needs of various access patterns. For example, B-trees are the best choice for range requests.
[0004] The current OLAP database is mainly used for data analysis and processing, querying and analyzing the stored static data, and generating data reports. The OLAP database will update data regularly, and the data storage structure will change after the data is updated. The application of the OLAP system is mainly to analyze the user's current and historical data to assist leadership decision-making. Its typical applications include the analysis and prediction of bank credit card credit risk and the formulation of corporate marketing strategies. It mainly performs a large number of query operations and does not have strict time requirements.
[0005] The function of the index is to find the position corresponding to the key value better and faster. Through previous research, it is found that the index is a model that takes the key as input and predicts the location of the data. For point queries, the order of the data does not matter. For range queries, the data must be sorted according to the key so that all data items in the range (for example, within the time range) can be effectively retrieved. From this, it can be found that a model that predicts the position of a given key in a sorted array effectively approximates the cumulative distribution function (CDF). The CDF of the data can be modeled to predict the position, and the index can be learned by learning the cumulative distribution function (CDF) of the input data using traditional machine learning techniques or neural network models.
[0006] Most existing OLAP database indexes use pure B+ tree indexing. This is because B+ tree indexes have good performance and stability in both continuous and point queries, which is the result of comparison with B-tree. B+ tree may have advantages overall, but due to the use of fixed models for training, it is sometimes not the optimal solution for some data structures. For example Figure 1As shown, the key value represents the primary key of the record in the table, the pointer represents the storage child node address information, the data represents the data in the table record except the primary key, and the leaf node is the disk block 4-9. If each disk block is of equal length and the number of data in each disk block is equal, then when we look for a key value, the linear expression (position = k*(key)+b) may perform better.
[0007] Therefore, the present invention adopts a dynamic tree structure to construct an index, and the model at each node can be dynamically selected from multiple models, including at least a neural network model, a linear model, and a B+ tree index, etc. Each node of the tree index is trained and optimized with multiple models, so that it can be applicable to various types of data structures. Summary of the invention
[0008] The purpose of the present invention is to propose a method for constructing a database dynamic index and a method for adaptively updating a dynamic index based on an OLAP database. The present invention makes full use of the inclusiveness of multiple models to multiple data structures, uses the most suitable index model according to the data distribution of each node, and uses the regular update characteristics of the OLAP database to update the dynamic learning index model for self-adaptability.
[0009] The dynamic learning index model of the present invention is a multi-layer dynamic learning index. The specific idea is to use a multi-layer model for positioning, and the model is divided into 2-4 layers. Each node of each layer may be any one of a variety of node models, including but not limited to a neural network model (the mapping relationship within the neural network is uncertain, but the output of the neural network satisfies the cumulative distribution function CDF, and the neural network can be BP, LSTM), a linear regression model, and a B+ tree model. There may also be other node models other than the above three models. For each node, it is necessary to train the node models other than the B+ tree separately, and then compare them with the B+ tree model, and select the node model with the best effect as the final node model of this node.
[0010] To achieve the above object, the technical solution of the present invention is:
[0011] A method for constructing a database dynamic index, the method comprising the following contents:
[0012] Step 1. Build a global dataset
[0013] Obtain a database, wherein a large number of similar tuples are stored in the database, and each tuple has the same storage format;
[0014] Create a global data set, select the required attributes from the data information in the database, map according to the required attributes, find the data block where each row record in the mapping is located, and form a key-value pair with the key value and the block number of the data block where the data is located. All the key-value pairs selected in the database are used as the global data set;
[0015] Step 2. Build a dynamic learning index model
[0016] First, the B+ tree regression tree training is performed on the global data set, and the trained B+ tree index is recorded for data update. At the same time, the number of layers of the B+ tree and the number of nodes in each layer of the entire global data set are determined according to the B+ tree index. The global data set is divided according to the number of layers and corresponding nodes to obtain the node data set corresponding to each node;
[0017] An error threshold is set, and then, starting from the first layer, various node models other than the B+ tree are trained for each node in each layer. The node data set simultaneously trains various node models other than the B+ tree in a multi-threaded manner. For each node, there are results obtained from training various different node models, and the error rate of each node model is obtained. The node model with the smallest error rate is selected and compared with the error threshold. If it is less than the error threshold, the node model with the smallest error rate is selected as the node model of the current node, otherwise the node model of the current node selects the B+ tree; after determining the type of the node model of the current node, the node is model-identified, that is, what node model is used for this node is recorded; the various node models other than the B+ tree include at least a neural network model and a linear regression model;
[0018] After the node model type of the nodes in the current layer is determined, the nodes in the next layer that the key value of the current layer is to enter are selected and then the node model of the next layer is trained. Similarly, a dynamic learning index model is obtained. The nodes in the dynamic learning index model are dynamic index nodes, and the construction of the dynamic index of the database is completed.
[0019] The level and number of nodes of the dynamic learning index model are exactly the same as those of the B+ tree index.
[0020] A dynamic index adaptive update method based on OLAP database, the data in the global data set is distributed on the disk block as an interval array, that is, the previous and next bits of each data are empty. Then the number of positions that can accommodate new data is the same as the number of data in the global data set, and this number is called the threshold, which is the upper limit of accommodating new data; if the number of new data exceeds this threshold, data redistribution is required, and the data blocks after redistribution still return to the form of interval arrays, and the dynamic index needs to be retrained.
[0021] First, each node has a node model label, which can be used to determine the training model. Starting from the bottom data block (a data block is a group or several groups of records arranged in sequence), the data block is the training set for training the nodes connected to them. The new data in this data block can be determined by the time label of the data (usually the update timestamp attached to the data). The bottom node model is retrained with these new data, and then the node model of the previous layer is retrained, and so on. The reason for retraining from the bottom to the top is that for various models such as neural networks and linear models, the training direction does not matter, but for B+ tree nodes, the regression tree is built from the bottom to the top. Therefore, considering the entire dynamic model, the order of retraining can only be from the bottom to the top.
[0022] A computer-readable storage medium stores a computer program, wherein the computer program is suitable for executing the above-mentioned database dynamic index construction method or the above-mentioned dynamic index adaptive updating method based on OLAP database when loaded by a computer.
[0023] Compared with the prior art, the present invention has the following beneficial effects:
[0024] Compared with the traditional B+ tree index model, the present invention uses a variety of models for selection, and the three models used in the examples are listed here for advantage analysis. The neural network model uses a two-layer fully connected neural network for model training. The model trained in this way is more sensitive to historical training data, and the positioning speed is faster than the traditional B+ tree under normal irregular data distribution. In addition, when the data is distributed in a linear pattern, the traversal method of the traditional B+ tree index in the search process is not as fast as the linear expression calculation speed. However, the B+ tree index performs relatively well in the case of extremely uneven data, which is also the reason why the present invention retains the B+ tree index node. From a holistic perspective, indexing is the process of segmenting a large segment of data. In the segmentation process, starting from the first node, the data segment assigned to each node has its specific data distribution, because different sub-data segments in each large segment of data will have their own data characteristics and data distribution (there will be many data blocks in each segment, and the size and number of the mounted data blocks are uncertain). Therefore, in the process of searching for data, each time the key value reaches a node, it will face different data distributions to search for the key value. This dynamic index selects the best index model for each node's different data distribution to search for key values. It performs better than pure B+ trees and some neural network models in OLAP databases, and can improve the inclusiveness of OLAP database data search, increase its scope of application, and improve search accuracy.
[0025] The present invention utilizes the update mechanism of OLAP database to maintain and update the model, does not occupy the service provision time, improves the dynamic learning index, and improves the accuracy of the dynamic learning index. The use of a bottom-up incremental update mechanism greatly shortens the update time. After the data insertion exceeds the threshold, data redistribution is required, and spatial expansion is performed to ensure the data structure of the interval array. At this time, the index connected to it is retrained from the bottom data block to adapt to the new data distribution. The training starting from the bottom is performed asynchronously, and asynchrony is multi-threaded simultaneously, which means that each different sub-node model starts training at the same time from the bottom, and the upper node model of the sub-node model can only be trained when all its sub-node models are trained, until the root node model is retrained, which greatly reduces the training time.
[0026] In the dynamic index construction of the present invention, the node model used in each layer is not fixed, and the optimal node model suitable for the current data distribution can be selected, which is adaptive and can adapt to different data structures, thereby improving the efficiency and accuracy of database retrieval. The computer-readable storage medium of the present application can be deployed on a computer to significantly improve the computer's retrieval and search capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is a schematic diagram of the structure of a B+ tree.
[0028] Figure 2 Schematic diagram of the structure of the dynamic learning index model.
[0029] Figure 3 Schematic diagram of the neural network training model structure.
[0030] Figure 4 A relational table in a database.
[0031] Figure 5 Two-layer dynamic index model.
[0032] Figure 6 Inserts a non-empty translation operation.
[0033] Figure 7 B+ tree index generated by global data set
[0034] Figure 8 Dynamic index trained on global dataset. DETAILED DESCRIPTION
[0035] The present invention is further explained below in conjunction with the embodiments and drawings, but this is not intended to limit the scope of protection of the present application.
[0036] In this embodiment, three node models are used as examples for illustration. The three node models respectively refer to a neural network model, a linear regression model, and a B+ tree model. The output of the neural network model conforms to the CDF.
[0037] A method for constructing a dynamic index of a database according to the present invention, the process of the construction method is as follows:
[0038] Step 1. Construct a global data set.
[0039] A data set, also known as a data set, data collection or data collection, is a collection composed of data. In this embodiment, an OLAP (Online Analytical Processing) database is used as an example. The data set refers to the data to be analyzed in the OLAP database. Taking bank card information as an example, the information of a tuple in the OLAP database is approximately: ID, bank card number, cardholder name, cardholder phone number, card opening date, credit rating, etc. (see Figure 4 ). There are many similar tuples in a database relationship (a database relationship refers to a collection composed of many tuples). The <key.Value> values required for the global data set in this embodiment are <ID, block number of the data block where the data is located> or <bank card number (last digits instead of the full card number), block number of the data block where the data is located>. Therefore, before using the data set, the data source should be preprocessed to pick out the key-value pairs we need and then use them as the global data set. The original data in the OLAP database is stored in a table, and each tuple has many attribute columns, but not all of them are needed. To build an index, only the relationship between the index number and the data block number needs to be built. By finding the data block through the index number and then finding the data we need inside the data block.
[0040] First, map the required attributes to find the data block where each row record is located, and then take out the key-value pairs composed of <ID, block number of the data block where the data is located> and save them to a csv file. The data format in the csv file is key-value pairs, and each row has a pair of data, which is used as the global data set.
[0041] Step 2. Construct a dynamic learning index model
[0042] First, perform regression tree training of the B+ tree on the global data set, record the trained B+ tree index for data update, and at the same time determine the number of layers of the entire global data set in the B+ tree and the number of nodes in each layer according to the B+ tree index, and divide the global data set according to the layers and the corresponding nodes to obtain the node data set corresponding to each node;
[0043] An error threshold is set, and then, starting from the first layer, various node models other than the B+ tree are trained for each node in each layer. The node data set simultaneously trains various node models other than the B+ tree in a multi-threaded manner. For each node, there are results obtained from training various different node models, and the error rate of each node model is obtained. The node model with the smallest error rate is selected and compared with the error threshold. If it is less than the error threshold, the node model with the smallest error rate is selected as the node model of the current node, otherwise the node model of the current node selects the B+ tree; after determining the type of the node model of the current node, the node is model-identified, that is, what node model is used for this node is recorded; the various node models other than the B+ tree include at least a neural network model and a linear regression model;
[0044] After the node model type of the nodes in the current layer is determined, the nodes in the next layer that the key value of the current layer is to enter are selected and then the node model of the next layer is trained. Similarly, a dynamic learning index model is obtained. The nodes in the dynamic learning index model are dynamic index nodes, and the construction of the dynamic index of the database is completed.
[0045] The specific process is: First, confirm the input and output of the dynamic learning index model. The input includes data[] (global data set), limit (error threshold), etc., and the output is trained index (dynamic index).
[0046] Define a temporary data two-dimensional array temp_data[][] to store the training data. The two dimensions of this two-dimensional array represent the layer and node respectively. Assign the entire global data set to temp_data[1][1]. This is the first model [1.1], which is the node data set of the root node. The main function of this step is to initialize the global data set.
[0047] Then, a B+ tree index is constructed and stored based on the global data set, recording the B+ tree nodes, which also serve as a record of data distribution in the global data set, determining the number of layers and nodes, and the node data set of each node in each layer, with a total of S layers.
[0048] From the 1st layer to the Sth layer, loop from the 1st node to the last node of each layer, and the content of the loop is:
[0049] Use the node data set temp_data[i][j] of this node to train the neural network model and linear regression model;
[0050] Obtain the errors of the neural network model and the linear regression model respectively, compare them, and store the smallest error value in err. In this embodiment, the error calculation uses the mean square error, the purpose is to amplify the error as much as possible and improve accuracy.
[0051] Compare the error value err with the set error threshold (generally set to around 0.35-0.45). If the node model with the smallest error in the neural network model and the linear regression model still performs poorly, use the B+ tree node and copy and mark the previously trained B+ tree node.
[0052] The trained data in the node data set of the current node in the current layer will be used to select child nodes according to the current node model, and the selected data will be used to train the node models of each child node in the next layer.
[0053] After the cycle is completed, the dynamic learning index model is trained and the dynamic index trained index is output. The nodes of the dynamic index are marked with the type of node model finally selected by the node.
[0054] Figure 2 This is a schematic diagram of the structure of the obtained dynamic learning index model. There are four layers in total, recorded as stage1 to stage4, and each layer of nodes is recorded as NODEi.j (this letter indicates a model type without a node). i represents the layer, with a value of 1 to 4, and j represents the node, with each layer starting from 1. Figure 2 The types of node models that can be selected for each node are given in brackets.
[0055] The structure of the neural network model is shown in Figure 3 , the input is the key value, it contains two hidden layers, the output conforms to the CDF, and the child node is selected according to the output. The training process is roughly as follows: first, the parameters are initialized, which include but are not limited to: the threshold for stopping training, the number of neurons, the number of iterations, the learning rate, etc. Then, the relu function is activated for each neuron, and the dropout function is used to prevent overfitting. Then, the optimizer is set and the loss function is defined, and finally the training is started.
[0056] The data search process in the above dynamic learning index model is: input the search target, calculate the key from the root node through the determined node model, select the child node according to the output, select the lower node, until the bottom data block (internal mapping of the neural network model or other models for the key calculation, for example, the linear expression is y = kx + b, x is brought in for calculation, and y is obtained as the node model output). If the search is empty during the search, exit the program.
[0057] The present invention also protects a dynamic index adaptive update method based on an OLAP database, and the update method is based on the update strategy of the OLAP database. The status of the OLAP analytical database is divided into two states: running and updating. In the running state, the OLAP database provides data analysis services for the data analysis system (big data application system such as a banking system). In the updating state, incremental updates of new data are performed. In order to ensure normal operation, the OLAP database generally updates data at night and provides analysis services during the day, or in order to ensure that it is performed while providing services, a shadow system is generally used for updating. The shadow system copies a snapshot B of the current version A, updates the data on version B, and version A provides services normally. After version B is updated, replace version A with version B.
[0058] The present invention makes full use of the update time of the OLAP database and performs synchronization update with the OLAP database. First, the dynamic index of the present invention contains a neural network model, which has certain adaptability and certain flexibility after adding new data. Therefore, for new data updated incrementally, the dynamic index does not necessarily need to be updated.
[0059] The first thing to be clear is that the data structure in the OLAP database is an interval array. Figure 6 This is a simple two-layer dynamic learning index model. The bottom layer in the figure shows the distribution of data blocks. It can be seen that there is an empty space between every two data in the data block. The specific process of the dynamic index adaptive update method is:
[0060] 1. The key value of the new data enters the dynamic learning index model to calculate the location of the data block where the new data should be located.
[0061] 2. Check whether there is an available position in the data block where the new data should be located calculated in step 1. If there is, search in the data block. Since the data in the data block is ordered, binary search can be used to find the position where the new data should be inserted. If there is no available position, record the data and add the data to the record array. The record content includes the block number and position subscript of the data block to be inserted, as well as the key (card number). The data block number is the value.
[0062] 3. After finding the position where the new data should be inserted, if the position is empty, insert it directly; if it is not empty, search for an empty position from the position to the left and right, and after finding it, select the direction shortest to the insertion position to shift one position, and finally insert the new data to the position where it should be inserted. Figure 7As shown, the position where the new data should be inserted is between Data 3 and Data 5. This position is not empty. Therefore, the distance to find an empty position to the left from this position is 2, and the distance to find an empty position to the right from this position is 1. Since 1 is less than 2, Data 5 is shifted one position to the right, and the new data 3 is inserted into the original position of Data 5. If the empty position distance is too far, exceeding the preset distance threshold (the distance threshold is half of the data block length, and each data block has its own distance threshold), this data can be added to the record array for data block splitting operation.
[0063] 4. After the insertion is completed, find the data records in the new data that have not been inserted, and perform data block splitting and model retraining.
[0064] First, apply for a new data block with the same size as the data block where the new data should have been inserted. Then, copy the data in the second half of the data block that should have been inserted into the new data block (i.e., the splitting operation), and perform operations on the two data blocks to restore them to the structure of the interval array (i.e., the data movement operation), complete the redistribution of the data blocks, and obtain the redistributed data blocks.
[0065] Each node model has a label of the node model type (neural network, linear model, B+ tree, etc.). After the new data is inserted, use the data block mounted on the node model for retraining of the node model. The training method is incremental training, that is, use the newly inserted new data as the training set to train the labeled node model. The label type of the node model does not change. The new data can fine-tune and correct the node model to improve its self-adaptability. Starting from the bottom layer, the node models of each layer are retrained asynchronously until the root node to obtain the retrained dynamic learning index model.
[0066] Embodiment
[0067] This embodiment is a method for constructing a dynamic index of the database of the bank card management system. The bank card data in the bank's bank card management system is <ID, bank card number, cardholder name, cardholder phone, cardholder address, credit rating, update time, belonging data block number>, as shown in Table 1.
[0068] Table 1
[0069]
[0070]
[0071] (The non-critical information is omitted in the table)
[0072] Extract the mapping of the bank card number and the block number of the belonging data block from Table 1, as shown in Table 2.
[0073] Table 2
[0074] Bank card number (the last digit replaces the card number) The block number of the data block 2 0 3 0 5 0 7 1 11 1 13 2 17 2 18 3 19 3 23 4 29 4 31 5 36 5
[0075] Then sort the two columns of data into<key,value> All key-value pairs in the format of , all key-value pairs constitute a global data set, and the global data set is used to perform B+ tree training to determine the levels and nodes of the dynamic index model.
[0076] The constructed B+ tree index is as follows Figure 7 As shown, there are two layers, the number of nodes is three, and the number of nodes in the second layer is 2:
[0077] Then, the node models are selected as the neural network model CDF, the linear regression model, and the B+ tree model, and the data in the format of <card number, data block number> is trained for the dynamic learning index model. The specific training process can refer to the above process.
[0078] The trained dynamic learning index model is as follows Figure 8 As shown, Figure 8 Each node in the dynamic learning index model has a node model label, denoted as MODELi.j:
[0079] For example, when searching by bank card number, the bank card management system inputs card number 11 into the dynamic learning index model, enters the root node MODEL1.1 for internal calculation, finds that it should enter MODEL2.1, and then finds data block 1 according to the internal calculation of MODEL2.1. Then, binary search is performed in data block 1 to find the required data.
[0080] Dynamic indexing in bank databases mainly accelerates the query process and can quickly find the data location. Compared with pure B+ tree indexing, since the node models of each layer adapt to the data structure of the data block mounted by the node model itself, the dynamic learning index model is superior in query speed and can achieve fast query and update of the bank card management system database.
[0081] Any matters not described in the present invention are applicable to the prior art.
Claims
1. A method for constructing a dynamic index of a database, the method comprising the following contents: Step 1. Build a global dataset Obtain a database, wherein a large number of tuples are stored in the database, and each tuple has the same storage format; Create a global data set, select the required attributes from the data information in the database, map according to the required attributes, find the data block where each row record in the mapping is located, form a key-value pair with the key value and the block number of the data block where the data is located, and use all the key-value pairs selected in the database as the global data set; Step 2. Build a dynamic learning index model First, the B+ tree regression tree training is performed on the global data set, and the trained B+ tree index is recorded for data update. At the same time, the number of layers of the B+ tree and the number of nodes in each layer of the entire global data set are determined according to the B+ tree index. The global data set is divided according to the number of layers and corresponding nodes to obtain the node data set corresponding to each node; An error threshold is set, and then, starting from the first layer, various node models other than the B+ tree are trained for each node in each layer. The node data set simultaneously trains various node models other than the B+ tree in a multi-threaded manner. For each node, there are results obtained from training various different node models, and the error rate of each node model is obtained. The node model with the smallest error rate is selected and compared with the error threshold. If it is less than the error threshold, the node model with the smallest error rate is selected as the node model of the current node, otherwise the node model of the current node selects the B+ tree; after determining the type of the node model of the current node, the node is model-identified, that is, what node model is used for this node is recorded; the various node models other than the B+ tree include at least a neural network model and a linear regression model; After the node model type of the nodes in the current layer is determined, the nodes in the next layer that the key value of the current layer is to enter are selected and then the node model of the next layer is trained. Similarly, a dynamic learning index model is obtained. The nodes in the dynamic learning index model are dynamic index nodes, and the construction of the dynamic index of the database is completed.
2. A method for constructing a dynamic index based on an OLAP database, the method comprising the following contents: Step 1. Build a global dataset An OLAP database is obtained, wherein a large number of tuples are stored in the OLAP database, and each tuple has the same storage format; Create a global data set, select the required attributes from the data information in the OLAP database, map according to the required attributes, find the data block where each row record in the mapping is located, form a key-value pair with the key value and the block number of the data block where the data is located, and use all the key-value pairs selected in the database as the global data set; Step 2. Build a dynamic learning index model First, the B+ tree regression tree training is performed on the global data set, and the trained B+ tree index is recorded for data update. At the same time, the number of layers of the B+ tree and the number of nodes in each layer of the entire global data set are determined according to the B+ tree index. The global data set is divided according to the number of layers and corresponding nodes to obtain the node data set corresponding to each node; An error threshold is set, and then, starting from the first layer, various node models other than the B+ tree are trained for each node in each layer. The node data set simultaneously trains various node models other than the B+ tree in a multi-threaded manner. For each node, there are results obtained from training various different node models, and the error rate of each node model is obtained. The node model with the smallest error rate is selected and compared with the error threshold. If it is less than the error threshold, the node model with the smallest error rate is selected as the node model of the current node, otherwise the node model of the current node selects the B+ tree; after determining the type of the node model of the current node, the node is model-identified, that is, what node model is used for this node is recorded; the various node models other than the B+ tree include at least a neural network model and a linear regression model; After the node model type of the nodes in the current layer is determined, the nodes in the next layer that the key value of the current layer is to enter are selected and then the node model of the next layer is trained. Similarly, a dynamic learning index model is obtained. The nodes in the dynamic learning index model are dynamic index nodes. At this point, the construction of the dynamic index of the OLAP database is completed.
3. The method for constructing a dynamic index based on an OLAP database according to claim 2, characterized in that: Confirm that the input of the dynamic learning index model is the global data set and the error threshold, and the output is the dynamic index. Define a temporary data two-dimensional array temp_data[][] to store the data in training. The two dimensions of this two-dimensional array represent the layer and node, respectively. Assign the entire global data set to temp_data[1][1]. This is the first model [1.1], that is, the node data set of the root node. Then, the B+ tree index is constructed and stored according to the global data set, and the B+ tree nodes are recorded. It also serves as a record of the data distribution in the global data set, determines the number of layers and nodes, and the node data set of each node in each layer, with a total of S layers; From the 1st layer to the Sth layer, loop from the 1st node to the last node of each layer, and the content of the loop is: Use the node data set temp_data[i][j] of this node to train the neural network model and linear regression model; Obtain the errors of the neural network model and the linear regression model respectively, compare them, and store the smallest error value in err. The error calculation uses the mean square error; Compare the error value err with the set error threshold. If the node with the smallest error in the neural network model and the linear regression model still performs poorly, use the B+ tree node and copy and mark the previously trained B+ tree node. The trained data in the node data set of the current node in the current layer will be used to select child nodes according to the current node model. The selected data is used to train the node models of each child node in the next layer. After the cycle is completed, the dynamic learning index model is trained and the dynamic index trained index is output. The nodes of the dynamic index are marked with the type of node model finally selected by the node.
4. The method for constructing a dynamic index based on an OLAP database according to claim 2, characterized in that: The OLAP database is used in the bank card management system. The bank card data in the bank's bank card management system is <ID, bank card number, cardholder name, cardholder phone number, cardholder address, credit rating, update time, data block number to which it belongs>. The required attributes for research are extracted from it, and a mapping relationship is established between this attribute and the block number of the data block. A key-value pair is composed of the key value and the block number of the data block where the data is located, and all the key-value pairs selected from the database are used as the global data set.
5. A dynamic index adaptive updating method based on OLAP database, characterized in that: The dynamic index of the OLAP database is obtained by using the construction method described in claim 2, and the model is maintained and updated by using the update mechanism of the OLAP database. The distribution of data in the global data set on the disk block is an interval array, that is, there are empty positions before and after each piece of data; then the number of positions on the data disk that can accommodate new data is the same as the number of data in the global data set, and this number is called the threshold here, that is, the upper limit for accommodating new data; if the number of new data exceeds this threshold, data redistribution is required. After redistribution, the data block still resumes the form of an interval array, and at this time, the dynamic index needs to be retrained; New data in the data block is judged through the time tag of the data. Each node in the dynamic index of the OLAP database has a node model tag. The underlying node model is retrained with these new data, and then the node model of the upper layer is retrained, and so on, to achieve the adaptive update of the dynamic index.
6. The method for adaptively updating a dynamic index based on an OLAP database according to claim 5, characterized in that: The process of the specific dynamic index adaptive update method is as follows: 1) The key value of the new data enters the dynamic learning index model to calculate the position of the data block where the new data should be located; 2) Query whether there is an available position at the position of the data block where the new data calculated in step 1) should be located. If there is, search in the data block. Since the data in the data block is ordered, the binary search method is used to find the position where the new data should be inserted; if not, record the data, add the data to the record array, and the record content includes the block number and position subscript of the data block where it should be inserted, as well as the key value key; 3) After finding the position where the new data should be inserted, if the position is empty, insert directly; if not, search for empty positions to the left and right from this position. After finding, select the direction with the shortest distance from the insertion position and shift one position, and finally insert the new data into the position where it should be inserted; if the distance of the empty position is too far, exceeding the preset distance threshold, add this data to the record array and perform the data block splitting operation, and the distance threshold is half of the data block length; 4) After the insertion is completed, find the data records in the new data that have not been inserted, and perform data block splitting and model retraining; First, apply for a new data block, and the size of the new data block is the same as the data block where the new data should have been inserted. Then copy the data in the second half of the data block where it should have been inserted to the new data block and perform the splitting operation; then perform the data movement operation on the two data blocks to make the two data blocks resume the structure of the interval array, complete the data block redistribution, and obtain the redistributed data block; Each node model is marked with the node model type. After new data is inserted, the node model is retrained using the data block mounted on the node model. The training method is incremental training, that is, the newly inserted new data is used as the training set to train the marked node model. The marking type of the node model does not change. The new data can be used to fine-tune and correct the model to improve its self-adaptation ability. Starting from the bottom layer, the node models of each layer are asynchronously retrained until the root node, and the retrained dynamic learning index model is obtained.
7. A computer-readable storage medium storing a computer program, wherein the computer program is suitable for executing the method for constructing a database dynamic index according to claims 1-4 or the method for adaptively updating a dynamic index based on an OLAP database according to claims 5-6 when loaded by a computer.
Citation Information
Patent Citations
Field-invariant quantitative magnetic-resonance signatures
CN108027412A
Extensible learning indexing method and system
CN111126625A
Cited By
Fine-grained data permission searching method based on permission atlas and dynamic index
CN121256763A