Click here to Skip to main content
15,906,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends ......!

I want to know why loop in sql2008,2005, etc. is very fast as compare to .Net loops. What i want to ask will clear with following Example

Suppose, i Have Query which select Data from multiple tables and put it in another table (table name tblTemp) . Now after this i am updating multiple columns( around 30 Columns) of table tblTemp.

Now, what Logic say , the Sql will look for condition and will match with each row of table tblTemp , it will update rows which match condition.

Same procedure will be used for 35 Columns. It will update all columns in fraction of seconds.

But , If I do same thing in .Net(C#,VB.Net) i.e If I retrieve all data and bind it with Datagridview and i try to update 35 columns then it takes around Minute.

My Question why loops which we used in .net take lot of type.
Posted

1 solution

SQL server is sitting on the data and it is optimized to use indexes.

Your .net application is on another process and most likely on another machine, so it has to get all the data to do work on hence data must be transferred/marshaled to it over a network [library].

Datagridview are UI objects and do a lot of extra work also like formatting and layout, you will find a performance boost if you do your work on DataSets or DataTables only.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900