语句优化

[复制链接]
查看11 | 回复1 | 2005-10-30 17:05:33 | 显示全部楼层 |阅读模式
下面的SQL太耗时,请问有什么优化的措施没有
update jnl
set (bokbal,nstmpg,paglin,lasbal,stmpny,stmdep)=
(select stm.actbal,stm.nstmpg,stm.paglin,stm.lasbal,stm.stmpny,stm.stmdep fromstm
where jnl.orgidt=stm.orgid3 and jnl.tlrnum=stm.tlrnum and jnl.vchset=stm.vchset and jnl.setseq=stm.setseq and jnl.erydat=stm.stmdat

and jnl.orgid3=stm.orgidt and jnl.cusidt=stm.cusidt and jnl.apcode=stm.apcode and jnl.curcde=stm.curcde)
where exists (select 1 from stm
where jnl.orgidt=stm.orgid3 and jnl.tlrnum=stm.tlrnum and jnl.vchset=stm.vchset and jnl.setseq=stm.setseq and jnl.erydat=stm.stmdat

and jnl.orgid3=stm.orgidt and jnl.cusidt=stm.cusidt and jnl.apcode=stm.apcode and jnl.curcde=stm.curcde)
其中表jnl 中有上亿条数据,而stm当中有几百万的数据
stm表是jnl的一个子集,每次stm重新产生数据的时候,都要做一次这种操作
注:有连接关系的字段都已经建立索引
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
exists 无用,可删掉
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行