mysql分表算法

1. 取模  uid % 20 + 1。(分20张表)

2. hash
function get_hash($id){
       $str = bin2hex($id);
       $hash = substr($str, 0, 4);
       if (strlen($hash)<4){
           $hash = str_pad($hash, 4, "0");
       }
       return $hash;
}
3. md5(uid)
4.按时间段 

猜你喜欢

转载自peter8015.iteye.com/blog/2232762