A method for storing data partitions in a distributed database

Through the undirected graph processing method based on the frequency of table connections and the strength of relationships, the distributed database is partitioned into tables, which solves the problem of low cross-partition query efficiency in the distributed database, achieving more efficient query and information security, and No changes to existing database systems are required.

CN111782654BActive Publication Date: 2024-09-20SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010617993.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-01
Publication Date
2024-09-20
Estimated Expiration
2040-07-01

AI Technical Summary

Technical Problem

In distributed databases, due to the uncertainty between table partitions, cross-partition query efficiency is low and query time is long. Optimization is required to improve query efficiency.

Method used

Based on the frequency and strength of the connection between tables, an undirected graph processing method is introduced to partition the table. By recording the connection relationship between tables and partitions and the connection relationship diagram between tables, the storage partition of the table is optimized to ensure Tables in strongly connected subgraphs are stored in the same partition, and key intermediate nodes are stored redundantly.

Benefits of technology

It improves query efficiency, reduces query time, and ensures the security and reliability of information without requiring substantial changes to the existing database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111782654B
    Figure CN111782654B
Patent Text Reader

Abstract

The present invention provides a method for storing data partitions in a distributed database, and belongs to the field of distributed databases. The method records the query history of users by introducing a structure TABLE_RELATION, and the method is convenient and effective. On the basis of using frequency as the basis for table dumping, a further analysis is performed based on the connection graph between tables, and all node tables of a strongly connected subgraph are stored in the same partition or node; for a few key intermediate nodes in the graph, they are redundantly stored, which ensures query efficiency while also ensuring the security and reliability of key information. Through the partition dumping of the table, the method enables many query operations that originally required partitions or nodes to be completed in one partition or node, thereby improving query efficiency and reducing query time. The method does not require substantial changes to the existing database system, and is easy to implement and deploy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of distributed databases, and in particular relates to a method for storing data partitions in a distributed database. Background Art

[0002] Adding, deleting, modifying and checking are the most common operations in a database. When performing this series of operations, it is inevitable to access the data in the database table. In many cases, it is not just accessing the data in one table. For example, to query the information about a student and his school, it is necessary to connect the student and university tables and return the results that meet the conditions.

[0003] For traditional databases, the most important factor affecting the efficiency of connections between different tables may be the Cartesian product of the two tables; but for distributed databases, the communication time between partitions that are far apart also plays a very important role.

[0004] For a distributed database, it usually includes multiple storage nodes. Without considering redundancy, each node stores different data. When querying data through the database, in many cases, it is not just a query on one table, but more often it is to search for data in multiple tables at the same time. In the latter case, we are uncertain about the partitions (nodes) where different tables are stored. If they are stored in the same partition (node), it is of course good, but if the tables are stored in different partitions (nodes), then when querying, it is necessary to cross partitions (cross nodes) to query, resulting in slow query efficiency and long query time. Therefore, it is necessary to optimize this problem to improve the query efficiency of distributed databases. Summary of the invention

[0005] The technical task of the present invention is to solve the deficiencies of the prior art and provide a method for storing data partitions in a distributed database to improve the efficiency of the distributed database when executing queries and reduce the time used for queries.

[0006] The technical solution adopted by the present invention to solve its technical problem is:

[0007] A method for storing data partitions in a distributed database. The method measures the strength of the relationship between tables based on the frequency of connections between tables. Then, an undirected graph processing method is introduced to further partition the tables.

[0008] Preferably, a structure is introduced to record the connection and relationship between tables and between tables and partitions.

[0009] Preferably,

[0010] On the one hand, the frequency of table connections is used to characterize the strength of the relationship between the table and the partition storage partition (node), specifically:

[0011] The introduced structure is TABLE_RELATION, which maintains a connection relationship TABLE_RELATION between a table and a partition (node) to record the relationship strength between different tables and each partition;

[0012] Each operation related to table connection will change the record of TEABLE_RELATION of the table involved in the connection; in the initial state, after certain DML operations, the state of this TABLE_RELATION will change;

[0013] Then, through the records of the TABLE_RELATION table, according to the association strength represented by the connection frequency, the table is stored in different partitions (nodes);

[0014] On the other hand, based on the connection relationship between tables, a connection relationship graph between tables is generated, and all nodes (representing tables) in the strongly connected subgraph in the connection relationship graph are stored in the same partition.

[0015] Preferably, in the connection relationship graph, a node represents a table, and an edge represents whether tables are connected or not.

[0016] Preferably, for a table that satisfies both of the above aspects, the latter is given priority.

[0017] Preferably,

[0018] Taking the connection strength between tables and partitions as an indicator, if the partition with the strongest connection to a table changes, you should consider dumping the partition of this table;

[0019] From the perspective of the connection relationship graph, when a strongly connected subgraph appears in the graph, all node tables in the same strongly connected subgraph should be stored in the same partition storage node.

[0020] Preferably, for tables that act as intermediate nodes in multiple strongly connected subgraphs, redundant storage of these few tables in different partitions should be considered if storage allows.

[0021] Preferably, when it is found that a table needs to be partitioned, a suitable time should be selected to perform the dump so as not to affect normal production activities or to minimize the impact on production activities.

[0022] Compared with the prior art, the method for storing data partitions in a distributed database of the present invention has the following beneficial effects:

[0023] 1. By introducing a structure TABLE_RELATION to record the user's query history, the method is convenient and effective.

[0024] 2. Based on the frequency as the basis for table dumping, further analysis is performed based on the connection graph between tables, and all node tables of the strongly connected subgraph are stored in the same partition or node; for a few key intermediate nodes in the graph, they are stored redundantly, which ensures query efficiency while also ensuring the security and reliability of key information.

[0025] 3. This method dumps the partitions of the table so that many query operations that originally required partitions or nodes can be completed in one partition or node, thereby improving query efficiency and reducing query time.

[0026] 4. This method does not require substantial changes to the existing database system, making it easy to implement and deploy. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly describe the working principle of the method for storing data partitions in a distributed database of the present invention, a simplified diagram is attached below for further explanation.

[0028] Attached Figure 1 is a connection relationship diagram of the bid in the first embodiment of the present invention;

[0029] Attached Figure 2 It is a connection diagram of 7 tables in the database of Example 1. DETAILED DESCRIPTION

[0030] The following will be combined with the attached embodiment of the present invention Figure 1 , 2 , the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] The invention discloses a method for storing data partitions in a distributed database. The method measures the strength of the relationship between tables based on the frequency of connection between tables. Then, an undirected graph processing method is introduced to further partition the table.

[0032] Combined with Figure 1 , introduce a structure to record the connection and relationship between tables and between tables and partitions, mainly in the following two aspects:

[0033] On the one hand, the frequency of table connections is used to characterize the strength of the relationship between the table and the partition storage partition (node), specifically:

[0034] The introduced structure is TABLE_RELATION, which maintains a connection relationship TABLE_RELATION between a table and a partition (node) to record the relationship strength between different tables and each partition;

[0035] Each operation related to table connection will change the record of TEABLE_RELATION of the table involved in the connection; in the initial state, after certain DML operations, the state of this TABLE_RELATION will change;

[0036] Then, through the records of the TABLE_RELATION table, according to the association strength represented by the connection frequency, the table is stored in different partitions (nodes);

[0037] On the other hand, based on the connection relationship between tables, a connection relationship graph between tables is generated, and all nodes (representing tables) in the strongly connected subgraph in the connection relationship graph are stored in the same partition.

[0038] In the connection relationship diagram, nodes represent tables, and edges represent whether tables are connected or not.

[0039] For tables that meet both of the above aspects, the latter is given priority.

[0040] Among them, the connection strength between tables and partitions is used as an indicator. If the partition with the strongest connection to a table changes, the partition dump of this table should be considered;

[0041] From the perspective of the connection relationship graph, when a strongly connected subgraph appears in the graph, all node tables in the same strongly connected subgraph should be stored in the same partition storage node.

[0042] Among them, for tables that act as intermediate nodes in multiple strongly connected subgraphs, if storage allows, we should consider redundantly storing these few tables in different partitions.

[0043] Through the data information in the above TABLE_RELATION table and the information of the graph formed by the connection relationship between tables, the data stored in the database can be transferred and stored between partitions. However, the database needs to provide services to the outside world and it is impossible to update and store table partitions (nodes) at any time. Therefore, you can choose a time period with low service volume, such as 12:00 am every day, to perform table partition (node) dumping.

[0044] Embodiment 1

[0045] Assume that the database has three partitions, namely partition A, B, and C. There are 7 tables in the current database, namely tables t1, t2, t3, t4, t5, t6, t7, and t8. t1 and t2 are located in partition A, t3, t4, and t8 are located in partition B, and t5, t6, and t7 are located in partition C.

[0046] The general structure of TABLE_RELATION is as follows:

[0047] CREATE TABLE TABLE table_relation (

[0048] table_name TEXT,

[0049] current_partition TEXT,

[0050] weight_with_partA BIGINT,

[0051] weight_with_partB BIGINT,

[0052] weight_with_partC BIGINT

[0053] }

[0054] For the statement

[0055] SELECT * FROM t1,t2;

[0056] SELECT * FROM t1,t3;

[0057] SELECT * FROM t2,t3;

[0058] SELECT * FROM t3,t4;

[0059] SELECT * FROM t4,t5;

[0060] SELECT * FROM t4,t6;

[0061] SELECT * FROM t5,t6;

[0062] SELECT * FROM t4,t7;

[0063] SELECT * FROM t8,t7;

[0064] Each time a table is connected to another table, the weight of the partition corresponding to the other table is increased by 1. After the above command, the data of TABLE_RELATION is updated as follows:

[0065]

[0066] The connection diagram of the corresponding table is as follows Figure 2 shown.

[0067] According to the data in TABLE_RELATION, the partitioning result obtained by the frequency method should be A(t1, t2,), B(t3, t7, t8), C(t4, t5, t6), but according to the figure, t1, t2, t3 should be assigned to one partition, and t4, t5, t6 should be assigned to one partition. In summary, combining the two methods, the final table partitioning result is A(t1, t2, t3), B(t7, t8), C(t4, t5, t6).

[0068] If the partition result does not change, the database data will be dumped at an appropriate time. In the subsequent query process, the probability and situation of needing to search across partitions will be reduced.

[0069] It should be understood that the terms and expressions used herein are for descriptive purposes only, and the present method should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustrations and descriptions (or parts thereof), and it should be recognized that various modifications that may exist should also be included in the scope of the claims. Other modifications, changes and substitutions may also exist. Accordingly, the claims should be deemed to cover all such equivalents.

[0070] Similarly, it should be pointed out that although the method has been described with reference to the current specific embodiments, ordinary technicians in this technical field should realize that the above embodiments are only used to illustrate the method, and various equivalent changes or substitutions can be made without departing from the spirit of the method. Therefore, as long as the changes and modifications to the above embodiments are within the essential spirit of the method, they will fall within the scope of the claims of this application.

Claims

1. A method for storing data partitions in a distributed database, characterized in that: This method measures the strength of the relationship between tables based on the frequency of connections between tables. It then introduces an undirected graph processing method to further partition the table. Introduce a structure to record the connection and relationship between tables and between tables and partitions; On the one hand, the frequency of table joins is used to characterize the strength of the relationship between tables and partitions, specifically: The introduced structure is TABLE_RELATION. By maintaining a connection relationship TABLE_RELATION between a table and a partition, the relationship strength between different tables and each partition is recorded. Each operation related to table connection will change the record of TEABLE_RELATION of the table involved in the connection; in the initial state, after certain DML operations, the state of this TABLE_RELATION will change; Then, through the records of the TABLE_RELATION table, the table is stored in different partitions according to the association strength represented by the connection frequency; On the other hand, according to the connection relationship between tables, a connection relationship graph between tables is generated, and all nodes in the strongly connected subgraph in the connection relationship graph are stored in the same partition; For tables that meet both of the above aspects, the latter is given priority; Taking the connection strength between tables and partitions as an indicator, if the partition with the strongest connection to a table changes, you should consider dumping the partition of this table; From the perspective of the connection relationship graph, when a strongly connected subgraph appears in the graph, all node tables in the same strongly connected subgraph should be stored in the same partition storage node; For tables that act as intermediate nodes in multiple strongly connected subgraphs, if storage permits, we should consider redundantly storing these few tables in different partitions.

2. According to the method for storing data partitions in a distributed database as described in claim 1, in the connection relationship diagram, the node represents the table, and the edge represents whether the table is connected or not.

3. The method for storing data partitions in a distributed database according to claim 2, characterized in that: When a table needs to be partitioned, it is necessary to select an appropriate time to perform the dump so as not to affect normal production activities or to minimize the impact on production activities.