Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a task which receives an input and performs a series of tasks on the SQL server, which some depend on the content of the server and on the input. For that I use a lot of selects and then logic based on input and then insert or update. The network activity between the server and the client is high while performing those tasks because they depend on the content of the server.

Will I gain any significant boost or degrade in performance if I move this to a stored procedure while the sql server and client are on the same machine?

share|improve this question

migrated from stackoverflow.com Sep 29 '11 at 9:57

This question came from our site for professional and enthusiast programmers.

2 Answers 2

Yes you will get a performance boost if you do this entirely on the server as the IO will be contained entirely inside the database server. However, at the same time you will introduce a performance hit on the server potentially.

It's a trade-off but I'd say it's worth it if you have spare capacity.

share|improve this answer
    
My application hardly uses the database and its small part of it. my concern is that code might run slower on the database than in a compiled language like c. –  Dani Sep 28 '11 at 20:16
1  
I'd do it inside the database then. SQL Server stored procedures are extremely fast as they are compiled into steps which run inside a virtual machine inside the database server. Don't forget with a compiled language, you are still going to have to issue separate commands to the server and wait for the IO anyway. –  Chris Smith Sep 28 '11 at 20:21

Keep database logic in the database. I'd say your best bet is to utilize a stored procedure. That way you keep your data logic in SQL Server where it is more efficient (plan reuse, etc.).

The database engine is made soley for this sort of thing. Your application is still making calls to the database even if you keep your data logic in your application code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.