This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Long running custom SQL query since upgrade to NPM 12.4 and SQL 2016

We have a custom SQL query on availability we have been running for years for a client with 145 locations. It use to run in a matter of seconds till we upgraded to NPM 12.4 and SQL server 2016 SP2. Now the query runs for hours for more than 10 nodes. It will run in 4 seconds for 10 nodes or less. I have included the query that the reporting team is using in hopes someone can shed a light on what appears to have changed since upgrade.

SELECT Nodes.Caption AS Device_Name,

       av.[Availability] AS [Availability],

       downevents.cnt AS Down_Events

       FROM Nodes

       OUTER APPLY (

              SELECT AVG([Availability]) AS [Availability]

              FROM (

                     SELECT [NodeID],

                           [Timestamp],

                           [ResponseTime],

                           [PercentLoss],

                           [Availability],

                           [Weight]

                           FROM ResponseTime_CS_cur

                           WHERE [Timestamp] BETWEEN CONVERT(datetime2, '2019-05-07') AND CONVERT(datetime2, '2019-05-08')

                                  AND NodeID = Nodes.NodeID

                     UNION SELECT [NodeID],

                           [Timestamp],

                           [ResponseTime],

                           [PercentLoss],

                           [Availability],

                           [Weight] FROM ResponseTime_CS_Detail_hist

                           WHERE Timestamp BETWEEN CONVERT(datetime2, '2019-03-24') AND CONVERT(datetime2, '2019-03-25')

                                  AND NodeID = Nodes.NodeID                     

                     ) AS ResponseData

                         

              ) AS av

                   

       OUTER APPLY (

              SELECT COUNT(*) AS cnt FROM [Events]

              WHERE NetObjectID = Nodes.NodeID AND EventType = 1

              AND [EventTime] BETWEEN '2019-04-4' AND '2019-04-5') AS downevents

                   

     Where nodes.nodeid  >2 and nodes.nodeid <16

  • Can the query be tweaked to actually run for more than 10 nodes at a time?

  • tborgg​ I'm not sure what's going on in that environment, but I took off the "WHERE" part of you query, and limited it to top 100, and it took about 20-30 seconds to populate results for me. I changed it to top 500, then top 1000, and even removed the top limit altogether, and it seemed to take roughly the same amount of time each run.

    Being there are so many variables in play between environments, I'd recommend running diagnostics, opening a ticket, and calling support to have them take a look at it.

    Let us know how it goes, please.

    Thank you,

    -Will

  • tborgg​ Also, you can remove the "WHERE" line at the bottom (unless you need to only be looking at those nodes), and use test it little by little by adding "TOP 50/100/500/1000" up top.

    Directly after your SELECT, just add TOP 50, then try it again.

    SELECT TOP 50 Nodes.Caption AS Device_Name,