本帖最后由 nevermore_0923 于 2011-09-30 15:17:52 编辑

解决方案 »

  1.   


    SELECT soft_id,(SELECT COUNT(distinct(uc_softrecord.user_id))AS A FROM uc_softrecord where
     uc_softrecord.soft_id='2' and uc_softrecord.id='511331') AS ClickPeoNumber,
    (select uc_softrecord.click from uc_softrecord where uc_softrecord.soft_id='2' and
     uc_softrecord.id='511331') AS ClickNumber,
    (SELECT count(distinct(user_id) ) as DropNumber  FROM uc_softrecord where soft_id='2' and 
    uc_softrecord.`status` in (1,2) and uc_softrecord.id='511331') AS DropNumber,
    (Select count(distinct(user_id) ) AS num from uc_softrecord where uc_softrecord.`status`='2' and
     uc_softrecord.soft_id='2' and uc_softrecord.id='511331') AS DropOkNumber
     FROM uc_softrecord  where uc_softrecord.soft_id='2' and uc_softrecord.id='511331' and 
    uc_softrecord.createtime between '2011-09-15' and '2011-09-30' 
      

  2.   

    explain sql
    show index from xx
      

  3.   

    explain没走uc_softrecord.id这个索引吗
      

  4.   

    贴EXPLAIN结果
    贴表索引情况
      

  5.   

    第一句话报错。have an error。我是说可以语句弄短一点,性能高一点,不用考虑索引