我想对网站上的产品进行过滤. 像这样:
I want to make a filtering of products on a site. Something like this:
Department - lassics (13,395) - Literary (111,399) - History (68,606) ... Format - HTML (3,637) - PDF (8) - Audio CD (443) ... Language - English (227,175) - German (10,843) - French (10,488) ...如何计算每个类别的产品?对于每个类别,单独的SQL查询将太慢,因为产品和类别过多.我建议也不要选择缓存.
How to count products per category? A separate SQL-query for each category would be too slow because there are too many products and categories. I suggest caching is not an option too.
使用MySQL EXPLAIN查询也许有意义(尽管它并不总是提供足够的信息)?还是使用狮身人面像搜索引擎进行计数?...最好的方法是什么?谢谢.
Maybe it makes sense to use MySQL EXPLAIN queries (though it not always provide adequate information)? Or maybe using sphinx search engine for counting?... What is the best way to do this? Thanks.
推荐答案尝试:
SELECT category, COUNT(*) as count FROM table GROUP BY category响应应该是所有不同的category值,以及每个值的出现次数.
The response should be all the different category values, and the number of occurrences of each.
更多推荐
如何计算每个类别的项目?
发布评论