Oracle SQL Update 查询需要几天时间才能更新
我正在尝试根据来自源的记录更新目标表中的记录。例如,如果传入记录存在于目标表中,我将在目标表中更新它们,否则我将简单地插入。我的源中有超过 100 万条记录,而我的目标有 4600 万条记录。目标表根据日历键进行分区。我使用 Informatica 实现了整个逻辑。我发现 Informatica 代码在查看 Informatica 会话日志时完全没问题,但更新需要很长时间(更新 100 万条记录需要 5 天以上)。
关于在该场景中可以采取哪些措施来提高性能有什么建议吗?
I am trying to update a record in the target table based on the record coming in from source. For instance, if the incoming record is present in the target table I would update them in the target else I would simply insert. I have over one million records in my source while my target has 46 million records. The target table is partitioned based on calendar key. I implement this whole logic using Informatica. I find that the Informatica code is perfectly fine looking at the Informatica session log but its in the update it takes long time (more than 5 days to update one million records).
Any suggestions as to what can be done on the scenario to improve the performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以试试这个
语法,乍一看有点令人畏惧,但如果我们从上到下读一遍,它是相当直观的。请注意以下子句:
•MERGE(第 1 行):如前所述,这是 Oracle 中的第四条 DML 语句。我们可能希望直接添加的任何提示都遵循此关键字(即 MERGE /*+ HINT */);
•INTO(第2 行):这就是我们指定MERGE 目标的方式。目标必须是表或可更新视图(此处不能使用内联视图);
•USING(第3 行):USING 子句表示MERGE 的源数据集。这可以是单个表(如我们的示例)或内联视图;
•ON ()(第 4 行):ON 子句是我们提供源数据集和目标表之间的联接的地方。注意连接条件必须在括号内;
•WHEN MATCHED(第5行):这个子句是我们在目标表中已经有匹配记录(即源数据集和目标数据集之间存在连接)时指示Oracle做什么的地方。在这种情况下,我们显然需要更新。该子句的限制之一是我们无法更新 ON 子句中使用的任何列(当然我们不需要这样做,因为它们已经匹配)。任何包含连接列的尝试都会引发不直观的无效标识符异常; WHEN
NOT MATCHED(第10行):这个子句是我们插入当前没有匹配项的记录的地方。
You can try this
The syntax at first looks a little daunting, but if we read through from top to bottom, it is quite intuitive. Note the following clauses:
•MERGE (line 1): as stated previously, this is now the 4th DML statement in Oracle. Any hints we might wish to add directly follow this keyword (i.e. MERGE /*+ HINT */);
•INTO (line 2): this is how we specify the target for the MERGE. The target must be either a table or an updateable view (an in-line view cannot be used here);
•USING (line 3): the USING clause represents the source dataset for the MERGE. This can be a single table (as in our example) or an in-line view;
•ON () (line 4): the ON clause is where we supply the join between the source dataset and target table. Note that the join conditions must be in parentheses;
•WHEN MATCHED (line 5): this clause is where we instruct Oracle on what to do when we already have a matching record in the target table (i.e. there is a join between the source and target datasets). We obviously want an UPDATE in this case. One of the restrictions of this clause is that we cannot update any of the columns used in the ON clause (though of course we don't need to as they already match). Any attempt to include a join column will raise an unintuitive invalid identifier exception; and
•WHEN NOT MATCHED (line 10): this clause is where we INSERT records for which there is no current match.
我不确定这如何适用于您的项目,因为您可能需要进行很多更改。由于您正在处理数百万条记录,因此我建议使用批处理作业。您可以使用 SQL Loader 实用程序。但这取决于源的格式。如果它是一个文件(例如csv文件),那么它是正确的选择。
I am not sure how this is applicable to your project since you may need to change a lot. Since you are dealing with millions on records, I would recommend a batch job. You can use SQL Loader utility. But it depends on the format of source. If it is a file(e.g. csv file), it is the right choice.