我怎么优化这个SQL语句啊?

[复制链接]
查看11 | 回复0 | 2004-11-12 16:16:00 | 显示全部楼层 |阅读模式
版本:MySQL4.0.13
ExamInfo :170000条
PatientInfo: 13000条
PatientInfo:800条
selectcount(*) as totalCount
from ExamInfoinnerjoin PatientInfo
(on PatientInfo.PatientIntraID =ExamInfo.PatientIntraID)
left join ProcedureStepInfo
(on ExamInfo.ProcedureStepID=ProcedureStepInfo.ProcedureStepID)
where ExamInfo.PreExamScheduleDate ='1900-11-30'
AND ExamInfo.ExamType='CT';
mysql> explain :
+-------------------+--------+---------------------------+---------+---------+--------------------------+--------+-------------+
| table
| type | possible_keys
| key | key_len | ref
| rows | Extra |
+-------------------+--------+---------------------------+---------+---------+--------------------------+--------+-------------+
| ExamInfo
| ALL| Index_PreExamScheduleDate | NULL|NULL | NULL
| 175732 | Using where |
| PatientInfo | eq_ref | PRIMARY,PatientIntraID| PRIMARY | 4 | ExamInfo.PatientIntraID|1 | Using index |
| ProcedureStepInfo | eq_ref | PRIMARY
| PRIMARY | 4 | ExamInfo.ProcedureStepID |1 | Using index |
+-------------------+--------+---------------------------+---------+---------+--------------------------+--------+-------------+
3 rows in set (0.00 sec)

我怎么优化啊? 这句话在我的服务器上执行效率很低啊得 30秒
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行