In my APP, there is a function similar to that of the Prestige circle of friends. Is to view the sharing of friends. The specific SQL statement is: selectphoto. * fromphotowhereuserIdin (1, 2, 3,...) in is my friend. This is obtained in advance .... In my APP, there is a function similar to that of the Prestige circle of friends. Is to view the sharing of friends.
The specific SQL statement is:
select photo.* from photo where userId in(1,2,3,.........)
In conditions are my friends. This is obtained in advance.
There is a confusion here, that is, if there are 1000 friends, will the query efficiency be slow?
I don't know how PHP SNS are made ..
Everybody should have used it!
I have nearly 1000 friends. So what is the sharing of everyone's friends?
Yesselect inIn this way?
Reply content:
In my APP, there is a function similar to that of the Prestige circle of friends. Is to view the sharing of friends.
The specific SQL statement is:
select photo.* from photo where userId in(1,2,3,.........)
In conditions are my friends. This is obtained in advance.
There is a confusion here, that is, if there are 1000 friends, will the query efficiency be slow?
I don't know how PHP SNS are made ..
Everybody should have used it!
I have nearly 1000 friends. So what is the sharing of everyone's friends?
Yesselect inIn this way?
Index + paging + ajax automatic loading
Now a lot of nosql to achieve, such as redis set, that set provides a rich set of parallel operations, so the implementation is very good, this is a case http://blog.nosqlfan.com/html/2938.html
Sina Weibo uses redis in large quantities for business processing. There are many articles on the Internet for reference.
You can use redis to focus on friends and other keywords to google. There should be a lot of results.
Adding an index won't be too slow, or you can try union
Nosql with high usage
You can also use exists, for example:
select photo.* from photo p where exists (select 1 from user u where u.id = p.userId )
If the volume of data in the photo table is larger than that in the user table, we recommend that you use in. On the contrary, using exists is faster.