How to deal with the Mysql subtable of Hash algorithm
This article mainly explains "how to deal with the Mysql sub-table of Hash algorithm". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how to deal with the Mysql sub-table of the Hash algorithm.
Our hash algorithm in the sub-table is similar to this idea: calculate the table name of the data storage table through a certain hash algorithm through the ID or name of an original target, and then access the corresponding table.
Continue to take the above post bar, each post bar has a section name and a section ID, so these two values are fixed and unique, so we can consider doing some operations on one of these two values to get the name of a target table.
Now if we aim at our sticker bar system, assuming that the system allows a maximum of 100 million pieces of data, considering that each table holds 1 million records, then the whole system can hold no more than 100 tables. According to this standard, let's assume that we hash on the ID of Tieba, get a key value, which is the name of our table, and then access the corresponding table.
How to deal with Mysql sub-table based on Hash algorithm
We construct a simple hash algorithm:
Functionget_hash ($id) {
$str=bin2hex ($id)
$hash=substr ($str,0,4)
If (strlen ($hash)