问题描述
问题:我的团队目前正在将 ERP 从 ECC 系统迁移到新的 S/4 Hana 系统。作为上线的一部分,我们的团队需要将所有表从 S/4 系统复制到我们将托管数据的 SLT 模式中。大多数表将由 SAP 外的 SLT 复制处理。但是,由于时间紧迫,我们确定了 4 个需要多天复制的表。这个想法是从远程源 (ABAP/SDA) 复制现有数据并放入我们的 SLT 模式中。完成后,我们可以激活点转发复制并允许更新所有新的或修改过的记录查看 SLT 复制。
尝试的方法:我们当前的方法是建立与后端 S/4 数据库的 SDA 连接,并按年份将数据分解以使用存储过程插入到我们的本地表中。这种方法出现了许多问题,但目前正在发挥作用。只是超级慢。
论坛问题:
- 这是您处理此类问题的方式吗?如果没有,您建议的解决方案是什么?
- 您是否在目标表中看到任何需要自定义以提高性能的内容?
- 在可能需要调整的存储过程中,您有什么突出的地方吗?
示例: 假设我们有一个名为:A_tbl
的源表- A_tbl 中有 5 亿条记录
- 大约 500 列宽
然后我们将有我们的目标表:B_tbl
- 与 A_tbl (500) 相同的列数
- 12 个循环分区
- 在 5 列上编入索引
当前程序:
CREATE OR REPLACE procedure LOAD_B_TBL_FROM_A_TBL ()
as
begin
declare v_offset_nbr integer;
declare v_record_count integer;
declare v_commit_count integer;
declare i integer;
declare v_year nvarchar(4);
declare v_record_per_commit_count CONSTANT INT = 1000000;
declare v_table_name CONSTANT NVARCHAR(30) = 'A_TBL';
declare v_start_year CONSTANT INT = 2011;
declare v_end_year CONSTANT INT = 2022;
declare year_nbr integer;
for year_nbr in v_start_year..v_end_year do
select IfNull(max(offset_nbr),0) into v_offset_nbr from B_TBL_SCHEMA.bulk_load_log where table_name = :v_table_name AND year_nbr = to_varchar(year_nbr); -- Get offset number of records
select count(*) into v_record_count from A_TBL_SCHEMAA_TBL A_TBL WHERE A_TBL.YEAR = to_varchar(year_nbr); -- Count the source records.
v_record_count = v_record_count - v_offset_nbr; -- Subtract out the records already committed for the current year. Failsafe if procedure fails
v_commit_count = v_record_count / v_record_per_commit_count; -- Number of times we need to loop
IF v_record_count < v_record_per_commit_count THEN -- Don't enter the loop if it's not necessary
INSERT INTO B_TBL_SCHEMA.B_TBL (
SELECT * FROM A_TBL_SCHEMAA_TBL
WHERE A_TBL.YEAR = to_varchar(year_nbr)
); -- Insert into our target table
COMMIT;
insert into B_TBL_SCHEMA.bulk_load_log values(
v_table_name,to_varchar(year_nbr),:v_offset_nbr,now()
); -- Insert into a logging table to keep up with offset
ELSE
for i in 0..v_commit_count do -- Loop number of commit times. (500 million / 1 million) = 500 commits necessary to process entire table
INSERT INTO B_TBL_SCHEMA.B_TBL (
SELECT * FROM A_TBL_SCHEMAA_TBL
WHERE A_TBL.YEAR = to_varchar(year_nbr)
LIMIT :v_record_per_commit_count OFFSET :v_offset_nbr
); -- Insert into our target table
COMMIT;
v_offset_nbr = v_offset_nbr + v_record_per_commit_count; -- Update the offset before logging so we know where to begin if procedure fails
insert into B_TBL_SCHEMA.bulk_load_log values(
v_table_name,now()
); -- Insert into logging table to keep up with offset
COMMIT;
end for;
end if;
end for;
end;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)