`
zhb8015
  • 浏览: 378201 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
Group-logo
Spring Roo杂谈
浏览量:0
社区版块
存档分类
最新评论

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.按时间段 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics