OracleClient vs ODP.NET Performance Benchmark

In my previous post I mentioned that I was doing some comparisons on the performance of System.Data.OracleClient (provided by Microsoft) versus the ODP.NET (provided by Oracle). Since we still use a lot of DataSets on our project I decided that the simpler example that could be used to measure the performance would be to fill a DataTable using a DataAdapter.

For the experiment I took a table that would fill the DataTable with about 100.000 records. I then created two classes, one for each provider. The classes accessed the same database using the same SQL. Here is the code for the class using the OracleClient provider: 

class MicrosoftProvider
{
    public static void RunTest()
    {
        var conn = new System.Data.OracleClient.OracleConnection(Params.ConnectionString);
        var cmd = new System.Data.OracleClient.OracleCommand(Params.CommandText, conn);
        var adapter = new System.Data.OracleClient.OracleDataAdapter(cmd);
        var dataTable = new DataTable();
        adapter.Fill(dataTable);
    }
}

And here is the class using the ODP.NET provider:

class OracleProvider
{
    public static void RunTest()
    {
        var conn = new Oracle.DataAccess.Client.OracleConnection(Params.ConnectionString);
        var cmd = new Oracle.DataAccess.Client.OracleCommand(Params.CommandText, conn);
        var adapter = new Oracle.DataAccess.Client.OracleDataAdapter(cmd);
        var dataTable = new DataTable();
        adapter.Fill(dataTable);
    }
}

I ran the test one after the other:

class Program
{
    static void Main(string[] args)
    {
        OracleProvider.RunTest();
        MicrosoftProvider.RunTest();
    }
}

To compare the execution of each provider I ran this code using the VS 2010 Profiler, which by the way is very cool. The visualization of the tests has improved a lot since VS 2008. Here are the results summary:

 Profiler Summary

 As you can see there is a huge difference! The ODP.NET had less than 10% of the samples taken during processing while more than 90% were taken while running the method with the OracleClient provider. The report will also show you the information in more detail:

 Main method details

And the coolest view of them all will even show the percentage used overlapping the code:

Cool, right? I think so! Ok, now back to our tests... Before wrapping the post there is still one test I could do. I wanted to measure the execution time in seconds of each routine. To do this I used the Stopwatch class.

class Program
{
    static void Main(string[] args)
    {
        Time(() => OracleProvider.RunTest());
        Time(() => MicrosoftProvider.RunTest());
    }

    static void Time(Action action)
    {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        action.Invoke();
        stopwatch.Stop();
        Console.WriteLine(stopwatch.Elapsed);
    }
}

When I ran the code I got the following results:

ODP.NET: 20.6756 seconds

OracleClient: 41.7716 seconds

The conclusion for the article is simple. The ODP.NET provider is way faster than the Oracle provider offered by Microsoft. On top of it all, as I mentioned in my previous post, many of the classes in the System.Data.OracleClient namespace are marked as obsolete. Microsoft no longer is going to keep working on them in the future.

Comments

Posted by: Stephen Pollett
On: 2/4/2011 1:50:16 PM

This is a great article. We are trying to convert an existing solution to ODP.NET which uses Datasets and I'm wondering how to get these Datasets to use ODP instead of the Microsoft provider (System.Data.Oracle). We changed connection strings to use the new provider, but the code that was auto-generated for my datasets (MyDataset.Designer.vb) still appears to be using the MS provider. How can I change that?
Posted by: Eric
On: 3/8/2011 11:33:49 PM

Dear Gabriel Bogéa Perez,

This is a good article,
but I thought something is missing .
if you run the same SQL twice continuously,Oracle will give you difference response time ,in otherword,first run should be slower than later,because first run need more jobs for ORACLE to process,for example parse SQL/Check Data Dirctionary...etc
(Just my personal opinion,maybe it is wrong..)

Eric .

Posted by: Kindle Review Blog
On: 6/7/2011 12:41:40 PM

Thank you for good idea and the way how to implement it.
Posted by: Kevin Wang
On: 7/21/2010 3:12:46 AM

Hi Gabriel,

This topic is so worth to me.

Bcz, I have a program made by the other person and the program is using System.Data.OracleClient provider to doing some executions.

But, that program had bed performance(85900 records need spends 51 minutes). I need some strong evidences to approve need to change provider into ODP.NET.

I think your sample code is using delegate to calculated spending times for that 2 processes.

But, I can't very understanding for delegate after I saw the documents in MSDN(http://msdn.microsoft.com/en-us/library/aa288459(v=VS.71).aspx).

Could you please provide your sample code to me?

Thanks!
Posted by: Gershon Hochman
On: 11/9/2010 8:10:30 AM

Gabriel,

thanks for valuable info. I would like to add that while ODP.NET is very good on selects - it really shines on bulk inserts. In your benchmarks ODP.NET was elsewhere between x2 to x10 faster than MS's product - in my experiments with bulk inserts the ratio was more like x100!

Here is a useful link (not mine) about bulk inserts with ODP.NET: http://dotnetslackers.com/articles/ado_net/BulkOperationsUsingOracleDataProviderForNETODPNET.aspx

Leave your comment

Author

Email (never displayed)

Website

Comment  
HTML is NOT allowed. Use regular line breaks and those will be respected.