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

发布于 2024-09-12 07:36:36 字数 126 浏览 1 评论 0原文

没有冗余数据的完全规范化数据库在“学术上”是好的,但在现实世界中的性能却很糟糕。

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静谧幽蓝 2024-09-19 07:36:36

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

基本上,cron 作业是一个计划作业(无论您希望运行的频率如何),并且触发器...好吧...触发。一般来说,当您想要的任务是以下一项或两项时,您将使用任何类型的调度(Cron、计划作业(在 MS Sql 世界中)等):
* 时间不敏感
* 流程密集。

对于任何对时间敏感且处理不密集的事情,您都可以使用触发器。

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

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

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.

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文