当前位置:网站首页>Shardingsphere sub database and table scheme

Shardingsphere sub database and table scheme

2022-07-23 11:06:00 Road of Kings 001

lately , When the research background database is too large , Related sub database and table solutions .

1. Sub database and sub table

When the database and data table in a database are large enough , There are many problems . Because most databases use B The tree is stored , When the amount of data is too large , Excessive resource access will occur , Data lag . In the face of such problems , A better solution is to divide the database into tables .

There are two schemes for dividing databases and tables : Vertical segmentation and horizontal segmentation .

Vertical segmentation is generally divided into different parts for different businesses and different fields , Horizontal segmentation generally means that the same database or data table is divided into different databases and tables according to certain rules .

Generally speaking , The library generally adopts vertical segmentation , The advantage is that the library is dedicated ; The table adopts horizontal segmentation , Avoid excessive quantity .

2. The result of amalgamation

After database and table segmentation , The data will actually be segmented into different databases . Of course , Logically , The data in different databases are still in a set . therefore , The process of operating a database must be :

1) When entering data , Data is divided into different entity databases or data tables according to certain rules ;

2) During the query , Query in different physical entities by table ; Wait until the data is queried , Will merge data .

therefore , After querying the data , Will merge data .

3.ShardingSphere Technical solution

according to Apache Its official website says ,“ShardingSphere Is a set of open source distributed database middleware solutions composed of the ecosystem , It consists of Sharding-JDBC、Sharding-Proxy and Sharding-Sidecar( Planned ) this 3 The products are independent of each other . They all provide standardized Data fragmentation 、 Distributed transactions and database governance function , It can be applied to such as Java isomorphism 、 Heterogeneous languages 、 Various application scenarios such as cloud native .”

ShardingSphere It is a better technical scheme at present , After using the configuration, you can complete the relevant scheme of dividing databases and tables .

4. Read / write separation

Read / write separation , yes ShardingSphere Another option for . The basic idea is : Write with the main table , Read with auxiliary table . This makes reading faster , Make writing less intrusive . The only problem is : This may cause data inconsistency between the primary table and the secondary table .

5. Distributed transactions

Distributed transactions , yes ShardingSphere Important functions of . There are several mechanisms for distributed transactions :

1) Two stage method : Submission respectively , Make the transaction finally consistent ;

2) Flexible business : Maintain the final consistency of transactions .

6. reference

[1] overview :: ShardingSphere

原网站

版权声明
本文为[Road of Kings 001]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230536560278.html