Handling performance issues like CSDN downloads "Welcome to the discussion."
In Csdn's download channel, if the user downloads the attachment, the next time you download it, you don't need to deduct points.
I currently have a similar feature, and my implementation is to add a field to my attachment table: Download_uids is used to store all the user IDs that have been downloaded for that attachment. Then when the user downloads the first time to use the In_array () function to see if the user UID in the attachment record download_uids exist, if there is not to perform the deduction of gold operation, and vice versa to perform the deduction of gold Array_push.
Key point: In_array () has a performance problem with operations on large arrays (up to 30k users).
Large Array Array_push () has performance issues with large arrays (up to 30k users)
Share to:
------Solution--------------------
Create a new table, 2 fields
UID Save User ID
Did save resource ID
Query whether a user has downloaded a resource
SELECT * from Tbl_name where uid= $uid and did= $did
Query users to download those resources
SELECT * from Tbl_name where uid= $uid
Query which users have downloaded a resource
SELECT * from Tbl_name where did= $did