My Life My Dream!

守信 求实 好学 力行
随笔 - 193, 文章 - 0, 评论 - 55, 阅读 - 34万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

BulkCopy频繁执行产生的性能问题

Posted on   召冠  阅读(1008)  评论(0编辑  收藏  举报

问题现象:

image

image

image

完整的SQL脚本如下:

select ac.constraint_name key_name, acc.column_name key_col, 1 from all_cons_columns acc, all_constraints ac where acc.owner = ac.owner and acc.constraint_name = ac.constraint_name and acc.table_name = ac.table_name and ac.constraint_type = 'P' and ac.owner = user and ac.table_name = :TableName order by acc.constraint_name

 

查阅咨询显示,使用OracleCommandBuilder对象后会产生该语句,而bulkcopy正是使用了该对象。

The query you have mentioned is done by OracleCommandBuilder to get the schema information from the database.

Once queried, the instance of OracleCommandBuilder creates an internal cache of it and reuses it.

But when you create new instance of OracleCommandBuilder it will run this query again.

 

To avoid it, create OracleCommandBuilder once and reuse it. For example, you can define a static variable to hold the instance,

or you can create it once in caller class and pass it as an argument every use.

https://social.msdn.microsoft.com/Forums/en-us/53defa9c-82f2-48b4-b923-6afbc064928c/oraclecommandbuilder-and-repetitive-internal-query?forum=adodotnetdataproviders

 

按照提示修改每次bulkcopy的批量大小后,问题消失。

编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示