Long-performing queries on a single table

working on that. main problem is that this is a live DB intertwined with other DBs and under constant load. so I don't think I'll get to sleep any time soon... sigh... Hey, thanks a whole bunch for sticking this out, I appreciate it!

No, actually. the volume of transactions is roughly the same as it's always been. this is an old, stable app that doesn't change much. I do need to go through all that SP code, though, to make sure none of my devs took any nasty shortcuts.

:astonished:
devs have access to live SQL Db??? dont you have a gating mechanism for deploying bits??

boss, you need to revisiting this whole thing, bottom up. its like easter egg fest, new surprises every post :grinning:

LOL No, they don't. But I'm not the only one approving code releases to live db. I just need to double-check after everyone dow, to make sure nobody's locking resources on this thing or running ad-hoc stuff. audit time...

1 Like

I want to go back to the original query - since this is a 'stack' or queue, then I would assume that you want the read process to pull the next available row (record) to be processed. If so - then do you really care (or need) to filter on [date] and [time]?

SELECT TOP 1
       @T_ID = id,
     , @T_TYPE = [type]
  FROM stack WITH(NOLOCK)
 WHERE machinenum = @T_MachineNum
   AND datetimepr <> 'INPROGRESS'
 ORDER BY
       [date]
     , [time]
     , priority desc;

Wouldn't this get you the earliest date (which should be today - if everything is processing as expected) with the earliest time and greatest priority. Just a thought...

Is it possible that all instances have allocated to their maximum allocation - and the OS needs additional memory? If these instances are not locking pages in memory then the OS could request memory from any instance...

On a system with a single instance and 32GB of memory - I would leave 4GB of memory for the OS. For a system with multiple instances - I would monitor more closely and increase the memory available to the OS if I saw any issues.

Also - do you have every instance set with 'Boost SQL Server Priority'? Or only this instance? I would definitely disable that feature - across all instances.

1 Like