title: Why mysql Query Sending Data Slow
body: <p>my query </p>
  
  <pre><code>      SELECT Info.InfoID,
        SessionInfo.SessionInfoID,
        SessionInfo.ANI,
        ANumber.ANumber,
        tmfInfo.PTime,
        tmfInfo.PTry,
        SessionInfo.CardID,
        tmfInfo.Status
   FROM tmfInfo,
        SessionInfo,
        ANumber ,
        ANumberLog,
        ANumberGroup,
        ANumberGroupLog
  WHERE (tmfInfo.IVRSessionInfoID = SessionInfo.IVRSessionInfoID)
    AND (SessionInfo.ANumberLogID = ANumber.ANumberLogID)
    AND (ANumber.AccessNumberLogID = ANumberLog.ANumberLogID)
    AND (ANumberrLog.ANumberGroupID = ANumberGroup.ANumberGroupID)
    AND (ANumberGroup.ANumberGroupLogID = ANumberGroupLog.ANumberGroupLogID)
    AND (SessionInfo.SessionCallTime &gt;= '2013-08-01 00:00:00'
    AND (SessionInfo.SessionCallTime &lt;= '2013-08-01 23:59:59')
    AND (ANumberLog.IsDeleted = '0')
    AND (ANumberLog.IsActive = '1')
    AND (ANumberGroupLog.IsDeleted = '0')
    AND (ANumberGroupLog.IsActive = '1')
   ORDER BY SessionInfo.SessionCallTime,tmfInfo.PTime DESC;
  </code></pre>
  
  <hr>
  
  <p>it results gives 1237 rows (10 sec)</p>
  
  <p>when iam execute explain cmd </p>
  
  <pre><code>  id    select_type table   type    possible_keys   key key_len ref rows    Extra
     1    SIMPLE  SessionInfo range   PRIMARY,SessionCallTime,ANumberLogID    SessionCallTime 4       57536   Using where; Using temporary; Using filesort
    1       SIMPLE    Anumber ref AnumberLogID    AnumberLogID    5               SessionInfo.ANumberLogID    1   Using where
    1     SIMPLE  AnumberLog  eq_ref  PRIMARY,ANumberGroupID,IsActive,IsDeleted   PRIMARY 4   SessionInfo.ANumberLogID    1   Using where
    1 SIMPLE  AnumberGroup    eq_ref  PRIMARY,ANumberGroupLogID   PRIMARY 4   AnumberLog.ANumberGroupID   1   
    1 SIMPLE  AnumberGroupLog eq_ref  PRIMARY,IsActive,IsDeleted  PRIMARY 4   AnumberGroup.ANumberGroupLogID  1   Using where
   1  SIMPLE  tmfInfo ref IVRSessionInfoID    IVRSessionInfoID    8   SessionInfo.IVRSessionInfoID    1   
  </code></pre>
  
  <p>here query serching more than 57536  rows 
  it will take more time to execute</p>
  
  <p>sending data solw:__</p>
  
  <pre><code>                      Status    Duration
                       starting   0.000009
   Waiting for query cache lock   0.000003
    checking query cache for query    0.000087
            checking permissions  0.000003
           checking permissions   0.000002
           checking permissions   0.000002
           checking permissions   0.000002
           checking permissions   0.000002
           checking permissions   0.000003
                   Opening tables 0.000037
                   System lock    0.000007
   Waiting for query cache lock   0.000053
                          init    0.000039
                    optimizing    0.000018
                    statistics    0.000156
                            preparing 0.000033
             Creating tmp table   0.000029
                     executing    0.000002
            Copying to tmp table  0.353
                Sorting result    0.000238
                  Sending data    7.763123
                            end   0.000009
              removing tmp table  0.000011
                             end  0.000004
                         query end    0.000004
                  closing tables  0.000014
                  freeing items   0.000018
              logging slow query  0.000003
            logging slow query    0.000025
                   cleaning up    0.000005
  </code></pre>