A method and device for intelligent data partitioning
By obtaining load information, dividing data blocks and running the space splitting algorithm in parallel in the database, combined with the hypergraph partitioning algorithm to generate target partitions, it solves the problem that existing partitioning algorithms cannot meet the requirements for efficiency and flexibility, and achieves database performance optimization and cross-platform optimization. Partition access is reduced.
Patent Information
- Application Number
- CN202311715004.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-12-13
AI Technical Summary
Existing partitioning algorithms cannot meet the needs of modern database systems for efficiency and flexibility, and have performance bottlenecks that prevent them from effectively processing massive data and changing application requirements.
Divide multiple data block information by obtaining load information, separate column groups of different importance according to important values and store them in the first-level partition, and run the space splitting algorithm in parallel in each first-level partition to obtain the second-level partition, using hypergraph segmentation The algorithm generates target partitions and introduces the concept of space splitting to dynamically adjust the partitioning strategy to minimize cross-partition access.
It achieves the minimum storage of data block information, improves the flexibility and adaptability of partitioning strategies, meets the needs of modern database systems for efficiency and flexibility, solves the performance bottleneck problem in traditional partitioning algorithms, and provides database performance optimization new ideas.
Smart Images

Figure CN117874076B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing technology, and in particular, relates to a method and device for intelligent data partitioning. Background Art
[0002] In the related technologies, optimizing the physical layout and logical partitioning of the database plays a significant role in improving query processing performance. Currently, there are a lot of studies and algorithms on data partitioning. However, with the rapid growth of data volume and the huge changes in application scenarios, the demand for partitioning algorithms in database systems is also increasing. However, the current partitioning algorithms can no longer meet the ever-changing application requirements and the processing requirements of massive data. Therefore, how to better implement the partitioning algorithm has become an urgent problem to be solved. Summary of the invention
[0003] In view of the above deficiencies in the prior art, the purpose of the invention is to provide a method, device and related equipment for intelligent data partitioning, which can not only meet the requirements of modern database systems for efficiency and flexibility, but also effectively solve the performance bottleneck problems existing in traditional partitioning algorithms, and provide new ideas and methods for performance optimization of database systems.
[0004] According to a first aspect of the present invention, a method for intelligent data partitioning is proposed, comprising: obtaining a plurality of data block information divided by load information; separating the plurality of data block information according to their importance values, and determining column groups of different importance to store in a plurality of first-level partitions; running a spatial splitting algorithm in parallel in each of the first-level partitions to obtain a plurality of second-level partitions corresponding to each of the first-level partitions; and using a hypergraph partitioning algorithm to generate target partitions for each of the second-level partitions after determining the number of subgraphs in each of the second-level partitions.
[0005] Further, the plurality of data block information includes hot data block information, warm data block information and cold data block information, wherein, according to importance values of the plurality of data block information, the plurality of data block information is separated, and column groups of different importance are determined to be stored in a plurality of primary partitions, including:
[0006] according to Determine the spatial importance of all attribute columns in the table, where Q represents the workload set and T i .max represents the maximum value of table T on dimension i, T i .min represents the minimum value of table T on dimension i, q i .max indicates query q i The maximum value of a range query on dimension i of table T, q i .min means query q iThe minimum value of the range query on dimension i of table T. T.tuples represents the tuples in table T. i .w indicates load q i weights; arranging all attribute columns in the table in descending order according to their spatial importance values; allocating the attribute columns in descending order to the multiple first-level partitions to determine column groups of different importance and store them in the multiple first-level partitions.
[0007] Furthermore, the space splitting algorithm is implemented in the following manner: when it is determined that the number of buckets is 0, a first target bucket is created, and the current query statement is stored in the target bucket; when it is determined that the number of buckets is greater than 0 and there is a second target bucket, the load and query statement contained in the second target bucket are intersected in space; when it is determined that the number of buckets is greater than 0 and there is no second target bucket, the first target bucket is created, and the current statement is stored in the target bucket; when it is determined that the first target bucket and the second target bucket have the same query statement, the first target bucket and the second target bucket are merged.
[0008] Furthermore, a spatial splitting algorithm is run in parallel in each of the first-level partitions to obtain multiple second-level partitions corresponding to each of the first-level partitions, including: obtaining multiple query statements, wherein the multiple query statements are different; a spatial graph surrounded by the multiple query statements corresponds to the space that the multiple query statements need to access at the horizontal level; and based on the spatial intersection technology, multiple second-level partitions corresponding to each of the first-level partitions are obtained.
[0009] Furthermore, determining the number of subgraphs in each of the secondary partitions includes: determining the size of each of the secondary partitions; and determining the number of subgraphs in each of the secondary partitions according to the size of each of the secondary partitions and a preset size of each of the secondary partitions.
[0010] Furthermore, the number of subgraphs in each of the secondary partitions is determined, which also includes: determining an access attribute set for each query statement; constructing a hypergraph in each of the secondary partitions to obtain each of the secondary partitions after the hypergraph is constructed.
[0011] Furthermore, the METIS algorithm is used to divide the constructed hypergraph of each secondary partition into non-overlapping partitions to obtain the target partition.
[0012] According to a second aspect of the present invention, a device for realizing intelligent data partitioning is proposed, and the device comprises: a first acquisition module for acquiring multiple data block information divided by load information; a determination module for separating the multiple data block information according to their importance values, and determining column groups of different importance to store in multiple first-level partitions; a second acquisition module for running a spatial splitting algorithm in parallel in each of the first-level partitions to obtain multiple second-level partitions corresponding to each of the first-level partitions; and a generation module for generating target partitions for each of the second-level partitions by using a hypergraph partitioning algorithm after determining the number of subgraphs in each of the second-level partitions.
[0013] According to a third aspect of the present invention, an electronic device is proposed, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the methods described in the first aspect of the present invention.
[0014] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods according to the first aspect of the present invention.
[0015] The beneficial effects of the present invention are as follows:
[0016] The method and device described in the present invention obtain multiple data block information divided by load information, separate the multiple data block information according to the importance values of the multiple data block information, determine the column groups of different importance and store them in multiple first-level partitions, run the space splitting algorithm in parallel in each first-level partition, obtain multiple second-level partitions corresponding to each first-level partition, and use the hypergraph partitioning algorithm to generate target partitions for each second-level partition when the number of subgraphs in each second-level partition is determined. This method can minimize storage by separating data block information, and introduces the concept of space splitting, so that the partitioning strategy is more flexible and can be dynamically adjusted according to the actual situation of the data, and by using the hypergraph partitioning algorithm to simulate the vertical partitioning process, the number of cross-partition accesses is minimized. This method can not only meet the requirements of modern database systems for efficiency and flexibility, but also effectively solve the performance bottleneck problem existing in traditional partitioning algorithms, and provide new ideas and methods for performance optimization of database systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.
[0018] Figure 1 It is a hardware structure block diagram of a terminal device of a method for intelligent data partitioning according to an embodiment of the present invention;
[0019] Figure 2 is a flow chart of a method for intelligent data partitioning according to an embodiment of the present invention;
[0020] Figure 3 is a flow chart of a method for intelligent data partitioning according to a specific embodiment of the present invention;
[0021] Figure 4 is a schematic diagram of a method for intelligent data partitioning according to an embodiment of the present invention;
[0022] Figure 5 is another schematic diagram of a method for intelligent data partitioning according to an embodiment of the present invention;
[0023] Figure 6 is another schematic diagram of the method for intelligent data partitioning according to an embodiment of the present invention;
[0024] Figure 7 It is a structural block diagram of a device for intelligent data partitioning according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.
[0026] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.
[0027] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the orientation or position relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0028] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.
[0029] According to one aspect of an embodiment of the present invention, a method for intelligent data partitioning is provided, and the method for intelligent data partitioning can be executed in a terminal device or a similar computing device. Taking running on a terminal device as an example, Figure 1 FIG. 1 is a hardware structure block diagram of an electronic device for a method for intelligent data partitioning according to an embodiment of the present invention. Figure 1 As shown, the terminal device may include one or more ( Figure 1 Only one is shown in the figure) processor 102 (processor 102 may include but is not limited to a microprocessor (Microprocessor Unit, referred to as MPU) or a programmable logic device (Programmable logic device, referred to as PLD)) and a memory 104 for storing data. In an exemplary embodiment, the terminal device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the above terminal device. Figure 1 More or fewer components as shown, or with Figure 1 Equivalent functions or comparisons shown Figure 1 A different configuration with more features is shown.
[0030] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the level determination method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal device via a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0031] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the switching device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0032] In the related art, optimizing the physical layout and logical partitioning of the database plays a significant role in improving query processing performance. Current intelligent storage strategies are usually divided into two main steps to decide how to store data in memory / disk. First, through optimization algorithms or heuristic rules, determine which columns should constitute a column group, or which tuples should constitute a block, that is, database partitioning. The goal of this step is to reduce the data span range within each partition block so that the required data can be located faster during query, thereby improving data access efficiency; secondly, within each block, we need to determine the appropriate data layout strategy, such as row storage (N-Array Storage Model, NSM) or column storage (DecompositionStorage Model, DSM). The purpose of this strategy is to further optimize the storage and access methods of data to achieve more efficient data processing.
[0033] The goal of database partitioning is to reduce the amount of data that needs to be processed by the query, thereby improving the efficiency of query execution. This requires carefully setting the amount of data contained in each partition to efficiently access the data. However, overly detailed partitioning methods, such as treating each tuple or single column of data as a partition and maintaining the corresponding metadata, can achieve accurate data skipping, but it also increases a lot of metadata maintenance costs and disk I / O overhead. Therefore, when designing a partitioning algorithm, it is necessary to reasonably select the size of the partition granularity based on the actual situation of the system to achieve the best query performance and storage efficiency.
[0034] Database logical partitioning can be divided into horizontal partitioning, vertical partitioning and hybrid partitioning. Horizontal partitioning can simplify database management operations. Traditional horizontal partitioning strategies include range partitioning and hash partitioning. Vertical partitioning divides the table into multiple column groups. Each partition only contains part of the columns of the table. When the columns involved in the query are all in the same partition, access to other partitions can be avoided, thereby improving query efficiency. When designing a vertical partitioning scheme, it is necessary to weigh the access cost and the row reconstruction overhead of the target workload. Traditional vertical partitioning strategies include hill climbing algorithms and affinity matrix-based segmentation strategies. Hybrid partitioning is a combination of horizontal partitioning and vertical partitioning. It can make better use of the characteristics of the load to provide more refined and load-aware fine-grained partitioning.
[0035] Traditional partitioning methods cannot give the most effective partitioning method according to the actual workload. To address this problem, Sun et al. proposed a workload-driven, skip-based fine-grained horizontal partitioning framework SOP in 2014. The core idea of SOP is to use frequent item set mining technology to mine representative filters from the workload as features to guide the query to skip data blocks, thereby obtaining the optimal partitioning scheme based on the workload query log. Hyrise has launched a vertically partitioned database system that can pre-calculate the cost values of various partitioning strategies (i.e., divide the table into different combinations of column groups) based on the access method of the columns in the table, using the number of cache misses as a measurement indicator, and select the partitioning plan that makes the cost function perform best and implement it on the disk. For analytical query statements, the system prefers to use narrow partitioning; when faced with loads that frequently perform database insertion and update operations, Hyrise can automatically adjust to wide partitioning. With the rapid development of artificial intelligence technology, more and more research has been conducted on the use of machine learning algorithms to guide data partitioning. Yang et al. proposed a fine-grained horizontal partitioning framework based on reinforcement learning called the query data routing tree (QD-tree), and designed an algorithm based on greedy algorithms and deep reinforcement learning to construct a routing tree for query data.
[0036] Coarse-grained partitioning causes the database to scan unnecessary data, while fine-grained partitioning results in a smaller number of elements in each partition block, which negatively affects I / O performance and brings a lot of reconstruction overhead. Jigsaw introduces a new partitioning strategy that creates partitions of arbitrary shapes and calls it "irregular partitioning". This strategy partitions the table vertically based on the projection elements in the SELECT statement in the query statement, guides horizontal partitioning based on the attributes in the WHERE statement, and calculates the cost overhead under different partitioning strategies. This process will continue to iterate until the cost function no longer increases. Finally, these sub-blocks are aggregated according to the objective function into the final partition whose size satisfies [minSize, 2*minSize).
[0037] Therefore, although there are a lot of research and algorithms on data partitioning, with the rapid growth of data volume and the huge changes in application scenarios, the demand for partitioning algorithms in database systems is also increasing. However, the current partitioning algorithms can no longer meet the ever-changing application requirements and the processing requirements of massive data. Therefore, how to better implement partitioning algorithms has become an urgent problem to be solved.
[0038] To this end, the present application proposes a method, device and electronic device for intelligent data partitioning.
[0039] In this embodiment, a method for intelligent data partitioning is provided, which can be applied to the above-mentioned terminal device or configured in a server. The terminal device can be a PC or a mobile terminal. This embodiment of the application does not limit this. Figure 2 is a flow chart of a method for intelligent data partitioning according to an embodiment of the present invention, the flow chart comprising the following steps:
[0040] S210, obtaining information of multiple data blocks divided by load information.
[0041] In an embodiment of the present invention, the plurality of data block information includes hot data block information, warm data block information and cold data block information.
[0042] Among them, the data characteristics of hot data block information are high access frequency and strong business importance. This type of data can be stored on high-performance, low-latency storage devices, such as SSD solid-state drives, memory, etc.; the data of warm data block information has a lower access frequency than the data in hot data information, so this type of data can be stored on low-cost, large-capacity storage devices, such as disk arrays; the data characteristics of cold data block information are that they do not require frequent access and processing, so this type of data can be stored on lower-cost, larger-capacity storage devices, such as tape libraries.
[0043] That is to say, dynamic adjustments are made based on factors such as data value density, access frequency, usage method, and timeliness to divide the load information into hot data block information, warm data block information, and cold data block information, and then multiple data block information divided by the load information can be obtained.
[0044] S220 , separating the plurality of data block information according to importance values of the plurality of data block information, and determining column groups of different importance to store in a plurality of first-level partitions.
[0045] In an embodiment of the present invention, after obtaining multiple data information, the importance values of multiple data block information can be determined, and then the multiple data information can be separated according to the importance values of the multiple data block information to determine column groups of different importance and store them in multiple first-level partitions. For specific implementation methods, please refer to the subsequent embodiments.
[0046] That is to say, the present invention separates multiple data block information by their importance values, that is, performs a coarse-grained processing partition on the table, thereby saving a lot of storage costs.
[0047] S230, running the space splitting algorithm in parallel in each first-level partition to obtain multiple second-level partitions corresponding to each first-level partition.
[0048] In an embodiment of the present invention, when it is determined that column groups of different importance are stored in multiple first-level partitions, a space splitting algorithm may be determined first, and then the space splitting algorithm may be run in parallel in each first-level partition to obtain multiple second-level partitions corresponding to each first-level partition. The specific implementation process may refer to the subsequent embodiments.
[0049] S240, after determining the number of subgraphs in each secondary partition, generate target partitions for each secondary partition using a hypergraph partitioning algorithm.
[0050] In an embodiment of the present invention, when multiple secondary partitions corresponding to a primary partition are obtained, the number of subgraphs in each secondary partition can be determined, and then a hypergraph partitioning algorithm is called to generate a target partition from each secondary partition.
[0051] The hypergraph segmentation algorithm may adopt the METIS algorithm. The specific implementation process may refer to the subsequent embodiments.
[0052] According to the method of data intelligent partitioning in the embodiments of the present invention, multiple data block information divided according to load information is obtained. According to the importance values of the multiple data block information, the multiple data block information is separated, and column groups of different importance levels are determined and stored in multiple primary partitions. The space splitting algorithm is run in parallel within each primary partition to obtain multiple secondary partitions corresponding to each primary partition. In the case of determining the number of subgraphs within each secondary partition, the hypergraph partitioning algorithm is used to generate target partitions for each secondary partition. This method can minimize storage by separating the data block information, and by introducing the concept of space splitting, the partitioning strategy is made more flexible, enabling dynamic adjustment according to the actual situation of the data. In addition, by using the hypergraph partitioning algorithm to simulate the vertical partitioning process, the number of cross-partition accesses is minimized to the greatest extent. This method can not only meet the requirements of modern database systems for efficiency and flexibility, but also effectively solve the performance bottleneck problems existing in traditional partitioning algorithms, providing new ideas and methods for the performance optimization of database systems.
[0053] For those in the art to more easily understand the present invention, Figure 3 is a flowchart of the method of data intelligent partitioning according to specific embodiments of the present invention. The method includes the following steps:
[0054] S310, obtain multiple data block information divided according to load information.
[0055] That is to say, the load information can be analyzed first so that the load information is divided into multiple data block information. Among them, the embodiments of S310 of the present invention can refer to the embodiments of S210 above, and the present invention will not elaborate here.
[0056] S320, according to the importance values of the multiple data block information, separate the multiple data block information, and determine column groups of different importance levels and store them in multiple primary partitions.
[0057] In the embodiments of the present invention, in the case where the multiple data block information includes hot data block information, warm data block information, and cold data block information, the importance values and importance levels of the multiple data block information can be determined first, and then the hot data block information, warm data block information, and cold data block information are separated, and column groups of different importance levels are stored in multiple primary partitions.
[0058] For example, the query statement q1 is: SELECT A, B FROM T WHERE 2 < A < 5 AND 3 < B < 7 AND 0 < C < 5; the specific query process when the database executes q1 is: first find the tuple ids that satisfy 2 < A < 5 and 3 < B < 7 and 0 < C < 5, and then retrieve the attribute columns A and B of these id rows;
[0059] and then according to Determine the spatial importance of all attribute columns in the table, where Q represents the workload set and T i .max represents the maximum value of table T in dimension i.
[0060] T i .min represents the minimum value of table T on dimension i, q i .max indicates query q i The maximum value of a range query on dimension i of table T, q i .min means query q i The minimum value of the range query on dimension i of table T. T.tuples represents the tuples in table T. i .w indicates load q i The weight of
[0061]
[0062]
[0063] Then, all attribute columns in the table are sorted in descending order according to their spatial importance values, and the attribute columns sorted in descending order are distributed to multiple first-level partitions to determine column groups of different importance and store them in multiple first-level partitions.
[0064] For example, multiple first-level partitions include partition A, partition B, and partition C. Each partition contains attribute columns sorted in descending order by importance value. For example, partition A contains 0%-10% of attribute columns in descending order, partition B contains 10%-50% of attribute columns in descending order, and partition C contains 50%-100% of attribute columns in descending order.
[0065] In the embodiment of the present invention, the calculation formula of the importance value can help enterprises distinguish between hot and cold data in advance, thereby minimizing storage costs. This formula deeply understands the access pattern of the application and evaluates the importance of the data by tracking and parsing the load information. This evaluation not only considers a single access, but also can mine the true value of the data from the long-term access pattern.
[0066] S330, running the space splitting algorithm in parallel in each first-level partition to obtain multiple second-level partitions corresponding to each first-level partition.
[0067] In an embodiment of the present invention, multiple query statements can be obtained, wherein the multiple query statements are different; the spatial graph enclosed by the multiple query statements corresponds to the space that the multiple query statements need to access at the horizontal level; based on the spatial intersection technology, multiple secondary partitions corresponding to each primary partition are obtained.
[0068] Specifically, first, the spatial graphs corresponding to each query statement are intersected to obtain an intersection area. Then, the union of all intersection areas is used as the final secondary partition. In this way, each secondary partition contains all the data that needs to be accessed by multiple query statements. In this way, data redundancy between query statements can be effectively reduced and query performance can be improved. At the same time, more information can be provided to the database optimizer to select the best execution plan.
[0069] For example, Figure 4 As shown, Figure 4 In the two-dimensional coordinate system, different colors represent different query statements (i.e., each ellipse represents a query statement), corresponding to the query {q0, q1.....q7}, and the spatial graphs surrounded by these query statements correspond to the space that the corresponding query statements need to access on the horizontal level. According to the concept of spatial intersection, two n-dimensional graphs have an intersection if and only if they satisfy Right now Figure 4 The middle space Ω is divided into two related secondary partitions and one irrelevant partition, and P1.Q = {q0, q2, q3, q4, q5, q6}, P2.Q = {q1, q7}, where P1 represents the first secondary partition, P2 represents the second secondary partition, and Q represents the query load set.
[0070] Among them, in an embodiment of the present invention, the space splitting algorithm is implemented in the following manner: when it is judged that the number of buckets is 0, a first target bucket is created, and the current query statement is stored in the target bucket; when it is judged that the number of buckets is greater than 0 and there is a second target bucket, the load and query statement contained in the second target bucket are intersected in space; when it is judged that the number of buckets is greater than 0 and there is no second target bucket, a first target bucket is created, and the current statement is stored in the target bucket; when it is determined that the first target bucket and the second target bucket have the same query statement, the first target bucket and the second target bucket are merged.
[0071] Among them, in the initial state, the number of buckets is 0.
[0072] It can be seen that the space splitting algorithm can process query statements by creating buckets and merging buckets to find all overlapping areas in the space.
[0073] In the embodiment of the present invention, a space splitting algorithm is designed to use load information to find the best partition boundary in the hyperdimensional space. This can effectively solve the "rectangular partition" problem existing in existing research. By introducing fine-grained irregular partitions, we can divide the data space more flexibly and accurately, so that each partition can better adapt to its specific query load.
[0074] S340: Determine an access attribute set for each query statement.
[0075] For example, for each query statement, the union of the attribute columns after Select and Where can be taken as the access attribute set of the query statement, thus realizing load analysis.
[0076] S350, construct a hypergraph in each secondary partition to obtain each secondary partition after the hypergraph is constructed.
[0077] For example, a hypergraph is constructed in each secondary partition, and each attribute column is used as a node of the hypergraph. If some attributes are accessed simultaneously by a query statement, a complete graph is constructed between these attribute nodes, and the weight of each hyperedge is sql.w (where sql.w represents the weight of the query statement).
[0078] In the embodiment of the present invention, in the case of designing a space splitting algorithm, by constructing a hypergraph, the load-aware partitioning problem of the horizontal and vertical directions at the table level in the hyperdimensional space is further explored. By introducing fine-grained irregular partitioning, the load characteristics in these two directions can be considered at the same time, so as to design a better partitioning strategy. This method makes full use of the load access pattern information, makes the partitioning strategy more adaptable to the query load information, and further improves the performance of the database.
[0079] S360, after determining the number of subgraphs in each secondary partition, a hypergraph partitioning algorithm is used to generate target partitions for each secondary partition.
[0080] Specifically, many current systems use fixed-size data blocks for data skipping during storage. For example, IBM BD2 BLU uses blocks of 1,000 tuples, and Google's PowerDill recommends using 50,000 tuples. Shark queries data in HDFS blocks, and the default size of each block is 128M. Therefore, the present invention follows the above convention and strictly limits the capacity of each final partition (i.e., the target partition) to strictly meet the maximum and minimum values.
[0081] Among them, in an embodiment of the present invention, the size of each secondary partition can be determined; based on the size of each secondary partition and the preset size of each secondary partition, the number of sub-graphs in each secondary partition is determined, and then when the number of sub-graphs in each secondary partition is determined, a hypergraph partitioning algorithm is used to generate target partitions for each secondary partition.
[0082] For example, the final number of hypergraphs in each secondary partition is determined according to the number of tuples in each secondary partition and the maximum set value corresponding to each secondary partition, such as K i =P i / maxSize, that is, the secondary partition P iEventually, K i Sub-pictures.
[0083] In an embodiment of the present invention, when the number of subgraphs in each secondary partition is determined, the METIS algorithm is used to divide the constructed hypergraph of each secondary partition into non-overlapping partitions to obtain the target partition, so as to minimize the total cost of cutting edges and ensure that the number of tuples in each final partition remains balanced. This step can not only minimize the number of cross-partition queries, but also balance the amount of data between different partitions. And the present invention can minimize cross-partition access transactions and minimize access to irrelevant tuples by adopting a hypergraph partitioning algorithm, thereby improving resource consumption during query.
[0084] Therefore, the present invention adopts the idea of multi-stage partitioning, combining the hypergraph partitioning technology with the field of database vertical partitioning. It can dynamically adjust the partitioning strategy according to the actual query load, enhance the adaptability of the partitioning strategy to the query load information, and thus achieve the goal of improving the database processing efficiency.
[0085] In one embodiment of the present invention, the present invention is not only applicable to traditional stand-alone relational databases, but also to distributed scenarios where the query load includes range queries. When faced with massive data scenarios, the present invention can enhance the data skipping capability during querying, thereby reducing the overall cost of consumed computing resources and disk I / O resources. This innovative algorithm can not only improve query efficiency, but also effectively reduce the consumption of hardware resources, saving a lot of storage and computing costs for enterprises.
[0086] In a specific embodiment of the present invention, Figure 5 As shown, the load information can be obtained first, and then the load information is analyzed to obtain multiple data block information, namely hot data block information, warm data block information and cold data block information, and then the hot data block information, warm data block information and cold data block information are separated, and the column ancestors of different importance are stored in the corresponding first-level partitions, for example, stored in D0, D1 and D2 respectively, and then the hyperdimensional space splitting algorithm is run in parallel in each first-level partition to obtain several second-level partitions, for example, D1 (first-level partition) corresponds to p0 (secondary partition) and pn (secondary partition), and then the table data information is input in each second-level partition to determine the size of each second-level partition, and the number of subgraphs formed by each second-level partition is determined according to the size of each second-level partition and the preset size of each second-level partition set by the system, and finally the hypergraph segmentation algorithm is called to generate the final partition, that is, the target partition. The present invention optimizes the algorithm performance of hybrid partitions from multiple angles by combining multiple technologies such as hyperdimensional space segmentation technology, machine learning algorithm and heuristic rules. In the era of big data, distributed database systems gradually replace stand-alone versions to achieve high availability and high responsiveness of data processing purposes.
[0087] In a specific embodiment of the present invention, an example of hypergraph construction is provided to enable readers to have a clearer understanding of the construction of the hypergraph:
[0088] Example 1: Assume that table T has six columns {a0, a1, a2, a3, a4, a5}, and the range of each column satisfies 0<=range<=10; the specific query statement is as follows:
[0089] <![CDATA[q1:SELECT a1,a2FROM T WHERE 2<a1<5 AND 3<a2<7;w=5]]> <![CDATA[q2:SELECT a3,a4FROM T WHERE 5<a3<10 AND 3<a4<6;w=1]]> <![CDATA[q3:SELECT a5,a4FROM T WHERE 1<a5<3;w=3]]> <![CDATA[q4:SELECT a1,a0,a3FROM T WHERE 1<a5<3;w=4]]>
[0090] Table 1 - Query load example
[0091] Then, according to the load in Table 1, the present invention will first analyze the common access attribute set of each load statement, and then construct the following Figure 6 The hypergraph shown.
[0092] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0093] Figure 7 is a structural block diagram of a device for intelligent data partitioning according to an embodiment of the present invention; Figure 7 As shown, including:
[0094] A first acquisition module 710 is used to acquire information of a plurality of data blocks divided by the load information;
[0095] A first determination module 720 is used to separate the plurality of data block information according to importance values of the plurality of data block information, and determine column groups of different importance to store in a plurality of primary partitions;
[0096] The second acquisition module 730 is used to run the space splitting algorithm in parallel in each of the first-level partitions to obtain multiple second-level partitions corresponding to each of the first-level partitions;
[0097] The generating module 740 is used to distinguish each of the secondary partitions by generating targets by using a hypergraph partitioning algorithm when the number of subgraphs in each of the secondary partitions is determined.
[0098] According to the device for intelligent data partitioning of the embodiment of the present invention, multiple data block information divided by load information is obtained, and multiple data block information is separated according to the importance values of the multiple data block information, and column groups of different importance are determined to be stored in multiple first-level partitions, and the space splitting algorithm is run in parallel in each first-level partition to obtain multiple second-level partitions corresponding to each first-level partition. When the number of subgraphs in each second-level partition is determined, the hypergraph partitioning algorithm is used to generate target partitions for each second-level partition. Thus, by separating the data block information, storage can be minimized, and the concept of space splitting is introduced to make the partitioning strategy more flexible and can be dynamically adjusted according to the actual situation of the data, and by using the hypergraph partitioning algorithm to simulate the vertical partitioning process, the number of cross-partition accesses is minimized. It can not only meet the requirements of modern database systems for efficiency and flexibility, but also effectively solve the performance bottleneck problem existing in traditional partitioning algorithms, and provide new ideas and methods for performance optimization of database systems.
[0099] Optionally, the plurality of data block information includes hot data block information, warm data block information and cold data block information, and the determination module 720 is specifically configured to: Determine the spatial importance of all attribute columns in the table, where Q represents the workload set and T i .max represents the maximum value of table T on dimension i, T i .min represents the minimum value of table T on dimension i, q i .max indicates query q i The maximum value of a range query on dimension i of table T, q i .min means query q i The minimum value of the range query on dimension i of table T. T.tuples represents the tuples in table T. i .w indicates load q i weights; arranging all attribute columns in the table in descending order according to their spatial importance values; allocating the attribute columns in descending order to the multiple first-level partitions to determine column groups of different importance and store them in the multiple first-level partitions.
[0100] Optionally, the space splitting algorithm is implemented in the following manner: when it is determined that the number of buckets is 0, a first target bucket is created, and the current query statement is stored in the target bucket; when it is determined that the number of buckets is greater than 0 and there is a second target bucket, the load and query statement contained in the second target bucket are intersected in space; when it is determined that the number of buckets is greater than 0 and there is no second target bucket, the first target bucket is created, and the current statement is stored in the target bucket; when it is determined that the first target bucket and the second target bucket have the same query statement, the first target bucket and the second target bucket are merged.
[0101] Optionally, the second acquisition module 730 is specifically used to obtain multiple query statements, wherein the multiple query statements are different; the spatial graph enclosed by the multiple query statements corresponds to the space that the multiple query statements need to access at the horizontal level; and based on the spatial intersection technology, multiple secondary partitions corresponding to each of the first-level partitions are obtained.
[0102] Optionally, the generating module 740 is specifically configured to determine the size of each of the secondary partitions; and determine the number of subgraphs in each of the secondary partitions according to the size of each of the secondary partitions and a preset size of each of the secondary partitions.
[0103] Optionally, the device further includes: a second determination module, used to determine the access attribute set of each query statement; and a construction module, used to construct a hypergraph in each of the secondary partitions to obtain each of the secondary partitions after the hypergraph is constructed.
[0104] Optionally, the generating module 740 is specifically configured to divide the constructed hypergraph of each secondary partition into non-overlapping partitions by using a METIS algorithm to obtain a target partition.
[0105] The present invention proposes a computer-readable storage medium having a computer program stored thereon, wherein the computer program can be loaded and executed by a processor according to the method for intelligent data partitioning described in the first aspect.
[0106] The applicant of the present invention has made a detailed explanation and description of the implementation examples of the present invention in conjunction with the drawings in the specification. However, those skilled in the art should understand that the above implementation examples are only preferred implementation schemes of the present invention, and the detailed description is only to help readers better understand the spirit of the present invention, but not to limit the scope of protection of the present invention. On the contrary, any improvements or modifications based on the inventive spirit of the present invention should fall within the scope of protection of the present invention.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above embodiments, or replace some of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or replacements that can be easily thought of by those skilled in the art within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for intelligent data partitioning, characterized in that: include: S1, obtaining information of multiple data blocks divided by load information; S2, separating the plurality of data block information according to importance values of the plurality of data block information, and determining column groups of different importance to store in a plurality of first-level partitions; S3, running the space splitting algorithm in parallel in each of the first-level partitions to obtain multiple second-level partitions corresponding to each of the first-level partitions; S4, when the number of subgraphs in each of the secondary partitions is determined, a hypergraph partitioning algorithm is used to generate a target partition from each of the secondary partitions; The spatial splitting algorithm is implemented in the following manner: when it is determined that the number of buckets is 0, a first target bucket is created and the current query statement is stored in the target bucket; when it is determined that the number of buckets is greater than 0 and there is a second target bucket, the load and query statement contained in the second target bucket are intersected in space; when it is determined that the number of buckets is greater than 0 and there is no second target bucket, the first target bucket is created and the current query statement is stored in the target bucket; when it is determined that the first target bucket and the second target bucket have the same query statement, the first target bucket and the second target bucket are merged; Among them, a space splitting algorithm is run in parallel in each of the first-level partitions to obtain multiple second-level partitions corresponding to each of the first-level partitions, including: obtaining multiple query statements, wherein the multiple query statements are different; a spatial graph surrounded by the multiple query statements corresponds to the space that the multiple query statements need to access at the horizontal level; and based on the spatial intersection technology, multiple second-level partitions corresponding to each of the first-level partitions are obtained.
2. The method for intelligent data partitioning according to claim 1, characterized in that: The plurality of data block information includes hot data block information, warm data block information and cold data block information, wherein, according to importance values of the plurality of data block information, the plurality of data block information are separated, and column groups of different importance are determined to be stored in a plurality of primary partitions, including: according to Determine the spatial importance of all attribute columns in the table, where Q represents the workload set and T i .max represents the maximum value of table T on dimension i, T i .min represents the minimum value of table T on dimension i, q i .max indicates query q i The maximum value of a range query on dimension i of table T, q i .min means query q i The minimum value of the range query on dimension i of table T. T.tuples represents the tuples in table T. i .w indicates load q i The weight of Arrange all attribute columns in the table in descending order according to their spatial importance values; The attribute columns sorted in descending order are distributed to the multiple first-level partitions to determine column groups of different importance and store them in the multiple first-level partitions.
3. The method for intelligent data partitioning according to claim 1, characterized in that: Determining the number of subgraphs in each of the secondary partitions includes: Determining the size of each of the secondary partitions; The number of subgraphs in each of the secondary partitions is determined according to the size of each of the secondary partitions and the preset size of each of the secondary partitions.
4. The method for intelligent data partitioning according to claim 1, characterized in that: Determine the number of subgraphs in each of the secondary partitions, which also includes: Determine the set of access attributes for each query statement; A hypergraph is constructed in each of the secondary partitions to obtain each of the secondary partitions after the hypergraph is constructed.
5. The method for intelligent data partitioning according to claim 4, characterized in that: A hypergraph partitioning algorithm is used to generate a target partition from each of the secondary partitions, including: The METIS algorithm is used to divide the constructed hypergraph of each secondary partition into non-overlapping partitions to obtain the target partition.
6. A device for intelligent data partitioning, characterized in that: The method for implementing the data intelligent partitioning according to any one of claims 1 to 5, the device comprising: A first acquisition module is used to acquire information of a plurality of data blocks divided by the load information; A first determination module is used to separate the plurality of data block information according to importance values of the plurality of data block information, and determine column groups of different importance to store in a plurality of primary partitions; A second acquisition module is used to run a space splitting algorithm in parallel in each of the first-level partitions to obtain a plurality of second-level partitions corresponding to each of the first-level partitions; A generating module, configured to generate a target partition from each of the secondary partitions by using a hypergraph partitioning algorithm when the number of subgraphs in each of the secondary partitions is determined; The spatial splitting algorithm is implemented in the following manner: when it is determined that the number of buckets is 0, a first target bucket is created and the current query statement is stored in the target bucket; when it is determined that the number of buckets is greater than 0 and there is a second target bucket, the load and query statement contained in the second target bucket are intersected in space; when it is determined that the number of buckets is greater than 0 and there is no second target bucket, the first target bucket is created and the current query statement is stored in the target bucket; when it is determined that the first target bucket and the second target bucket have the same query statement, the first target bucket and the second target bucket are merged; Among them, the second acquisition module is specifically used to obtain multiple query statements, wherein the multiple query statements are different; the spatial graph enclosed by the multiple query statements corresponds to the space that the multiple query statements need to access at the horizontal level; based on the spatial intersection technology, multiple secondary partitions corresponding to each of the first-level partitions are obtained.
7. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-5.
