Sql-server – stored procedures location influence their performance

performancequery-performancesql serverstored-procedures

I have a procedure SP_MYPRO that updates data in MYDB1.

1) the performance of SP_MYPRO would be different if I place it in MYDB2 instead of MYDB1?

2) what if the procedure SP_MYPRO only read data, does not update anything?

Best Answer

This is something you can easily test for yourself, but in my testing, no, there is no significant overhead in calling a stored procedure across a database boundary (I am sure you could make something noticeable though if you tried hard enough).

However, I would say that a stored procedure should live closer to the data that it manipulates than the object(s) that call it. This way, if you move the database, all that breaks is the remote calls to that procedure, rather than all of them.