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數據庫,... –