gpt4 book ai didi

mysql - 请问我该如何优化这个mysql查询?

转载 作者:行者123 更新时间:2023-11-29 08:17:02 25 4
gpt4 key购买 nike

有人可以帮我优化这个查询吗?我可能可以添加一些索引并仅从修改的(CURRENT_TIMESTAMP)字段中获取日期?

谢谢杰里米

SELECT a.providerName AS Assureur, b.insuranceType AS Produit, c.votedFor, c.votedFor2, c.email, c.comment, c.modified
FROM insuranceproviders AS a, insurancetypes AS b, insurancevotes AS c
WHERE a.id = c.providerId
AND b.id = c.insTypeId

最佳答案

以下连接查询看起来更好:

SELECT a.providerName AS Assureur, b.insuranceType AS Produit,
c.votedFor, c.votedFor2, c.email, c.comment, c.modified
FROM insuranceproviders AS a
INNER JOIN insurancetypes AS b ON a.id = c.providerID
INNER JOIN insurancevotes AS c ON b.id = c.insTypeId

并且您应该添加以下索引:

ALTER TABLE insuranceproviders ADD INDEX(id);
ALTER TABLE insurancetypes ADD INDEX (providerID, insTypeId);
ALTER TABLE insurancevotes ADD INDEX(insTypeId);

关于mysql - 请问我该如何优化这个mysql查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20396795/

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