Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Reading from MS SQL database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-11-20 : 08:03:22
Prakash writes "Hi,

I have an ETL application in C# that processes 10-20 million recordsin a single run. I have set it up so that it processes in chunks of few thousand records at a time.

In th process of optimizing the read from operational database I found that each read is taking about 800 milliseconds. I ran the same stored proc (used for reading from application) from query analyzer and it takes only about 200 milliseconds.

This was little surprising so I checked the execution plan for both but they are exactly same and doing exactly same number of reads too (captured data from profiler). I have repeated this several times and made sure there was nothing cached but same recults


This is how I create connection in application

cStr = "Initial Catalog=myDB; Data Source=myServer; Integrated Security=SSPI; Connect Timeout=300";
SqlConnection cn = new SqlConnection (cStr);
cn.Open();

This is how I execute stored proc

SqlCommand cmd = new SqlCommand(sqlString, connection);
cmd.CommandType = CommandType.StoredProcedure;
//set params
SqlDataReader readAllCursor = cmd.ExecuteReader();


Any ideas why reading from C# application so slow compared to from query analyzer?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-11-20 : 08:05:02
Query Analyzer has less overhead than .Net. You didn't specify how you determined the 800ms read time, and I would wager that it's probably taking about the same time to read the data, but the extra 600 ms of .Net overhead is invisibly lumped in there.
Go to Top of Page
   

- Advertisement -