How to Prevent Sql Server Jobs to Run simultaneously(如何防止 Sql Server 作业同时运行)
问题描述
我的 SQL 代理中有一些预定的作业:
I have some scheduled jobs in my SQL Agent:
- Job1,每 2 分钟执行一次
- Job2,每 10 分钟执行一次
- Job3,每 15 分钟执行一次
如您所见,多个作业可以同时运行.当这些作业同时运行时,会导致 CPU 使用率达到 100%.
As you can see, multiple jobs can run simultaneously. When these jobs do run simultaneously, it is causing the CPU usage to go to 100%.
有解决办法吗?有没有办法控制并发运行的作业数量?注意:我需要这些作业在适当的时间内大约运行.
Is there a solution? Is there a way to control the number of jobs running concurrently? Note: I need these jobs to run approximately in their appropriate period.
推荐答案
通过 sp_getapplock
您要求用户控制并发,这通常是最好的方法.
You're asking for user-controlled concurrency and this is usually the best way.
这允许您在锁已被另一个作业持有时等待或中止.我们在一两个地方使用它来阻止多个用户强迫同一任务重叠运行.效果很好.
This allows you to wait or abort if the lock is already held by another job. We use it in one or 2 places to stop multiple users forcing the same task to run overlapping. It works well.
这篇关于如何防止 Sql Server 作业同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何防止 Sql Server 作业同时运行


- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 更改自动增量起始编号? 2021-01-01