一个 旧项目 出现的 能源问题:
出现问题的 原句:
select * from stock where leechdomId
in
(
select leechdomId from collect
where id
not in
(
select collectId from quote
where type=0 and date >'2010-06-01 10:00:02'
) and date>'2010-06-01 10:00:02'
) and date>'2010-06-01 10:00:02'
in 嵌套 not in 加 三个where 有两个and 运行多次 一般需要 7秒;
-------------------------------------------
in 里面的句子
select leechdomId from collect
where id
not in
(
select collectId from quote
where type=0 and date >'2010-06-01 10:00:02'
) and date>'2010-06-01 10:00:02'
也就是 在in 里 嵌套的句子同样需要 7秒
--------------------------------------
not in 最深层的句子
select collectId from quote
where type=0 and date >'2010-06-01 10:00:02'
运行 显示为 0秒
--------------------------------------
第二层 in 里面的句子 去掉一个条件
去掉时间判断:
select leechdomId from collect
where id
not in
(
select collectId from quote
where type=0 and date >'2010-06-01 10:00:02'
)
或者去掉 not in:
select leechdomId from collect
where date>'2010-06-01 10:00:02'