Multi-Threading Issues with OleDbDataAdapter


I have a .NET 4.0 console application that does a lot of reads from SQL Server 2008 using the OleDbDataAdapter object.

I tried to improve performance by spreading the processing logic across four threads using Visual Studio 2010’s Task Parallel Library. Sadly the multi-threaded version is three times slower than the original. Using VS2010’s performance tools, I found thousands of thread contentions caused by the method OleDbDataAdapter.Fill() which populates a DataSet.

This is puzzling as there are no static classes or variables involved that would result in the OleDbDataAdapter being shared by my threads. Also, four simultaneous connections just can’t cause a hold up at the database level, right? The default connection pool size should be much larger than this.

Does anyone have any theories?



It would be uber-helpful if you showed us some code.

I’d really start by asking, in a performance-sensitive environment, you are using:

  • OleDbDataAdapter over SqlDataAdapter
  • Using DataSets

Or, Database I/O tends to bottleneck before in-process calculations, so paralellization won’t help at all until you get that sorted.