ADO.NET the fastest? My foot!

  • Thread starter Rex the Strange
  • Start date
R

Rex the Strange

I just benchmarked a query against an Oracle database using three
different access techniques (OLDDB, ADO.NET and ODBC) and I found that
ADO.NET fared worse than all of them - almost twice as long as OLEDB!

Surely something is wrong here. I was under the impression that ADO.NET
was supposed to improve retrieval times, not slow it down! The results
are as follows - it is an average of five executions of the same query.
Code is included in case someone wants to tell me what I'm doing wrong.
The query itself is a fairly long select query that I can't post here
due to its proprietary nature - the actual query shouldn't affect these
results, anyway.

Please, someone, what's going on?

-----------------------------------------------------------
OLEDB: 1.21 Seconds
-----------------------------------------------------------

public String execute_query (String query, DataGridView data_grid)
{
Int32 rowcount = 0;
OleDbCommand command = new OleDbCommand (query, connection);
DataTable data_table = new DataTable ();
OleDbDataAdapter data_reader = new OleDbDataAdapter ();
try {
data_reader.SelectCommand = command;
data_reader.Fill (data_table);
data_grid.DataSource = data_table;
rowcount = data_table.Rows.Count;
} catch (Exception e) {
MessageBox.Show ("Failed" + Environment.NewLine + e.Message);
} finally {
data_table.Dispose ();
data_reader.Dispose ();
command.Dispose ();
}// try..catch..finally
return "Rows returned: " + rowcount.ToString ();
}// execute_query;

-----------------------------------------------------------
ODBC: 1.274 Seconds
-----------------------------------------------------------

public String execute_query (String query) {
Int32 rowcount = 0;
OdbcCommand command = new OdbcCommand (query, connection);
DataTable data_table = new DataTable ();
OdbcDataAdapter data_reader = new OdbcDataAdapter ();
try {
data_reader.SelectCommand = command;
data_reader.Fill (data_table);
rowcount = data_table.Rows.Count;
} catch (Exception e) {
MessageBox.Show ("Failed" + Environment.NewLine + e.Message);
} finally {
data_table.Dispose ();
data_reader.Dispose ();
command.Dispose ();
}// try..catch..finally
return "Rows returned: " + rowcount.ToString ();
}// execute_query;

-----------------------------------------------------------
ADO.NET: 2.056 Seconds
-----------------------------------------------------------

public String execute_query (String query) {
Int32 rowcount = 0;
OracleCommand command = new OracleCommand (query, connection);
DataTable data_table = new DataTable ();
OracleDataAdapter data_reader = new OracleDataAdapter ();
try {
data_reader.SelectCommand = command;
data_reader.Fill (data_table);
rowcount = data_table.Rows.Count;
} catch (Exception e) {
MessageBox.Show ("Failed" + Environment.NewLine + e.Message);
} finally {
data_table.Dispose ();
data_reader.Dispose ();
command.Dispose ();
}// try..catch..finally
return "Rows returned: " + rowcount.ToString ();
}// execute_query;
 
G

Guest

Rex the Strange,

All of your code examples are using ADO.Net.

If Select query execution speed is your primary concern, you should pick a
provider accordingly.

Kerry Moorman
 
M

Miha Markic [MVP C#]

Hi,

Your benchmark is really not accurate at all.
I mean you deduce that ado.net is slow from three examples??? And even don't
bother to check which operation is slow/fast?
Did you repeat the methods in a loop? No? Ever heard of JIT? etc...
 
R

Rex the Strange

Did you repeat the methods in a loop? No? Ever heard of JIT? etc...

Yeah, I did (loop). I just didn't post that part here.

So enlighten me. How can I make this faster?
 
R

Rex the Strange

Kerry said:
All of your code examples are using ADO.Net.

If Select query execution speed is your primary concern, you should pick a
provider accordingly.

Kerry Moorman

Well that would explain part of it. Can you elaborate on what you mean
by:

"pick a provider accordingly."

I have to use Oracle - I have no choice in the matter on that count.

rts.
 
C

Chris Mullins

Your test is a bit flawed.

First off, all of your methods are using ADO.Net. You're using a wide
variety of data providers, but they're all ADO.Net Data Providers.

You're never using the actual Oracle provided drivers for ADO.NET, so you
don't have a good baseline to start from. The Microsoft provider for Oracle
shouldn't be considered the ideal way to conenct to the Oracle Database.
Sure, it's good enough for many things, but I would be willing to bet it's
not nearly as tuned as (for example) the Sql Client provider for Sql Server.

You're not factoring in database connection times (are you using pooled
connections?), what's chached and what's not in the database, and a number
of other items.

I would love to see your test done in a more rigorous way. To do this,
you'll need to be a bit more methodical though.

I have, personally, been involved in a number of "What database to we buy,
and how do we connect to it?" decisions for very large applications. I've
had excellent success with SqlClient connecting to Sql Server, and the
Oracle Provider(from Oracle, not Microsoft), connecting to Oracle.
 
R

Rex the Strange

Chris said:
Your test is a bit flawed.

First off, all of your methods are using ADO.Net. You're using a wide
variety of data providers, but they're all ADO.Net Data Providers.

You're never using the actual Oracle provided drivers for ADO.NET, so you
don't have a good baseline to start from. The Microsoft provider for Oracle
shouldn't be considered the ideal way to conenct to the Oracle Database.
Sure, it's good enough for many things, but I would be willing to bet it's
not nearly as tuned as (for example) the Sql Client provider for Sql Server.

You're not factoring in database connection times (are you using pooled
connections?), what's chached and what's not in the database, and a number
of other items.

I would love to see your test done in a more rigorous way. To do this,
you'll need to be a bit more methodical though.

I have, personally, been involved in a number of "What database to we buy,
and how do we connect to it?" decisions for very large applications. I've
had excellent success with SqlClient connecting to Sql Server, and the
Oracle Provider(from Oracle, not Microsoft), connecting to Oracle.

OK. I'll cry uncle at this point. It seems that all I've managed to
demonstrate is that certain providers are faster than others. Allow me
to rephrase the question:

What do people think is the fastest way to connect to an Oracle
database?

rts.
 
W

William \(Bill\) Vaughn

There are at least three different "native" managed providers for Oracle.
Those sold by Microsoft, Oracle itself and DataDirect. Each has its
advantages and issues. In addition, you can also use generic (what I call
"OSFA") providers like ODBC and OLE DB that expose less native functionality
but can actually be faster in some cases.
As I discuss in my books, it's not how fast you ask the question--execute
the query. It's how long it takes the server to answer the question that
governs performance. Most performance tests I've seen don't measure anything
very well--and no, I didn't look at yours. The performance you seek might be
gained by better indexes, smarter queries, properly handling server-side
compiled code and a dozen dozen other factors.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
 
M

Miha Markic [MVP C#]

You might start by searching for bottleneck using a profiler.
Or simply compare various providers performance (as you did, but with
different parameters, etc) if performance is only thing that matters for
you.
 
G

Guest

I'll go with Oracle.
Take care that are also subtle differences in behavior between these
providers.
 
R

Rex the Strange

OSFA?

There are at least three different "native" managed providers for Oracle.
Those sold by Microsoft, Oracle itself and DataDirect. Each has its
advantages and issues. In addition, you can also use generic (what I call
"OSFA") providers like ODBC and OLE DB that expose less native functionality
but can actually be faster in some cases.
As I discuss in my books, it's not how fast you ask the question--execute
the query. It's how long it takes the server to answer the question that
governs performance. Most performance tests I've seen don't measure anything
very well--and no, I didn't look at yours. The performance you seek might be
gained by better indexes, smarter queries, properly handling server-side
compiled code and a dozen dozen other factors.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
 
C

Chris Mullins

Rex the Strange said:
What do people think is the fastest way to connect to an Oracle
database?

To be honest, in most cases it doesn't really matter. In almost all
real-world usage, your performance is going to be governed by how fast your
database can perform your queries. The issue of network lag time, and
database performance is going to be signifigantly more than the difference
in performance between providers.

If you're doing advanced Oracle stuff, I would go with the provider written
by Oracle. The drawback to this is that it requries (if I remember right) a
200+ meg installation on the machine. If all you have is a web server
hitting a database, this is plausable. If you're building a WinForms app
that's running on a few hundred workstations this isn't much of an answer.

Like all performance tuning, I wouldn't worry about it until you run into
performance problems. Go with whatever gets the job done and don't worry
about it unless you actually run into performance problems.

When/If you do hit performance problems, then take a methodical approach to
solving them. Use metrics and profilers - including a database profiler.

In the data layer for our IM Server, we use the Microsoft Provider for
Oracle. This simplifies the install, gives a good feature set, and has
worked fine. We don't do anything advanced though, as we also have data
layers for Postgres, MySQL, SQL 2000, SQL 2005, and a few others and they
all need to be interchangable based on a check-box during the installation
process.
 
W

William \(Bill\) Vaughn

OSFA::One Size Fits All--a generic interface designed to access a wide
variety of engines.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
 
C

Cor Ligthert [MVP]

Rex,

I thought that there are some videos on Google as benchmark between a
Ferrari and a Fiat.

It seems that the are at the end almost finishing at the same moment.

Just what I thought reading your message.

Cor
 
F

Frans Bouma [C# MVP]

William said:
There are at least three different "native" managed providers for
Oracle. Those sold by Microsoft, Oracle itself and DataDirect. Each
has its advantages and issues.

I wouldn't call Microsoft's or Oracle's 'native managed' providers ;).
Both are thin wrappers around the OCI, the oracle client interface
which does all the work, where ODP.NET is more powerful than MS's for
obvious reasons. The only fully native managed providers are the one
from DataDirect and the one from CoreLab, where the one from CoreLab is
way cheaper than the DataDirect one.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
R

Rex the Strange

Hi Rex,
Could u tell me how many number of Records are u fetching.

Nah. I'm bored with this thread. I screwed up. Give me a break. And
besides, I'm past this part of my project.

rts.
 
W

William \(Bill\) Vaughn

Ah, you're right. But the one-time cost of getting a deadly serious provider
(like the DataDirect version) makes a lot of sense to me. You get what you
pay for.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top