mysql hash 分表

比如用户表有1000万数据,系统的性能就会变得很慢。

function hashID($id, $max)
{
    $md5 = md5($id);
    $str1 = substr($md5, 0, 2);
    $str2 = substr($md5, -2, 2);
    $newStr = intval(intval($str1 . $str2, 16));
    $hashID = $newStr % $max + 1;
    return $hashID;
}

猜你喜欢

转载自blog.csdn.net/u011504963/article/details/81907922