简体   繁体   中英

Dmoz/Monster algorithme to calculate count of each category and sub category?

I have to create a browse page like monter.com or dmoz directory. My problem is the counts for each category. What's the best practive to do a similar thing? I am using PHP/MySQL Thx!

Did you try to implement it the way that you calculate these numbers dynamically when the page loads? How do you know that it is indeed a performance issue? Calculations are pretty fast these days.

Otherwise put a counter field next to each (sub-)category. When inserting(/deleting) a new post, then you update the counter of all categories it belongs to.

As a result, when you query any category, or set of categories, you will have a counter field for each giving the exact numbers of posts the category holds.

Solr可以使用Faceted Search http://lucene.apache.org/solr/tutorial.html#Faceted+Search做到这一点,现在我将对其进行测试。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM