以下查询执行8秒
SELECT `currency`, sum(amount) as amount
FROM `p_transactions`
WHERE `member_id` = 2051
AND `transaction_type` = 'debit'
AND `transaction_status` = 12
GROUP BY `currency`
但是如果删除GROUP BY currency
部分,它最多短按2秒。有没有办法加快这个查询?
索引是复合索引(member_id,transaction_type,transaction_status)。
答案 0 :(得分:0)
尝试将索引更改为:
(member_id, transaction_type, transaction_status, currency)