Home  >  Article  >  Database  >  How to divide mysql horizontal tables

How to divide mysql horizontal tables

(*-*)浩
(*-*)浩Original
2019-05-25 16:44:305030browse

Mysql table data generally reaches one million levels, and the query efficiency will be very low, which can easily cause table locks, or even accumulate a lot of connections and directly hang up; horizontal table partitioning can greatly reduce these pressures.

How to divide mysql horizontal tables

Horizontal table:

How to divide mysql horizontal tables

As shown in the picture above: the other three tables The structure is the same, except that the data is stored in these three tables respectively. If you want to insert or query, you need to take the remainder of the id and then splice the table name, then it will be a complete table_name

But if Do I need to sub-table the name or the email?

Then you need to use MD5 for encryption, because MD5 is hexadecimal after encryption, then you can take the remainder, the idea is the same as above.

Put data rows into two separate tables based on the values ​​of one or more columns of data.

Horizontal split is usually used in the following situations.

The table is very large. After splitting, it can reduce the number of data and index pages that need to be read during query. It also reduces the number of index layers and improves query speed.

The data in the table is inherently independent. For example, the table records data for each region or data for different periods. In particular, some data are commonly used while other data are not.

The above is the detailed content of How to divide mysql horizontal tables. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How about mysql routerNext article:How about mysql router