sql语句如下
select fc.*,ub.userinfo_base_name,up.userinfo_pic_pic_small from sns_feed_comment fc force index(PRIMARY) 
left join sns_userinfo_base ub on fc.login_uuid=ub.login_uuid left join sns_userinfo_pic up on 
fc.login_uuid=up.login_uuid where fc.feed_uuid= 21195392485949527 and ((fc.login_uuid=21143200311803907 and 
fc.state=0) or (fc.state=1)) and fc.feed_comment_parent = 0 order by fc.feed_comment_uuid limit 0,10
explain select fc.* from sns_feed_comment fc force index(PRIMARY) where fc.feed_uuid= 21195392485949527 and 
((fc.login_uuid=21143200311803907 and fc.state=0) or (fc.state=1)) and fc.feed_comment_parent = 0 order by 
fc.feed_comment_uuid limit 0,10fc.feed_comment_uuid为fc表主健,已做了索引,但还是出现Using filesort,请问还可以优化吗?难道一定要分拆为2句?

解决方案 »

  1.   

    提供一下你的show index from sns_feed_comment, 等这三个表的索引情况。
      

  2.   

    show index from sns_feed_comment
    Table  Non_unique  Key_name  Seq_in_index  Column_name  Collation  Cardinality  Sub_part  Packed  Null  Index_type  Comment  
    sns_feed_comment 0 PRIMARY 1 feed_comment_uuid A 7 NULL NULL   BTREE   
    sns_feed_comment 1 feed_uuid 1 feed_uuid A 7 NULL NULL   BTREE show index FROM sns_userinfo_base 
    Table  Non_unique  Key_name  Seq_in_index  Column_name  Collation  Cardinality  Sub_part  Packed  Null  Index_type  Comment  
    sns_userinfo_base 0 PRIMARY 1 userinfo_base_uuid A 10 NULL NULL   BTREE   
    sns_userinfo_base 1 login_uuid 1 login_uuid A 10 NULL NULL   BTREE show index FROM sns_userinfo_pic
    Table  Non_unique  Key_name  Seq_in_index  Column_name  Collation  Cardinality  Sub_part  Packed  Null  Index_type  Comment  
    sns_userinfo_pic 0 PRIMARY 1 userinfo_pic_uuid A 10 NULL NULL   BTREE   
    sns_userinfo_pic 1 login_uuid 1 login_uuid A 10 NULL NULL   BTREE