问题语句如下
mysql> explain SELECT b.brand_id, b.brand_name, COUNT(*) AS goods_num FROM `hcsyw`.`ecs_brand`AS b, `hcsyw`.`ecs_goods` AS g WHERE g.brand_id = b.brand_id AND g.cat_id='1671' AND b.is_show = 1 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC;
+----+-------------+-------+--------+-------------------------------------------------------+---------+---------+------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+-------------------------------------------------------+---------+---------+------------------+------+----------------------------------------------+
| 1 | SIMPLE | g | ref | cat_id,brand_id,idx_catid_isdel_ison,idx_sal_sort_gid | cat_id | 2 | const | 1826 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | b | eq_ref | PRIMARY,is_show | PRIMARY | 2 | hcsyw.g.brand_id | 1 | Using where |
+----+-------------+-------+--------+-------------------------------------------------------+---------+---------+------------------+------+----------------------------------------------+
2 rows in set (0.00 sec)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。