Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code performance: SQL Server Query vs C#.Net web application

I am writing a complex logic to calculate sales and customer bonuses. I have million of records to calculate bonuses.

I want expert opinions so that mathematical operation don't take much time to display result on web page.

So where I need to write calculation part? In SQL Server Queries (Using Stored Procedure and functions) or ASP.NET & C#.Net (Business Logic layer)?

Which one is the best practice? Processing on Database server or Processing on Application server?

Regards

Mohsin JK

like image 622
Mohsin JK Avatar asked Apr 18 '12 07:04

Mohsin JK


2 Answers

If you have millions of records then I would suggest you to write calculation part in SQL Server as calcuations in Business Layer will significantly take more time.

Following are suggestions to improve performance -

  • Write Stored Procedures
  • Create Indexes to fetch records faster
  • Use of temp tables if manupulation is for huge records

You can search on net to find out T-SQL other performance optimization techniques.

like image 161
Parag Meshram Avatar answered Oct 19 '22 19:10

Parag Meshram


I have million of records to calculate bonuses

I think it is better to calculate it in database to avoid passing large amounts of data from the database to application.

like image 28
Artem Koshelev Avatar answered Oct 19 '22 19:10

Artem Koshelev