SELECTCOUNT(1)asnum,uid,sid,usernameFROMsd_usersGROUPBYsidHAVINGnum>1ORDERBYnumDESC在实际测试中发现由于数据量超过60万在group的时候就产生了巨大的威胁力,查询执行缓慢一直停留在copytmptable下explain发现需要重建索引导致请问类似的语句应该如何优化+----+-------------+-----------+-------+---------------+-----+---------+------+--------+---------------------------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+-----------+-------+---------------+-----+---------+------+--------+---------------------------------+|1|SIMPLE|sd_users|index|NULL|sid|97|NULL|539029|Usingtemporary;Usingfilesort|+----+-------------+-----------+-------+---------------+-----+---------+------+--------+---------------------------------+1rowinset
海绵宝宝撒
慕斯709654
相关分类