开发者

Best way to run a periodic query in MySQL

开发者 https://www.devze.com 2022-12-21 05:22 出处:网络
In my Rails application I have a separate process (BackgroundRb) to delete all transaction开发者_开发百科s which are not successful and it must be run after every five minutes.

In my Rails application I have a separate process (BackgroundRb) to delete all transaction开发者_开发百科s which are not successful and it must be run after every five minutes.

But in BackgroundRb, it runs a database check after every second though my query executes periodically at the specified time(after 5 minutes).

So my question is what is the best approach for this kind of scenario?

Should I use a Stored procedure in which the query is executed inside a infinite loop, not giving burden on Rails application (since BackgroundRb is accessing database at every second) or should I use a different application like Wokling to stop such frequent database access as BackgroundRb does?


I'd recommend a separate script run by cron. Cron is present on every hosting.

0

精彩评论

暂无评论...
验证码 换一张
取 消