如何优化此sql语句--几张表的数量如下:--代码表:63条select count(*) from etranscodeinfo --机构表:4887
如何优化此sql语句
--几张表的数量如下:
--代码表:63条
select count(*) from etranscodeinfo;
--机构表:4887条
select count(*) from bankdept;
--账号表:75712 条
select count(*) from eaccount;
--客户表:67363 条
select count(*) from ebankcif;
--交易表:7280737 条
select count(*) from ejnl;
select t2.deptseq,count(*) as accamount from
(
select acseq,ea.deptseq from eaccount ea,
(
select t1.cifseq from ebankcif t1
where t1.edition='1' and not exists(select 1 from ebankcif where t1.cifseq=cifseq and opendate>t1.opendate)
) eb
where ea.cifseq=eb.cifseq
and ea.authflag !=1 and
(
(ea.acstate='0' and ea.opendate <to_date(#nextEndDate#,'YYYY-MM-DD') )
or
(ea.acstate='1' and ea.closedate>=to_date(#startDate#,'YYYY-MM-DD') and ea.closedate < to_date(#nextEndDate#,'YYYY-MM-DD'))
)
and ea.deptseq like #likeDeptSeq#||'%'
) t2
where not exists
(
select 1 from ejnl ej,etranscodeinfo et
where ej.transcode=et.transcode and host='01' and acctype='0' and ej.acseq is not null and
ej.transdate>=to_date(#startDate#,'yyyy-mm-dd') and ej.transdate<=to_date(#endDate#,'yyyy-mm-dd')
and ej.acseq=t2.acseq
) group by t2.deptseq
别名t2是上半部分,查询不存在ejnl交易表中的记录。如何优化。
[解决办法]
如无意外你这个已经是表扫描了。
[解决办法]
加索引。。。
[解决办法]
java读取txt文件乱码经典问题 [问题点数:4分,结帖人cqhweb]
你好,这个问题你解决了吗?
http://bbs.csdn.net/topics/310009185#new_post
[解决办法]
ea.opendate
ea.closedate
ea.deptseq
ebankcif.cifseq
ej.acseq
et.transcode
这些字段若有索引,且xxxseq列重复率低的话,应不致太慢。
