0

i.e, can we just use stored procedures for everything? In a web-site backed by a DB that is.

2
  • No, Clearance in your question. May 4, 2011 at 4:57
  • We're working on a distributed web app. My team-mate wants to use MySql stored procedures for most everything...
    – Ada
    May 4, 2011 at 4:58

2 Answers 2

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.

3
  • 1
    With regard to the original question - using stored procedures 'for everything' - it's almost certainly a very bad idea.
    – magma
    May 4, 2011 at 5: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 4, 2011 at 16:38
  • @magma: "most" isn't an absolute, while "almost certainly is a very bad idea" is dangerously close.
    – OMG Ponies
    May 5, 2011 at 0:37
0

In short: no. And, that's probably a bad idea.

See: Arguments for/against Business Logic in stored procedures

4
  • Thank You - golden answer here
    – Ada
    May 4, 2011 at 5:03
  • Not a great question to refer to - the issue is subjective/argumentative, and really depends on the application design.
    – OMG Ponies
    May 4, 2011 at 5: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 4, 2011 at 5: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 5, 2011 at 0:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.