具有精确计时的 SQL Server 作业 [英] SQL Server Job with precise timing

查看:31
本文介绍了具有精确计时的 SQL Server 作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含游戏数据(地图、玩家等)的数据库,我有一个用 T-SQL 存储过程编写的游戏核心机制.

I have a DB with game data (map, players, etc...) and I have a game core mechanics written in T-SQL stored procedure.

我需要每X"秒处理一次游戏循环(通过存储过程).

I need process game loop (via the stored procedure) every "X" seconds.

我尝试使用 SQL 作业,但是当我将间隔设置为秒时,SQL 服务器停止响应.如果我将间隔设置为大于一分钟,则一切正常.

I tried used the SQL Job, but when I set the interval to seconds, the SQL server stops responding. If I set the interval greater than one minute, all was ok.

我需要在时间上精确的游戏循环,例如游戏循环只会运行一次,并且会精确地每隔X"执行一次(容差应小于一秒).

I need game loop precise in time, e.g. the game loop will run only once and will be executed every "X" precisely (tolerance should be less than one second).

我可以使用 SQL Server 功能来实现吗?或者我应该创建一个将重复执行游戏循环程序的 Windows 服务?还是我应该走另一条路?

Can I do it with SQL Server capabilities? Or should I create a windows service which will repeatly execute game loop procedure? Or should I go another way?

谢谢!

游戏循环存储过程占用的时间少于间隔.

The game loop stored procedure takes less than the interval.

推荐答案

我会为此使用 Windows 服务.有一个线程休眠的循环,让它每 x 秒等待一次.

I would use a windows service for this. Have a loop with a thread sleep in it to get it to wait every x seconds.

SQL 服务器中使用的计时器作业类型的问题在于,有一个计时器服务检查是否有需要运行的作业.例如,此计时器作业可能每 2 分钟检查一次,因此不可能精确到一秒.

The problem with timer jobs of type used in SQL server, is that there is a timer service checking if there is a job that need to be run. This timer job may check for example every 2 minutes, so precision down to a second is not possible.

这篇关于具有精确计时的 SQL Server 作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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