Handling problems related to the download performance similar to csdn [welcome to discuss]
Source: Internet
Author: User
Handling csdn-like download performance problems [welcome to discuss] In the csdn download channel, if you have downloaded this attachment, you do not need to deduct points when you download it again next time. I currently have a similar function. my implementation solution is to add a field in my attachment table: download_uids to store all user IDs that have downloaded the attachment. Then, when downloading a file, you must first handle performance issues similar to csdn Download. [welcome to discuss]
In the csdn download channel, if you have downloaded this attachment, you do not need to deduct points when you download the attachment again next time.
I currently have a similar function. my implementation solution is to add a field in my attachment table: download_uids to store all user IDs that have downloaded the attachment. Then, when downloading, use the in_array () function to check whether the user uid exists in the download_uids of the attachment record. if the user uid exists, do not deduct the gold coins, otherwise, array_push will be executed after the gold coins are deducted.
Key point: whether the in_array () operation on the large array (up to 30 K users) has performance problems.
Whether the large array array_push () has performance issues with the large array (up to 30 K users:
------ Solution --------------------
Create a table with 2 fields
Uid save user ID
Did save resource id
Queries whether a user has downloaded a resource.
Select * from tbl_name where uid = $ uid and did = $ did
Query the resources downloaded by the user.
Select * from tbl_name where uid = $ uid
Query which users have downloaded a resource.
Select * from tbl_name where did = $ did
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.