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.
Horizontal table:
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!