Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you have too many stored procedures?

Is there such a thing as too many stored procedures?

I know there is not a limit to the number you can have but is this any performance or architectural reason not to create hundreds, thousands??

like image 377
Brian G Avatar asked Sep 25 '08 20:09

Brian G


People also ask

Why you shouldn't use stored procedures?

Stored procedures promote bad development practices, in particular they require you to violate DRY (Don't Repeat Yourself), since you have to type out the list of fields in your database table half a dozen times or more at least. This is a massive pain if you need to add a single column to your database table.

How many stored procedures can be called from a stored procedure?

Although stored procedures allow nesting and recursion, the current maximum stack depth of nested calls for user-defined stored procedures is 5 (including the top-level stored procedure), and can be less if individual stored procedures in the call chain consume large amounts of resources.


2 Answers

To me the biggest limitation to that hundreds or thousands store procedure is maintainability. Even though that is not a direct performance hit, it should be a consideration. That is an architectural stand point, you have to plan not just for the initial development of the application, but future changes and maintenance.

That being said you should design/create as many as your application requires. Although with Hibernate, NHibernate, .NET LINQ I would try to keep as much store procedures logic in the code, and only put it in the database when speed is a factor.

like image 64
David Basarab Avatar answered Sep 30 '22 01:09

David Basarab


Yes you can.

If you have more than zero, you have too many

like image 28
Orion Edwards Avatar answered Sep 30 '22 03:09

Orion Edwards