user34537
user34537

Reputation:

When should I use stored procedures (in mysql)?

I seen this but its 3 years old and I assume the tech on most database is more optimize When should I use stored procedures?

I'm using mysql, when should i use stored procedures? IMO I should never unless i need performance. Then I read that there ISN'T a performance boost. Then I read there is but its compiled everytime i call the procedures for the first time on a connection. But even then its not helpful because its only speeds up parsing which takes no time.

I don't know if i got this right? But maybe i'm forgetting something big. I don't see any benefits for logic being there because my preference is having a lib or shared code (and there isn't any real cons doing this way).

But i never used a stored procedures so this is why i am asking.

Upvotes: 1

Views: 469

Answers (1)

Alain Collins
Alain Collins

Reputation: 16362

There are a couple of times when procedures are interesting to me:

  1. When I want to entirely encapsulate access to the database by forcing apps to use the stored procedures. This can be good for an organization with a strong/large database group and a small/weak programming team. It's also helpful when you have multiple code bases accessing the database, because they all get one interface, rather than each writing their own queries, etc.
  2. When you're repetitively doing something that should be done in the database. You'll know it when you see it.

So, unless you're a serious control freak (or are building some huge system like a bank), 90% of the time you won't need them.

Upvotes: 2

Related Questions