当前位置:网站首页>Type of sub database and sub table

Type of sub database and sub table

2022-06-22 08:11:00 abckingaa

Introduction to types of sub database and sub table

Once the amount of data in the business table is large , From a maintenance and performance point of view , Whatever CRUD operation , It is an extremely resource consuming thing for the database . Even if the index is set , It is still impossible to hide the fact that the database performance is degraded due to the large amount of data , At this time, the database should be Horizontal zoning (sharding, That is, sub warehouse and sub table ), Allocate the massive data maintained in the original table to N Sub tables are stored and maintained .

The horizontal sub table can be divided into 3 Kind of : Table only 、 Only branch library 、 Sub database and sub table , The following figure shows these three cases :

Table only : take db In the library user The table is divided into 2 A minute table ,user_0 and user_1, The two tables are also in the same library .

Only branch library : take db The library is split into db_0 and db_1 Two libraries , At the same time db_0 and db_1 Create a new one in the library user surface ,db_0.user Table and db_1.user Only the original... Are stored in the table db.user Some of the data in the table .

Sub database and sub table : take db The library is split into db_0 and db_1 Two libraries ,db_0 Contained in the user_0、user_1 Two sub tables ,db_1 Contained in the user_2、user_3 Two sub tables .

The following figure illustrates the case of sub database and sub table , How data is split : hypothesis db Library user There used to be 4000W Data , You will now db The library is split into 2 A sub Treasury db_0 and db_1,user The table is divided into user_0、user_1、user_2、user_3 Four sub tables , Each sub table stores 1000W Data .

原网站

版权声明
本文为[abckingaa]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202220529316671.html