gpt4 book ai didi

jquery - SQL 不在长时间响应中

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

我遇到了一个 SQL 查询问题,该查询返回了我想要的值,但在很长一段时间之后。

我可以在代码中更改哪些内容以进行时序优化?:

select * 
from t1
where
(t1.date between '01/01/2016' and '05/01/2016')
and (t1.section = 'KA')
and t1.protocol not in (select t2.protocol from t2 where (date between '01/01/2016' and '05/01/2016') and (section = 'KA'))

最佳答案

尝试使用不存在:

select t1.* 
from t1
where t1.date between '2016-01-01' and '2016-05-01' and
t1.section = 'KA' and
not exists (select 1
from t2
where t2.protocol = t1.protocol and
t2.date between '2016-01-01' and '2016-05-01' and
t2.section = 'KA'
);

为了提高性能,您需要在 t1(部分、日期、协议(protocol)) 上建立索引。和t2(协议(protocol)、部分、日期)

关于jquery - SQL 不在长时间响应中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46237728/

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