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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.