I have few questions about using functions in a MySQL database for plugins and extensions of web apps like Magento or Wordpress. Mostly this is for a few extensions I want to do for Magento. The questions are:

  1. is it possible under normal average hosts out there, that functions can be added.
  2. (if 1) is it worth the effort to create function that would replace php in some manner (speed mostly is what I'm thinking)
  3. (if 1) can functions be looped? like timed or call to it's self x time like sleep or something.

I was wanting to use the db for simple things like removing rows that were older then or something like that. Examples are not as important as possibility here in my mind. This is more of a set of questions that are due to not every really seeing web app use functions, and it just seems like an area of untapped potential for optimization when designing web apps.

1 Answer 1


I can't answer to question 1 as I do not have enough information about the MySQL instances offered by different hosting providers.

To answer the rest of your questions, yes, if you can leverage the features of the RDBMS you're using, you might replace PHP code with SQL scripts that can run faster than your code. Just think about the time you're saving up by not transferring your data back and forth.

On the other hand you would probably still end up using PHP code or other programs (crontab or any other kind of scheduler) to run your timed tasks as there's no built-in scheduler in MySQL.

  • well there is events that can be created, but yes, the goal is not to replace php in hole, but to internalized things that would be faster to do with a query and store functions. I guess I'm left wondering why I never see web app use MySQL functions.
    – Quantum
    Commented Jul 7, 2014 at 21:04

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.