Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why does ​ need to split tables in Database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you why the database needs to split the table, I believe that most people still do not understand, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

The database split table can be divided into horizontal split and vertical split. Horizontal split divides the table into multiple sub-tables according to the logical relations and related conditions in the table; vertical split divides the table into different databases according to different tables.

With the continuous expansion of the data, the size of some data tables will grow geometrically. When the data reaches a certain scale, the query and reading performance of the data will become slow, so it is necessary to split the data table. Next, in the article, we will introduce in detail how to split the table in the database. I hope it will be helpful to you.

Why do you need to split the table

When a table has a large amount of data, it is time-consuming, so it is necessary to split the table and split the large table into multiple sub-tables, so when updating or querying the data, the pressure will be scattered to different tables. Because the data of each table is small after sub-table, both query and update greatly improve the speed, even if the worst case of "locking table" occurs, then other tables can still be used in parallel.

Split of data table

Data table splitting can be divided into two forms, horizontal segmentation and vertical segmentation.

Horizontal segmentation: according to the logical relationship of the data in the table, the data in the same table is divided into multiple databases (hosts) according to certain conditions. this segmentation is called horizontal (horizontal) segmentation of the data.

Vertical segmentation: split into different databases (hosts) according to different tables, which can be called vertical (vertical) segmentation of data.

The method of horizontal split

In general, use the form of "take the model" to store the data in the table, if you use 4 tables, the id%4 result will be 0min1, 2, 3, 4, user_0,user_1,user_2,user_3 is enough. It should be noted that in this process, we need to create a new temporary table in order to provide self-increasing id for data insertion. After getting the self-increasing id, we can insert the table by taking the module.

The method of vertical split

Put a table on the commonly used fields and a table on the less commonly used fields.

Take out the fields with large fields such as text and put them in a table.

If it is used, it is dismantled according to the specific business, and multiple tables are used for query, which can be combined with redis storage.

The above is why the database needs to split all the contents of the table, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report