Recently encountered a problem, if the amount of data is larger how to divide the table?
Information table for example:
I built 100 such tables beforehand, message_00,message_01,message_02..........message_98,message_99. Then according to the user's ID to determine the user's chat information into which table, You can use a hash of the way to obtain, you can use to find the way to obtain, a lot of methods, each person to think of it. Here's a hash method to get the table name:
View copy print?
function get_hash_table ($table, $userid) {
$str = CRC32 ($userid);
if ($str <0) {
$hash = ' 0 '. substr (ABS ($STR), 0, 1);
}else{
$hash = substr ($str, 0, 2);
}
return $table. ' _ '. $hash;
}
echo get_hash_table (' message ', ' user18991 '); The result is message_10
This is the way to get the data table.
The original show was written dead.
You're going to get the table name from the function.
Like the news, the CM s half is divided by category, which is called vertical slicing
The kind of user called horizontal segmentation
For example: List This table has 50W data, you PHP write a judgment, each write this table to judge, is not reached 50W, if reached, write List_1 table, write an automatic add table
Then, according to the criteria, which table is queried and then the operation
The above describes the horizontal and vertical sub-table, including vertical, horizontal aspects of the content, I hope that the PHP tutorial interested in a friend helpful.