php - 分库分表后关于查询的问题
巴扎黑
巴扎黑 2017-04-18 10:34:09
0
4
436

假设 用户表规划是 2亿 = 500W(每表) 20表(每库) 2库 与 一个用户的总表

需求是这样的
当 需要用户互相关注的情况, following 表与 followers 表 (先假设不用分表),表结构分别为

following表 = id,uid(用户id),following_uid(关注人的uid),following_time
followers表 = id,uid(用户id),followers_uid(关注人的uid),followers_time

当要查询这个用户所有的关注人的时候问题就来了,用户表已经根据一定的规则分库分表,所有的用户在不同的表上面。

这样的情况是关联的用户的总表吗? 请大家指教一下,谢谢, 有类似的相关经验也可以

只放redis 不入库这样的方案接受不了。目前想要放redis 且入库

巴扎黑
巴扎黑

reply all(4)
阿神

1. Data redundancy, redundant user information that needs to be queried to your attention table, but this is generally not recommended
2. Cache user data, and read it from the cache when querying

小葫芦

The relationship is placed in redis

左手右手慢动作

Check twice. Users do not need a general table. First check followers, then use followers_id array to check profile, and then associate it on the front end.

巴扎黑

You can use the list type in redis to store

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!