Strange slow down with imbricated DataReader (Oracle, c#)

G

Guy

This is my first c# windows app.

I create a data reader on an Oracle table. Returns 552 rows. I iterate
thru them, goes like light speed.

Next, for each row returned, I need to fetch from another table to get
some other information. When I do that, my program takes 20s instead
of 1s. I even downgraded my inner SQL to become "select 1 from dual",
same performance hit!

Is there a problem with Oracle under c# using two DataReader at the
same time?

Here's the code:

con = new System.Data.OracleClient.OracleConnection();
con.ConnectionString = "user id=xx;data source=xx;password=xx";

public void Process(ProgressBar progBar)
{

OracleDataReader dr;
OracleCommand cmd;

dr = GetMainDR()
while (dr.Read())
{
// get some columns
...
cmd = new OracleCommand("select 1 from dual", con);
Decimal i = (Decimal) cmd.ExecuteScalar(); <----- slows down
everything
cmd.Dispose();
...
}

}

public OracleDataReader GetMainDR()
{
OracleDataReader dr;
OracleCommand cmd;


cmd = new OracleCommand("select * from TABLE_OF_552_ROWS", con); //
change
dr = cmd.ExecuteReader();

return dr;
}
 
M

Marina

I am surprised you don't get an exception, must be something about the
Oracle provider.
Normally, you can only have one open datareader on a given connection.
Trying to open a second one before closing the first, causes an exception.
 
W

WJ

Next, for each row returned, I need to fetch from another table to get
some other information. When I do that, my program takes 20s instead
of 1s. I even downgraded my inner SQL to become "select 1 from dual",
same performance hit!

I would try Procedure with Relation, it should be lightening fast.

John
 

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