OracleBulkCopy 与 SQL*Loader 性能对比
当 Oracle 服务器位于另一台计算机上时,我发现 OracleBulkCopy (ODP.NET) 和 SQL*Loader 之间存在一些显着的性能差异。
我在 Oracle 中有一个非常基本的表,包含三列(一个 BINARY_FLOAT,两个 NUMBER(18,0))。没有主键、索引、触发器等。它用作临时表,将批量数据获取到数据库中。
SQL*Loader 大约需要 27 秒才能将 450 万行加载到表中。
OracleBulkCopy 大约需要 10 分钟才能加载 100 万行。
OracleBulkCopy,根据文档,*“...使用直接路径加载方法,与 Oracle SQL*Loader 类似,但不相同。”* 在性能方面可能无法与 SQL*Loader 相比,但这种差异是荒谬的。
对网络流量进行一些基本分析后,我发现 OracleBulkCopy 正在发送和接收大量小数据包。我使用 Wireshark 比较每个数据包并发现了一些有趣的结果。
SQL*Loader - 在初始连接握手之后 - 发送一系列 8 KB 数据包(TNS 协议)并接收 60 字节 ACK 作为响应。
OracleBulkCopy 发送一系列102 字节数据包(TNS 协议)并接收一个133 字节数据包(TNS 协议)作为响应。什么……!?就像一次发送一行!
对于 OracleBulkCopy 类,我使用的批处理大小为 100,000,并使用自定义的 IDataReader 从数据文件中读取数据。
所以,我的问题是:
有人见过这种行为吗?
OracleBulkCopy 实际上作为批量加载工具执行吗?
我需要配置什么才能使其正常工作吗? (客户端/服务器设置等)
非常感谢任何帮助。
I am seeing some significant performance differences between OracleBulkCopy (ODP.NET) and SQL*Loader when the Oracle server is on another machine.
I have a very basic table in Oracle with three columns (one BINARY_FLOAT, two NUMBER(18,0)). There are no primary keys, indexes, triggers, etc. It is used as a staging table to get bulk data into the DB.
SQL*Loader takes about 27 seconds to load 4.5 million rows into the table.
OracleBulkCopy takes about 10 minutes to load just 1 million rows.
OracleBulkCopy, according to the documentation, *"...uses a direct path load approach, which is similar to, but not the same as Oracle SQL*Loader."* It might not be up there with SQL*Loader in terms of performance, but this difference is ridiculous.
After some basic analysis of the network traffic, I found the OracleBulkCopy was sending and receiving a huge number of small packets. I used Wireshark to compare the packets for each and found some interesting results.
SQL*Loader - after the initial connection handshaking - sends a series of 8 kilobyte packets (TNS protocol) and receives 60 byte ACKs in response.
OracleBulkCopy sends a series of 102 byte packets (TNS protocol) and receives a 133 byte packet (TNS protocol) in response. What the...!? It is like it is sending one row at a time!
With the OracleBulkCopy class, I am using a batch size of 100,000 and am using a custom IDataReader to read from a data file.
So, my questions are:
Has anyone ever seen this behaviour?
Does OracleBulkCopy actually perform as a bulk loading tool?
Is there something I need to configure to get it to work properly? (client/server settings, etc)
Any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我收到了 Oracle 产品经理 Alex Keh 的回复,称 Oracle“也注意到了这个问题。我们正在评估如何修复这个错误。”
因此,在回答我自己的问题时,我认为 OracleBulkCopy 作为批量加载工具性能不佳。至少目前不是。
我将封装 SQL*Loader 作为替代解决方案,因为错误修复没有预计到达时间。
I received a response from Alex Keh, Oracle Product Manager, that Oracle "has noticed this issue as well. We're evaluating how to fix this bug."
So in answer to my own questions, I guess OracleBulkCopy does not perform well as a bulk loading tool. At least not at the moment.
I will be wrapping SQL*Loader as an alternate solution as there is no ETA on the bug fix.