Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Abysmally bad performance of trivial select - what do I do wrong?

785293Aug 23 2010 — edited Sep 3 2010
I am still quite new to both C# and .NET, and while I have a certain amount of database experience, only for the last few months have I used a database from the C#/.NET environment.

My problem is performance. I access a remote high-performance database to retrieve a number of small records, typically 10.000, for local processing. When I call the SELECT statement from a tool like TOAD it takes virtually no time - less than a second. When I code the same statement in C# and use the adapter Oracle.DataAccess.Client it takes a LONG time - 10 to 20 minutes.

The code I have written is in this style:

string cmd2 = @"select .... from .... where .. = :1 and ... = :2";

OracleCommand command = new OracleCommand(cmd2, conn);
command.Parameters.Add("1", OracleDbType.Varchar2, stringVar1.Length).Value
= stringVar1;
command.Parameters.Add("2", OracleDbType.Varchar2, 5).Value
= stringVar2;
OracleDataReader reader = command.ExecuteReader();
xList = new List<XClass>();
while (reader.Read())
{
xlist.Add(new XClass((string)reader[0], (DateTime)reader[1], (DateTime)reader[2]));
}

As you can see, this is all very trivial. Retrieval from one table, no special processing, and one of the elements
of the WHERE clause is specifying a column that carries an index. So I cannot for my life figure out why this takes such
a long time.

I have tried using a DataSet and the OracleDataAdapter.Fill command; that took about the same time, perhaps a little more.

I have also tried the same request using System.Data.OracleClient (the adapter for Oracle that comes with Visual Studio). Same
result, no significant difference in the time it takes.

Is there some kind of local configuration that I need to operate?

I am using Visual Studio 2008 SP1 and the Oracle Client is 11gR2.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2010
Added on Aug 23 2010
7 comments
1,670 views