|
[\CODE]
这样的SQL G该如何优化:
update table1 a set col1='aaa'
where exists (select 1 from tab2 b where a.col2=b.col3 and b.col4 in ('a','b','c','d','e');
table1 记录为1800万,table2为3万多。col2列无索引,单独用col4选取b表5000条记录,加上a表200多万,cbo选择为hash,觉得有点慢啊
[/CODE]
对于update语句的优化,可以分为2步:
1.优化select col1 where exists (select 1 from tab2 b where a.col2=b.col3 and b.col4 in ('a','b','c','d','e');
如果该语句运行的很快,则可以转为第二步
2. 对update部分的优化
可以看:
http://blog.csdn.net/lunar2000/archive/2005/06/27/404090.aspx |
|