SQL Server的工作与precise时机 [英] SQL Server Job with precise timing
问题描述
我有游戏数据(地图,玩家,等...)一个DB,我有写在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服务器停止响应。如果我设置的时间间隔大于1分钟,一切都ok了。
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.
我需要时间的游戏循环precise,例如游戏循环将只运行一次,将被执行的每个X,precisely(公差应小于一秒)。
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分钟,因此,precision下降到第二是不可能的。
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的工作与precise时机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!