I have a question related to performance, speed and optimization.
So I have a employee table. There is a field as joiningDate
. I want to change employee designation
after 3 months since employee joined.
That means I have to run cron job every day as there are many employees having different joiningDate
.
I am using NodeJS and ExpressJS for backend and MySQL for database.
So what should be the best in this scenario? Cron Jobs or MySQL Events? Which one is faster and best for this situation
Asked
Active
Viewed 1,077 times
0

Barsigo Patoo
- 5
- 4

Asad Marfani
- 177
- 3
- 13
-
1why not test and find out? – treyBake Jul 09 '18 at 10:06
-
Yeah that's a better suggestion. But I am doing it for the first time that's why I need to get guidance from the experienced developers, like you. :) – Asad Marfani Jul 09 '18 at 10:08
-
There is no clear cut answer to your question because it is too general. You truly need to experiment with both solution before making up your mind. – Shadow Jul 09 '18 at 11:20
1 Answers
0
Mysql introduce Event scheduler which we can use alternative to Cronjob. There are many advantages over cronjob like:
1) It is directly written on Mysql Server.
2) This is platform independent. Your application might be written in any language it does not matters. You just need to know mysql.
3) We can use them whenever there is a database update or cleanup required at regulare interval.
4) No need to compile queries every time hence performace increased.
5) Error can be log in log files.

munsifali
- 1,732
- 2
- 24
- 43