Vertical split and horizontal split of MySQL database tables

table of Contents

Vertical split

What is vertical split 

The principle of vertical split

Horizontal split

What is horizontal split

 How to divide the data equally into N shares


 

Vertical split

 

What is vertical split 

The so-called vertical split is to split a table with many columns into multiple tables, which solves the problem of table width.

 

The principle of vertical split

1. Store the uncommonly used field tables in a single table.
2. Store large fields independently in a table.
3. Put together the fields that are often used together.

 

 

Horizontal split

 

What is horizontal split

The horizontal split of the table is to solve the problem of too much data in a single table. The structure of each table of the horizontal split table is completely consistent.

 

 How to divide the data equally into N shares

1. Hash the customer_id. If you want to split it into 5 tables, use mod (customer_id, 5) to retrieve 0-4 values.
2. Store data in different tables for immovable hasid.

 

Published 568 original articles · Like 180 · Visits 180,000+

Guess you like

Origin blog.csdn.net/Delicious_Life/article/details/105614809