December 17, 2003 at 10:19 am
I have a scheduled task which i want to run continually, but query a table periodically (e.g. every 1 second). I'm using a while loop with an always true condition, and a WAITFOR command to give to periodic interval. After a time of running, the process starts using huge amounts of CPU. The process is showing a status of sleeping in sysprocesses. Has anyone else encountered this and maybe resolved it.
Jon
December 17, 2003 at 10:27 am
Only when my waitfor was buggy and it went into a loop with no wait
December 18, 2003 at 8:32 am
Does this happen if you lengthen the amount of time in the interval? Since Windows is not a real time system, it may be the case that at some point the query didn't process and the subsequent query requests are starting to queue up (just a guess though).
Is it possible to make this process event driven instead of polling? For example, put a trigger on the table to let you know some change happened to the table when the change happens rather than polling the table every second.
December 18, 2003 at 8:42 am
I use a waitfor delay, so the wait won't start until the query completes anyway.
I've not tried testing what happens if i vary the interval.
It is possible i could use a trigger, but it would complicate matters!!
December 19, 2003 at 1:51 pm
Depending on how often you need it ran, you can also just schedule it as a job to run every minute. Since jobs won't start if they are already running, essentially this means that the proc will be ran back to back, with a maximum restart interval of one minute.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply