场景:
一个彩票过滤网站, 用户使用文件上传自己的投注方案,最大控制在50w条[需要保留原始投注单],需要和网站系统的过滤集进行对比。
1.在过滤集内的,保存到投注单列表(TZD)
2.不在过滤集内的,保存到过滤单列表(GLD)
3.如果用户的原始单,有多条相同投注号,只能过滤掉一条,其它的全部保存到投注单(YSD)
需要注意的是:当用户上传自己的投注方案后,网站需要按照以上规则算出对应的数量,以及用户对应的需要支付的金额,当用户选择支付以后,才允许用户下载过滤后的投注单列表。
现在的问题是:
所有的过滤操作都使用sql在oracle里操作,这样用户量大的时候问题会很大,而且很多用户过滤后计算出金额并不支付,而这也占用了数据库的资源。
过滤的sql现在的性能也有比较大的问题,执行25万条原始单数据时就卡住了:
[code="java"]
begin update zc_ysd$qsbh$ a
set blbz = '1'
where fxdid = #fxdid#
and exists (select 1 from zc_bqglz$qsbh$ b where b.ysz = a.tzh);
update zc_ysd$qsbh$ a set blbz = '1'
where fxdid = #fxdid# and blbz='0'
and exists (select 1
from (select ROWID as RID,
row_number() over(partition by tzh order by rowid) as rn
from zc_ysd$qsbh$
where fxdid = #fxdid# and blbz='0') b
where b.rn > 1 and b.RID = a.rowid);
insert into zc_tzd$qsbh$
(ysdid, gh, tzh, rq, fxdid)
select ysdid, gh, tzh, rq, fxdid
from zc_ysd$qsbh$
where fxdid = #fxdid# and blbz = '1';
insert into zc_gld$qsbh$
(ysdid, gh, tzh, rq, fxdid)
select ysdid, gh, tzh, rq, fxdid
from zc_ysd$qsbh$
where fxdid = #fxdid# and blbz = '0';
update zc_tzglrz set jzsj=sysdate where qsbh='$qsbh$' and fxdid=#fxdid# and jzsj is null; end;
[/code]