• Alternative to WAITFOR DELAY

    From Anton Shepelev@21:1/5 to All on Wed Nov 29 23:38:36 2017
    Hello, all

    Is there a more granular way to ease a tight polling
    loop in T-SQL than WAITFOR DEALAY? A delay of 3.33
    milliseconds being a tad too long for my purposes, I
    seek a way to implement delays of about half a mil-
    lisecond or shorter. I do not need the precision of
    real-time systems and will accept any solution to
    prevent a fast WHILE 1=1 loop from hogging the CPU.

    --
    () ascii ribbon campaign -- against html e-mail
    /\ http://preview.tinyurl.com/qcy6mjc [archived]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Erland Sommarskog@21:1/5 to Anton Shepelev on Wed Nov 29 22:49:29 2017
    Anton Shepelev (anton.txt@gmail.com) writes:
    Is there a more granular way to ease a tight polling
    loop in T-SQL than WAITFOR DEALAY? A delay of 3.33
    milliseconds being a tad too long for my purposes, I
    seek a way to implement delays of about half a mil-
    lisecond or shorter. I do not need the precision of
    real-time systems and will accept any solution to
    prevent a fast WHILE 1=1 loop from hogging the CPU.


    I guess that you could write a CLR procedure for the task.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Shepelev@21:1/5 to All on Thu Nov 30 13:58:58 2017
    Erland Sommarskog to Anton Shepelev:

    Is there a more granular way to ease a tight
    polling loop in T-SQL than WAITFOR DEALAY? A de-
    lay of 3.33 milliseconds being a tad too long for
    my purposes, I seek a way to implement delays of
    about half a millisecond or shorter. I do not
    need the precision of real-time systems and will
    accept any solution to prevent a fast WHILE 1=1
    loop from hogging the CPU.

    I guess that you could write a CLR procedure for
    the task.

    Thanks. No idea why it didn't occur to me. I have
    written .NET assemblies for MSSQL before. If per-
    formace testing shows a need for a shorter delay I
    will definitely follow your advice.

    Meanwhile, my loop switches to zero delay once it
    finds work to do, and back to a 3.3 ms delay once
    all work is done and in incoming queue is empty.

    --
    () ascii ribbon campaign - against html e-mail
    /\ http://preview.tinyurl.com/qcy6mjc [archived]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)