私の質問
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 >= '2013-08-01 00:00:00'
AND (SessionInfo.SessionCallTime <= '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;
その結果、1237行(10秒)が得られます
IAMが説明コマンドを実行するとき
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
ここで 57536 行を超えるクエリを検索すると、実行に時間がかかります
データの送信 sow:__
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