0
我们有以下种类统计的一个相当大的MySQL的InnoDB表,MySQL数据范围查询优化
Rows - 8277943+ Server Ram - 128 Gb
Avg row Length - 575 Processor - Deca Core Intel
Data Size - 4.4 GB Overall Database Size - 500Gb
的问题是,我们有几个查询此表上,他们现在正在运行很慢,正在运行出于想法优化。例如下面给出一些查询,
select TIMESTAMPDIFF(SECOND,w.msgCreatedOn,now()) as rnge
from t_xxx_dtls w
where w.profileId=17901
and w.orgId=1448
and w.actionStartDate BETWEEN '2016-07-27 05:08:00' and '2016-07-27 13:08:59'
and w.currentlyActive=true and w.`action` not in (6,9,17)
and (
w.parentId NOT in (
select CASE WHEN d.parentId IS NOT NULL THEN d.parentId ELSE d.id END as ticketId
from t_xxx_dtls d where d.profileId=17901 and d.orgId=1448 and d.actionStartDate BETWEEN '2016-07-27 05:08:00' and '2016-07-27 13:08:59' and d.action in (2,4,7)
group by ticketId
)
or (w.parentId is null and w.inReplyId is null)
)
and w.msgId is not null
order by rnge desc
limit 0,1
虽然我们有简单的查询,如下面的一个,它开始被卡住,
select count(*)
from t_xxx_dtls d
where d.actionStartDate BETWEEN '2016-07-27 05:08:00' and '2016-07-27 13:08:59'
这根据解释计划正在检查大量的记录,这怎么能改进。我正在阅读有关分区的信息,但现在确定它是否有帮助。
请显示表格结构。你有一个关于actionStartDate的索引吗? – rlanvin
请显示mysql版本,创建索引,oltp或olap数据库,... –