Horizontal and vertical segmentation database segmentation

Links: https://www.cnblogs.com/shijingxiang/articles/4601674.html

1, the level of segmentation:

Be divided according to the recording, the recording may be kept separate from different, each sub-table of the same number of columns , different numbers of rows .

Horizontal division is used at the following conditions:

A table is large, you can reduce the number of pages after the split at the time of the query needs to read the data and indexes, while also reducing the number of layers of index to improve query speed.

Data in Table B do have independence, for example, data are recorded in various regions or in different periods of the table, especially some of the data used, while other data is not used.

C needs to store data onto a plurality of media.

Split level will increase the complexity of the application, it usually takes more than one table name in the query, all the data required union operations. In many database applications this complexity will outweigh the advantages it brings, not as long as the index key, the index is used in the query, table two to three times the amount of data increases, it increases read query a number of disk index layer.

Relative to the vertical split, horizontal split data table will not be classified, but according to certain rules be dispersed into a plurality of fields in the database, each table contains part of the data. In simple terms, that is, it is segmented according to the data line, took part in the main library table and divide the two modes.

Solve the problem:
  The amount of data in a single table in the growth pressure
  Does not solve the problem:
  io contention between the table and the table
 
Program:
User tables by gender split into male and female users user table table
Orders table has been completed and completed by the split into completed orders and pending orders
 

2, the vertical split :( special purposes)

Divided by columns , i.e. the press table in the database tables into different modules (of course, without breaking the third principle is the paradigm), each sub-table of the same number of rows .

The master code and the number of columns into a table, and the main code and the additional columns into another table. If a table used in some columns, while other columns are not used, it is possible to use a vertical split, vertical split may be such that additional rows becomes smaller, a data page can store more data, at query time will be reduced I / O times. The disadvantage is the need to manage redundant columns to query all data needs to join the operation.

Characterized by simple rules, the implementation of more convenient, especially for the degree of coupling between the business is very low, very little interaction, the business logic of the system is very clear. In such a system, it can easily be split table do different services used by the module to different databases. Be split according to different tables, the impact of the application is also smaller, split rules are simple and clear (this is the so-called "share nothing"). In fact, relative to the vertical segmentation is further transformation services, to put it simple point is that the strong coupling of the original system to split into multiple weak coupling of services to meet business needs by calling room service. Single table large amount of data is still a performance problem.

Vertical Split:
Solve the problem:
io competition between the table and the table
Does not solve the problem:
The amount of data in a single table in the growth pressure
Program:
The product tables and user tables placed on a server
Orders placed a server on a separate table
 
Popular terms: horizontal split lines, split into different data rows in the table; split vertical columns, table column data are split into different tables.

Hash table and split horizon are similar, but there is no clear division level segmentation boundaries like that, it decided to save a file recorded by the hash function and key, so in order to IO more balanced.

Guess you like

Origin www.cnblogs.com/chen2608/p/10965565.html