MariaDB 中的事件 VS php 中的 Cron - 哪个更好 [英] Events in MariaDB VS Cron in php - which is better

查看:20
本文介绍了MariaDB 中的事件 VS php 中的 Cron - 哪个更好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个建议.我有一个程序在 MariaDB 中调用另一个程序.他们都在计算距离和时间,并把它们放在一张桌子上.我需要这个计算在每晚 23:59:59 开始.我应该调用的过程有两个参数 - from_dateto_date.我的问题是->哪个更合适 - 制作一个将调用我的程序的 php Cron 或在 MariaDB 中制作一个事件?如果您认为该事件是一个更好的解决方案,您能否告诉我是否可以在其中为 date_from 计算今天的日期时间,并在其中添加 24 小时来计算 date_to?提前谢谢你!

I need an advice. I have a procedure which is calling another procedure in MariaDB. They both are calculating distances and times and put them in a table. I need this calculation to start every night at 23:59:59. The procedure which I should call have two parameters - from_date and to_date. My question is -> which is more appropriate - To make a php Cron which will call my procedure or to make an event in MariaDB? And if you think that the event is a better solution, can you tell me if it is possible to calculate today's datetime in it for date_from and add 24 hours to it to calculate date_to? Thank you in advance !

推荐答案

简答:PHP、Cron 和 Bash

这完全取决于您的程序以及将处理和影响多少行.程序内部的查询复杂度也起着重要的作用.

It solely depend on your procedure and how many rows will be processed and affected. Query complexity inside the procedure also play important rule.

简而言之,如果你的程序是轻量级的,你不会注意到两者的区别.

In short, if your procedure is light weight, you wont notice the difference of both.

但是,对于生产服务器的日常使用,我更喜欢使用 PHP、Cron 和 Bash 来完成这项工作,因为它可以更好地控制工作的执行方式.我可以在执行作业之前添加预检查,包括系统负载和条件,包括检查每个输入行和受影响的结果行.

But, for daily use in production server, I prefer to use PHP, Cron and Bash to do the job, because it offer much more control on how the job will be conducted. I can add pre-checking, including system load and condition, before executing the job, including checking each input row and affected results rows.

这篇关于MariaDB 中的事件 VS php 中的 Cron - 哪个更好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆