The difference between horizontal and vertical database splitting (take mysql as an example

 
Case:
    The simple shopping system temporarily involves the following tables:
1. Product table (data volume 10w, stable)
2. Order table (data volume is 200w, and there is a growing trend)
3. User table (data volume is 100w, and there is a growing trend)
Taking mysql as an example to describe horizontal splitting and vertical splitting, the order of magnitude that mysql can tolerate is millions of static data and can reach tens of millions
 
Vertical split (split by database table server):
Vertical splitting refers to the method of splitting a table with many attributes and a large row of data into different tables to reduce the size of a single database (table) and improve performance. After division, the characteristics of each library (table) are:
(1) The structure of each library (table) is different
(2) Generally speaking, the attributes of each library (table) have at least one column intersection, usually the primary key
(3) The union of all libraries (tables) is full data
 
 
Solve the problem:
io competition between tables
 
does not solve the problem:
Pressure from the growth of data volume in a single table
 
plan:
Put the product table and the user table on a server
The order table is placed on a server alone
 
Horizontal split (split by data logical server):
Horizontal segmentation means that, based on a field (such as uid), according to certain rules (such as modulo), the data on one library (table) is split into multiple libraries (tables) to reduce the number of single library (table) (table) size, the method to achieve the purpose of improving performance, after horizontal segmentation, the characteristics of each library (table) are:
(1) The structure of each library (table) is the same
(2) The data of each library (table) is different, there is no intersection
(3) The union of all libraries (tables) is full data
 
Solve the problem:
Pressure from the growth of data volume in a single table
 
does not solve the problem:
io contention between tables
 
plan:
User table is split into male user table and female user table by gender
The order table is split into "Completed Orders" and "Incomplete Orders" by "Completed" and "Completing"
The product table is not completed and the order is placed on a server
    The completed order table box male user table is placed on a server
The female user table is placed on a server (female loves shopping)
 
Recommended tutorial: http://www.tuicool.com/articles/fYVBN32

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326399494&siteId=291194637