Php questions about multi-condition sorting of commodities,

Source: Internet
Author: User
Php questions about multi-condition sorting of commodities ,. A product sorting function is used because it is a B2B platform. One of the main methods is as follows: weight analysis of commodity arrangement 1. remaining time of recommendation window (field window_recom): 40% of the weight 2. store favorable rating (field praise_rate ): weight of 30% 3. product shelving time (field add_time): weight of 30% ------ php about multi-condition sorting of products ,.
A product sorting function is used because it is a B2B platform.
The main method is as follows:
Product ranking weight analysis
1. remaining time of the recommendation window (field window_recom): 40% weight
2. store rating (field praise_rate): 30% of the weight
3. product shelving time (field add_time): 30% weight

---------------------
Sorting rules
1. for any product, the program will extract the remaining time of its "Recommended Window", "store ratings", and "product shelving Time", and calculate the final score based on its weight;
2. the higher the score, the higher the ranking;
-------------------------------------------
My current statement is order by window_recom * 0.4 + praise_rate * 0.3 + add_time * 0.3 DESC, which sorts all the items. However, as the number of items increases, the speed slows down.
Are there any better solutions.


------ Solution --------------------
Sort by a field that does not exist. if there are too many items, it will be strange if it is not slow.

1. set a fixed field to store calculated values and update them in real time. sort these fields in the future.
2. if the number of retrieved records is not large each time, use this condition order by window_recom DESC, praise_rate DESC, and add_time DESC to retrieve records, sort the records according to your algorithm, and then generate the cache.

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.