5

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

2
  • 1
    if those millions of rows are already in a SQL Server database - process the data there! Have a stored procedure generate the results, put it in a table, and then just show the results from that table in your ASP.NET webpage. Commented Apr 18, 2012 at 7:27
  • If your calculation requires extensive use of aggregations, you can take a look on materialized views. en.wikipedia.org/wiki/Materialized_view Commented Apr 18, 2012 at 8:08

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Agree. Additionaly, I'd suggest considering CLR functions. For complex calculations CLR might be significantly faster than plain T-SQL. Or it might not be in this particular case, so testing is necessary.
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.