For help, how to optimize the count left join group by having result set a numbe

selec count(id) from (
  SELECT  a.id AS id    FROM  a  
  LEFT JOIN  b ON a.p_id = b.p_id   AND a.pe = b.pe AND a.`m_id` = b.`m_id`   
   LEFT JOIN  c ON c.id = a.`m_id`    
     LEFT JOIN  d ON d.id = a.p_id
    LEFT JOIN  f ON f.id = c.t     
LEFT JOIN  AS g ON f.pid = g.id  WHERE  
  a.time >= '2013-07-03 00:00:00' AND a.time <= '2013-08-01 23:59:59'   
GROUP BY a.id HAVING INSTR(GROUP_CONCAT(b.s),'0') <> 0) 
) tt


For help, such as SQL, trouble you teach me
Thank you

    id  select_type  table   type    possible_keys        key        key_len  ref                                         rows  Extra                         
------  -----------  ------  ------  -------------------  ---------  -------  ----------------------------------------  ------  ------------------------------
     1  PRIMARY      (NULL)  (NULL)  (NULL)               (NULL)     (NULL)   (NULL)                                    (NULL)  Select tables optimized away  
     2  DERIVED      a       index   (NULL)               PRIMARY    4        (NULL)                                    185378  Using where                   
     2  DERIVED      b       ref     NewIndex1,NewIndex2  NewIndex2  47       a.pid,a.pe       1                                
     2  DERIVED      c       eq_ref  PRIMARY              PRIMARY    4        a.m_id                          1                                
     2  DERIVED      d       eq_ref  PRIMARY              PRIMARY    4        a.p_id                         1  Using index                   
     2  DERIVED      f       eq_ref  PRIMARY              PRIMARY    4       .c.pt                               1                                
     2  DERIVED      g       eq_ref  PRIMARY              PRIMARY    4        f.pid                           1  Using index                  

Started by Cora at November 17, 2016 - 5:52 AM

Teach you what? ?

Posted by Gino at November 27, 2016 - 6:00 AM