简体   繁体   English

合并、分区和远程数据库 - 性能调优 Oracle

[英]Merge, Partition and Remote Database - Performance Tuning Oracle

I want to tune my merge query which inserts and updates table in Oracle based on source table in SQL Server.我想调整我的合并查询,它根据 SQL 服务器中的源表在 Oracle 中插入和更新表。 Table Size is around 120 million rows and normally around 120k records are inserted/updated daily.表大小约为 1.2 亿行,通常每天插入/更新约 12 万条记录。 Merge takes around 1.5 hours to run.合并运行大约需要 1.5 小时。 It uses nested loop and primary key index to perform insert and update.它使用嵌套循环和主键索引来执行插入和更新。 There is no record update date in source table to use;源表中没有记录更新日期可供使用; so all records are compared.所以所有的记录都会被比较。

Merge abc tgt
using
(
   select a,b,c
   from sourcetable@sqlserver_remote) src
  on (tgt.ref_id = src.ref_id)
when matched then 
update set 
      .......
where 
    decode(tgt.a, src.a,1,0) = 0
     or ......

when not matched then 
insert (....) values (.....);
commit;

Since the table is huge and growing every day, I partitioned the table in DEV based on ref id (10 groups) and created local index on ref id.由于表很大并且每天都在增长,因此我在 DEV 中根据 ref id(10 个组)对表进行了分区,并在 ref id 上创建了本地索引。 Now it uses hash join and full table scan and it runs longer than the existing process.现在它使用 hash 连接和全表扫描,运行时间比现有进程长。 When I changed from local to global index (ref_id), i uses nested loops but still takes longer to run than the existing process.当我从本地索引更改为全局索引 (ref_id) 时,我使用嵌套循环,但运行时间仍然比现有进程长。

Is there a way to performance tune the process.有没有办法对过程进行性能调整。

Thanks...谢谢...

I'd be wary to join/merge huge tables over a database link.我会警惕通过数据库链接加入/合并巨大的表。 I'd try to copy over the complete source table (for instance with a non-atomic mview, possibly compressed, possibly sorted, certainly only the columns you'll need).我会尝试复制完整的源表(例如,使用非原子 mview,可能已压缩,可能已排序,当然只有您需要的列)。 After gathering statistics, I'd merge the target table with the local copy.收集统计信息后,我会将目标表与本地副本合并。 Afterwards, the local copy can be truncated.之后,可以截断本地副本。

I wouldn't be surprised, if partitioning speeds up the merge from the local copy to your target table.如果分区加速了从本地副本到目标表的合并,我不会感到惊讶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM