Why does the performance differ so greatly with seemingly the same code?

C# code and SQL procedure performance question.?

  • Hi Friends, I am doing following things. 1) I am pushing 50 rows into a SQL table every 1 Min. 2) At same time, I am retrieving 180 Rows of data from same table based on primary key, using Views. 3) Now, from 180 Rows, I have to loop and find out open price, max price, close price. Currently I am doing using SQL Procedure to do the same. 4) My question is, If I directly use C# code (3.5 .NET framework) to retrieve all 180 rows from SQL (using select stored procedure) and loop through all the 180 rows to find close price, open price, high price in C# code. Will this be faster? 5) Or looping using WHILE in stored procedure in SQL would be faster? 6) Also I would like to know in terms of performance and robustness. Looking for expert opinion. :) Regards, AP

  • Answer:

    I can tell you from personal experience that any record operations are quicker at the database level. We have benchmarked stuff like this. Although it is MUCH easier and there are many more language tools for working with values in C# as opposed to T-SQL, the database will indeed be faster. Whatever you do, DO NOT use any edmx (entity data model) garbage. If you're going to do the work in the .NET code as opposed to the database T-SQL, write your own stuff.

maverick at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.