i.e, can we just use stored procedures for everything? In a web-site backed by a DB that is.
Asked
Active
Viewed 118 times
0
-
No, Clearance in your question. – Sai Kalyan Kumar Akshinthala May 04 '11 at 04:57
-
We're working on a distributed web app. My team-mate wants to use MySql stored procedures for most everything... – Ada May 04 '11 at 04:58
2 Answers
1
Stored Procedures have their benefits:
- Minimize traffic back & forth between the application & database, wasting bandwidth
- MVC: Separation of persistence layer
- Scale loads better than application code (IE:
ORDER BY
will always trump application code)
Stored Procedure Cons:
- Database dependency - ANSI is becoming more widely supported, but stored procedure code (not the query/queries in them) is not standardized at this time
Conclusion
Yes, stored procedures & functions can do most of what you'd probably ever want to do with data. The decision to use them is determined by design choices - to be database agnostic, most would not use stored procedures. Choose what best suits the requirements, not your preference.

OMG Ponies
- 325,700
- 82
- 523
- 502
-
1With regard to the original question - using stored procedures 'for everything' - it's almost certainly a very bad idea. – magma May 04 '11 at 05:36
-
as in "Yes, stored procedures & functions can do most of what you'd probably ever want to do with data", you mean? I agree. – magma May 04 '11 at 16:38
-
@magma: "most" isn't an absolute, while "almost certainly is a very bad idea" is dangerously close. – OMG Ponies May 05 '11 at 00:37
0
In short: no. And, that's probably a bad idea.
See: Arguments for/against Business Logic in stored procedures
-
-
Not a great question to refer to - the issue is subjective/argumentative, and really depends on the application design. – OMG Ponies May 04 '11 at 05:07
-
@omg *Because* the issue is subjective *and* it depends on the application design *and* we don't know much about Ada's application design, it's a worth read. – magma May 04 '11 at 05:35
-
So, you're unable to ask for clarification? Or just unwilling, when you could've supplied the link on the premise of being an exact duplicate? – OMG Ponies May 05 '11 at 00:38