在什么情况下你会使用或不使用数据库触发器而不是cron调用的脚本?

时间:2022-01-11 08:02:03

A fully normalized database with no redundant data is good "academically", but has terrible real-world performance.

没有冗余数据的完全标准化的数据库在“学术上”是好的,但具有可怕的真实性能。

The first optimization is obviously a cache system. After this, for creating redundant data for performance, when or why would (or wouldn't) you use triggers over a cron task that calls a script to update the redundant data?

第一个优化显然是缓存系统。在此之后,为了创建性能冗余数据,何时或为什么(或不会)在调用脚本来更新冗余数据的cron任务上使用触发器?

1 个解决方案

#1


4  

Not a MySQL guy, but the concept should port...

不是MySQL人,但概念应该移植...

Basically, a cron job is a scheduled job (however frequently you want that run), and a trigger is... well... triggered. In general, you would use any kind of scheduling (Cron, scheduled jobs (in the MS Sql world), etc.) when the task you want is one or both of:
* Not Time Sensitive
* Process Intensive.

基本上,一个cron作业是一个预定的作业(不管你经常想要那个运行),并且触发器......很好......被触发了。通常,当您需要的任务是以下任一项或两者时,您将使用任何类型的调度(Cron,预定作业(在MS Sql世界中)等)。*不是时间敏感*过程密集型。

For anything that is time sensitive and not process intensive, you'd use a trigger.

对于任何对时间敏感且不是过程密集的事物,您可以使用触发器。

For those cases where something is both time sensitive and process intensive, you have to decide which is more important (or handle the crunching outside of SQL in code somewhere).

对于那些时间敏感且过程密集的情况,你必须决定哪个更重要(或者在代码中的某个地方处理SQL之外的运算)。

#1


4  

Not a MySQL guy, but the concept should port...

不是MySQL人,但概念应该移植...

Basically, a cron job is a scheduled job (however frequently you want that run), and a trigger is... well... triggered. In general, you would use any kind of scheduling (Cron, scheduled jobs (in the MS Sql world), etc.) when the task you want is one or both of:
* Not Time Sensitive
* Process Intensive.

基本上,一个cron作业是一个预定的作业(不管你经常想要那个运行),并且触发器......很好......被触发了。通常,当您需要的任务是以下任一项或两者时,您将使用任何类型的调度(Cron,预定作业(在MS Sql世界中)等)。*不是时间敏感*过程密集型。

For anything that is time sensitive and not process intensive, you'd use a trigger.

对于任何对时间敏感且不是过程密集的事物,您可以使用触发器。

For those cases where something is both time sensitive and process intensive, you have to decide which is more important (or handle the crunching outside of SQL in code somewhere).

对于那些时间敏感且过程密集的情况,你必须决定哪个更重要(或者在代码中的某个地方处理SQL之外的运算)。