gpt4 book ai didi

mysql - MYSQL 中的生产查询速度慢,但开发速度慢

转载 作者:行者123 更新时间:2023-11-30 22:25:00 35 4
gpt4 key购买 nike

出于某种原因,以下查询在我的生产机器上需要 30 秒,而在本地不到一秒。我比较了字符编码、索引等

有什么想法吗?

SELECT ct.*, c.first_name as customer_first_name, c.last_name as customer_last_name, c.company_id as company_id 
FROM `communication_pieces`
JOIN contact c ON c.contact_id = communication_pieces.contact_id
JOIN customer_transactions ct ON ct.communication_piece_id = communication_pieces.id
JOIN campaign_iterations ci ON ci.id = communication_pieces.campaign_iteration_id
WHERE (communication_pieces.campaign_iteration_id = '1273')
AND (communication_pieces.status NOT IN ("undeliverable","not_delivered","address_rejected"))
ORDER BY ct.transacted_at ASC LIMIT 2000 OFFSET 0

我在解释时注意到的一件事是生产中的类型是 ct 表的索引和开发中的 ref。我知道层次结构索引更差,但可能是什么原因造成了差异?

最佳答案

好吧,事实证明不同版本的 MySql 选择要使用的索引的方式是不同的。我能够通过使用 rails USE INDEX 语法强制索引并在生产中获得相同的速度。如果有人遇到类似问题,请在此处添加。

关于mysql - MYSQL 中的生产查询速度慢,但开发速度慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35517302/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com