【业务流程】--通过临时表归档原创
金蝶云社区-eris
eris
5人赞赏了该文章 504次浏览 未经作者许可,禁止转载编辑于2022年12月08日 17:06:17

一、说明

1、为了快速的减少也流程实例数据,可以先把一定条件的数据迁移到临时表,在对临时表的数据进行归档到历史表

2、特别注意:处理时间一般只能在非生产时间,因为归档可能导致锁表,阻塞等,从而影响实际业务执行。

二、实现步骤

1、 把流程实例数据迁移到临时表中,并删除当前表中的数据,具体脚本为:

--把2021年以前的数据备份到临时表

--1、备份流程实例到temp_instance

select * Into  temp_instance from t_bf_instance where FSTARTTIME <'2021-01-01'

--temp_instance创建索引

Create Index Idx_temp_instance on temp_instance(FInstanceId)

--2、备份流程实例节点到temp_instanceEntry

select t0.* Into  temp_instanceEntry from t_bf_instanceEntry t0

inner join  temp_instance t1 on t1.FInstanceId = t0.FInstanceId 

--temp_instanceEntry创建索引

Create Index Idx_temp_instanceEntry on temp_instanceEntry(FRouteId)

--3、备份反写携带量到temp_instanceAmount

select t0.* Into  temp_instanceAmount from t_bf_instanceAmount t0

inner join  temp_instanceEntry t1 on t1.FROUTEID = t0.FROUTEID

--temp_instanceAmount创建索引

Create Index Idx_temp_instanceAmount on temp_instanceEntry(FRouteId)


--删除两年前的数据

--1、删除流程实例

delete from t_bf_instance where FSTARTTIME <'2021-01-01'

--2、删除流程实例节点

delete from t_bf_instanceEntry  where exists (select 1 from temp_instance t1 where t1.FINSTANCEID = t_bf_instanceEntry.FINSTANCEID)

--3、删除反写携带量

delete from t_bf_instanceAmount where exists (select 1 from temp_instanceEntry t1 where t1.FROUTEID = t_bf_instanceAmount.FROUTEID)


2、使用存储过程(附件中),对临时表中的数据进行归档


三、其他参考


1)【业务流程】--存储过程归档  https://vip.kingdee.com/article/388648080687608832?productLineId=1

2)【业务流程】--归档  https://vip.kingdee.com/article/171524?productLineId=1



赞 5