Today I found the OracleCommand.InitialLOBFetchSize property (documentation). Because I’m using NHibernate (which always accesses all values returned from a DataReader) I’ve set it to -1 for all new OracleCommands in my application (which brought a huge performance gain when selecting many CLOBs).
But then I noticed several new bugs in my application. All of them have the same source: Suddenly OracleDataReader.IsDBNull() (documentation) returns true for empty CLOBs! This is 100% reproducible, setting it back to 0 or a positive value brings IsDBNull() back to its correct behaviour.
Has anyone an idea how this bug can be prevented while still getting complete LOBs without additional round-trips?
I’ve noticed that setting InitialLOBFetchSize to a positive value affects the OracleDataReader.RowSize value, whereas 0 and -1 result in the same RowSize value. Is there any disadvantage in setting InitialLOBFetchSize to a big value (some MB)?
I’m using ODP.NET 11.2.0.3.0 (also tried 11.2.0.2.0) with .NET 4.0 and an Oracle 11g Release 2 server.
Some testing showed that using big values (>= 1 MB) for
InitialLOBFetchSizebrings the performance back down (as bad as 0).I’ll use a value that covers most of my CLOBs (5-10 KB) until someone has a real solution.