MySql 40W+数据,加上order by 查询速度很慢 本帖最后由 duanbinhua03 于 2014-02-24 17:43:09 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 explain select ..show index from ..直接以文本格式贴出来,不要贴图。 貌似没什么好的方法 只能换快的cpu了 mysql> explain Select * from vkq_kqdata Where EmpSysID<>'' Order by EmpNo ASC,KQDate ASC limit 0,30\G*************************** 1. row *************************** id: 1 select_type: SIMPLE table: b type: ALLpossible_keys: AK_KQ_KqData key: NULL key_len: NULL ref: NULL rows: 76013 Extra: Using where; Using temporary; Using filesort*************************** 2. row *************************** id: 1 select_type: SIMPLE table: c type: ALLpossible_keys: PRIMARY key: NULL key_len: NULL ref: NULL rows: 1 Extra: Using where; Using join buffer (Block Nested Loop)*************************** 3. row *************************** id: 1 select_type: SIMPLE table: a type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.b.EmpSysID rows: 1 Extra: Using index condition; Using where*************************** 4. row *************************** id: 1 select_type: SIMPLE table: b type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.DepartSysID rows: 1 Extra: NULL*************************** 5. row *************************** id: 1 select_type: SIMPLE table: c type: indexpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: NULL rows: 4 Extra: Using where; Using index; Using join buffer (Block Nested Loop)*************************** 6. row *************************** id: 1 select_type: SIMPLE table: d type: indexpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: NULL rows: 2 Extra: Using where; Using index; Using join buffer (Block Nested Loop)*************************** 7. row *************************** id: 1 select_type: SIMPLE table: e type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.PolitySysID rows: 1 Extra: Using index*************************** 8. row *************************** id: 1 select_type: SIMPLE table: f type: indexpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: NULL rows: 1 Extra: Using where; Using index; Using join buffer (Block Nested Loop)*************************** 9. row *************************** id: 1 select_type: SIMPLE table: g type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.NationSysID rows: 1 Extra: Using index*************************** 10. row *************************** id: 1 select_type: SIMPLE table: h type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.JobSysID rows: 1 Extra: NULL*************************** 11. row *************************** id: 1 select_type: SIMPLE table: i type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.EduSysID rows: 1 Extra: Using index*************************** 12. row *************************** id: 1 select_type: SIMPLE table: j type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.CountrySysID rows: 1 Extra: Using index*************************** 13. row *************************** id: 1 select_type: SIMPLE table: k type: eq_refpossible_keys: PRIMARY key: PRIMARY key_len: 74 ref: ecarddb.a.CertTypeSysID rows: 1 Extra: Using index*************************** 14. row *************************** id: 1 select_type: SIMPLE table: sy_id2name type: eq_refpossible_keys: PRIMARY,AK_SY_ID2Name key: PRIMARY key_len: 74 ref: ecarddb.a.EmpSexSysID rows: 1 Extra: Using where*************************** 15. row *************************** id: 1 select_type: SIMPLE table: sy_id2name type: refpossible_keys: AK_SY_ID2Name key: AK_SY_ID2Name key_len: 48 ref: const,ecarddb.a.EmpStatusID rows: 13 Extra: Using where; Using index*************************** 16. row *************************** id: 1 select_type: SIMPLE table: sy_id2name type: eq_refpossible_keys: PRIMARY,AK_SY_ID2Name key: PRIMARY key_len: 74 ref: ecarddb.a.EmpMarrySysID rows: 1 Extra: Using where*************************** 17. row *************************** id: 1 select_type: SIMPLE table: p type: eq_refpossible_keys: AK_RS_EmpCard key: AK_RS_EmpCard key_len: 74 ref: ecarddb.b.EmpSysID rows: 1 Extra: NULL*************************** 18. row *************************** id: 1 select_type: SIMPLE table: sy_id2name type: refpossible_keys: AK_SY_ID2Name key: AK_SY_ID2Name key_len: 48 ref: const,ecarddb.p.CardStatusID rows: 13 Extra: Using where; Using index*************************** 19. row *************************** id: 1 select_type: SIMPLE table: r type: eq_refpossible_keys: AX_RS_EmpPhoto key: AX_RS_EmpPhoto key_len: 74 ref: ecarddb.b.EmpSysID rows: 1 Extra: Using index19 rows in set (0.00 sec)mysql> 差不多有15张表,人事表涉及到职位等基本信息表,kq_kqdata这是人员的打卡时间表 mysql主从同步设置问题. mysql从binlog恢复数据的速度问题 数据库转存出错 求周数据 求教两句sql语句,谢谢 关于共享内存数据库 Mysql字符条件查询问题 求一SQL,急!在线等!!! 关于在mysql中使用ALTER语句 一串多语法问题 MYSQL 临时表不支持 再次引用 sphinx ,myisam
show index from ..直接以文本格式贴出来,不要贴图。
QDate ASC limit 0,30\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: b
type: ALL
possible_keys: AK_KQ_KqData
key: NULL
key_len: NULL
ref: NULL
rows: 76013
Extra: Using where; Using temporary; Using filesort
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: c
type: ALL
possible_keys: PRIMARY
key: NULL
key_len: NULL
ref: NULL
rows: 1
Extra: Using where; Using join buffer (Block Nested Loop)
*************************** 3. row ***************************
id: 1
select_type: SIMPLE
table: a
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.b.EmpSysID
rows: 1
Extra: Using index condition; Using where
*************************** 4. row ***************************
id: 1
select_type: SIMPLE
table: b
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.DepartSysID
rows: 1
Extra: NULL
*************************** 5. row ***************************
id: 1
select_type: SIMPLE
table: c
type: index
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: NULL
rows: 4
Extra: Using where; Using index; Using join buffer (Block Nested Loop)
*************************** 6. row ***************************
id: 1
select_type: SIMPLE
table: d
type: index
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: NULL
rows: 2
Extra: Using where; Using index; Using join buffer (Block Nested Loop)
*************************** 7. row ***************************
id: 1
select_type: SIMPLE
table: e
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.PolitySysID
rows: 1
Extra: Using index
*************************** 8. row ***************************
id: 1
select_type: SIMPLE
table: f
type: index
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: NULL
rows: 1
Extra: Using where; Using index; Using join buffer (Block Nested Loop)
*************************** 9. row ***************************
id: 1
select_type: SIMPLE
table: g
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.NationSysID
rows: 1
Extra: Using index
*************************** 10. row ***************************
id: 1
select_type: SIMPLE
table: h
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.JobSysID
rows: 1
Extra: NULL
*************************** 11. row ***************************
id: 1
select_type: SIMPLE
table: i
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.EduSysID
rows: 1
Extra: Using index
*************************** 12. row ***************************
id: 1
select_type: SIMPLE
table: j
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.CountrySysID
rows: 1
Extra: Using index
*************************** 13. row ***************************
id: 1
select_type: SIMPLE
table: k
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 74
ref: ecarddb.a.CertTypeSysID
rows: 1
Extra: Using index
*************************** 14. row ***************************
id: 1
select_type: SIMPLE
table: sy_id2name
type: eq_ref
possible_keys: PRIMARY,AK_SY_ID2Name
key: PRIMARY
key_len: 74
ref: ecarddb.a.EmpSexSysID
rows: 1
Extra: Using where
*************************** 15. row ***************************
id: 1
select_type: SIMPLE
table: sy_id2name
type: ref
possible_keys: AK_SY_ID2Name
key: AK_SY_ID2Name
key_len: 48
ref: const,ecarddb.a.EmpStatusID
rows: 13
Extra: Using where; Using index
*************************** 16. row ***************************
id: 1
select_type: SIMPLE
table: sy_id2name
type: eq_ref
possible_keys: PRIMARY,AK_SY_ID2Name
key: PRIMARY
key_len: 74
ref: ecarddb.a.EmpMarrySysID
rows: 1
Extra: Using where
*************************** 17. row ***************************
id: 1
select_type: SIMPLE
table: p
type: eq_ref
possible_keys: AK_RS_EmpCard
key: AK_RS_EmpCard
key_len: 74
ref: ecarddb.b.EmpSysID
rows: 1
Extra: NULL
*************************** 18. row ***************************
id: 1
select_type: SIMPLE
table: sy_id2name
type: ref
possible_keys: AK_SY_ID2Name
key: AK_SY_ID2Name
key_len: 48
ref: const,ecarddb.p.CardStatusID
rows: 13
Extra: Using where; Using index
*************************** 19. row ***************************
id: 1
select_type: SIMPLE
table: r
type: eq_ref
possible_keys: AX_RS_EmpPhoto
key: AX_RS_EmpPhoto
key_len: 74
ref: ecarddb.b.EmpSysID
rows: 1
Extra: Using index
19 rows in set (0.00 sec)mysql>