sql语句表过大 如何优化....

delete from Table1 t
where exists (select 1 from Table2 a where t.列2=a.列2 and t.列1=a.列1)
其中Table1 数据有800多万条
Table2 临时表有50多万条数据
我跑了大半天都没好 = =
求方案呀...谢谢啦...

ORACLE 我就无法测试但是我看了一下官方的文档
[url]http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm#i2071643[/url]
你进去后搜索 [color=red]DELETE TABLE[/color], 我觉得你一样能够用left join做这个事,因为mysql 和 sqlserver都提供了这样的方法,没理由oracle不提供。

这样可以不?试试。
delete from Table1 t
where t.列2,t.列1 in (select a.列2,a.列1 from Table2 a where t.列2=a.列2 and t.列1=a.列1)

delete Table1 from Table1 t,Table2 a where t.列2=a.列2 and t.列1=a.列1

不能执行,那是不可能的。

你试试不就知道了? :(

where条件中的字段是否已建立索引

建议建索引吧,800多万条的数据表也不算是大表了

采用左连接,不要用in或者exists不能改善多少效率的,左连接的字段建立索引,我2千万主表附表很小,查询数据也不过3秒。

子查询的写法会比较慢,用两个表左连接或者右连接

你用的什么的数据库啊 ?我已经在mysql 5.5上面测试通过了,为什么不可能 left join
delete person from person left join depart on person.depart =depart.id
where person.depart = '1';