A notice is sent to the designated person. Seek the most efficient solution.

there is a requirement:
A notice is sent to specify who can read it.

the simplest solution to take advantage of mysql:

message Information Table
id Information ID
name
content

< hr >

message_user user View Information Table
id
message_id Information ID
user_id user ID

tell me about the method
advantages:
easy to implement

disadvantages:
for example, an article is assigned to 10, 000 people and thousands of articles are posted.
the message_user table will soon have a burst of information and will soon have a performance bottleneck.

therefore, please give us a more efficient solution, third-party storage is unlimited.

there is an assumption that each bit in binary is used to represent a user ID,. A value of 1 indicates read permission, while 0 has no permission:
message information table, add a column of binary (10000) binary type suppose to be user_control

user ID 1 is readable, 2 unreadable, 3, readable, .1000 readable

then the binary number corresponding to user_control is

1. . 1010

I don"t know if it"s feasible?

Mar.09,2021

if the 10,000 people you want to send are arbitrary and irregular, it is inevitable to generate a list of 10,000 people, whether manually selected or stored, at least once. However, if it is regular, use a method similar to the permission to read the post. Every time a user requests a notification list, it can be checked whether it meets the requirements. It can also be divided into user groups, and users in some groups can view a notification.

I think your idea will be a bit troublesome to use, but the effect is the same as storing a list directly. If you have to store this list, you might as well categorize it, enumerate it directly if the target users are sparse, and use your method if it is dense. Of course, this may require two fields.


you can try saving the user list into the structure type to become
id
message_id information ID
user_id_list user ID list


this is based on the number of users. If it is only 10000, you can use your method. If the amount of data is relatively large, 1 million 10 million, you can only use the first method. Even if the amount of data is large, but there are few fields, the query is still very fast.


all data can be stored in redis
queue Synchronize to mysql
mysql can be divided into tables


this idea can be quickly realized by using user role + subscription function without having to send it thousands of times.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32fec-2b6a7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32fec-2b6a7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?