select a,b from table1 inner join table2 on table1.a=table2.a
and table1.b=table2.b where time>getdate()-15 and time<=getdate()
and not exists ( select 1 from BIGtable where BiGtable.a=table1.a and BiGtable.b=table1b)
这样一个简单逻辑的查询...= =只要我执行 MSSQL2000的CPU立马100%....16核的CPU+8G内存....而且很长一段时间都属于loading状态...机器为IBM 3950
table1有160M,数据量有60W条
table2有400M ,数据量有50W条左右
Bigtable有450M,数据量50W条....
table1 用来join的两个关键字建了聚集索引 其他两个表的都是ID为主键....
我估计查询得出的结果在2W条记录左右....让人纳闷的是 为什么一查询就会CPU100%呢= =...
开始觉得应该是table2 和BIGtable没有做好 聚集索引....
但是做这个索引与否能起到如此大的差别吗??
更何况Not exists也一样会扫描表...
我看了执行计划
inner join table2消耗了将近50%的资源
最后的not exists Bigtable 也消耗了将近50%.....
大虾们能一起讨论讨论吗...