据我所知,这两者是同义词。但是,将<>更改为!=会将我的持续时间从9-10秒增加到18-19秒。
我的查询如下所示
select cast(Item.type as char), (IFNULL(SUM(IFNULL(Item.amount, 0)),0) + IFNULL(Refund.amount ,0)) *-1
from Item
join Billing on Billing.id = Item.bill_id
join Payment_Item pi on Item.id = pi.Item_id
left join Payment p on p.id = pi.payment_id
left join Refund on Refund.type = Item.type
where Billing.year = 2020
and Billing.Code <> 075
group by Item.type如果我将Billing.Code <> 075更改为Billing.Code != 075,那么我的持续时间会急剧增加
为了了解更多信息: Explain不显示使用<>的查询和使用!=的查询之间的任何差异
*编辑查询以简化查询
**不再需要两倍的时间。我不知道为什么,我没有做任何改变,而且它之前一直在做。
发布于 2020-12-03 01:16:15
您可以尝试为某些表创建索引,索引通常是在要比较的表的共享属性上完成的,例如,查看查询中两个表之间的共享属性是否相等。
CREATE INDEX <index_name> ON <tablename>(<attribute_name>); 其中属性名通常是表的主键。
希望这能有所帮助
https://stackoverflow.com/questions/65112814
复制相似问题