Poor performance getting clob field from Oracle in .Net

断了今生、忘了曾经 提交于 2019-11-30 17:01:36

问题


I am trying to read a clob column from oracle in .Net and observing very poor performance and lots of network traffic.

I have tried ODP+OCI, devArt+OCI ways to access the data with the same results - it takes around 20 seconds to get 1000 rows in a data reader and read the clob value for each row.

Examining wireshark traces, it turns out that every time I try to read the clob field for a single row in the reader, there are additional multiple tcp packets sent between client and server. So for 1000 rows this becomes 1000 times slower than if querying just one row.

At the same time, if I run the same query in SQL Developer (which I believe uses thin jdbc driver instead of oci), I get the results instantly, including the clob values. It does not try to query clob for each row - it gets them all in one go!

But I don't see a thin client for .net. How can I speed things up? Please help!

EDIT: My field type is actually XMLTYPE stored as clob, not a true clob. Using getClobVal over it improves the result by 50% to 10 seconds for 1000 rows. But at the same time, Sql Developer is returning results instantly, not in 10 seconds.


回答1:


You have correctly observed that Oracle delays the retrieval of LOBs. Thus, the performance your application is limited by the network round-trip time.

With the InitialLOBFetchSize property of the OracleCommand class (in ODP.NET, see documentation), you can tell Oracle to retrieve part of the LOB with the initial retrieval of the row. If your LOBs aren't too long, this can make quite a difference.



来源:https://stackoverflow.com/questions/8838115/poor-performance-getting-clob-field-from-oracle-in-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!