Link to home
Start Free TrialLog in
Avatar of Amour22015
Amour22015

asked on

SQL Server 2012 r2 - Sum causes too much time

Hi Experts,

I have this small query:
SELECT 
        rd.[ScanDate]
       ,Rd.Plugin as [Plugin] 
       --,Sum(rd.[Total Vulnerabilities]) as [Total Vulnerabilities] 
    
FROM  dflt.SCCM_v_R_System as srs
       inner join  dflt.Systems AS rs on rs.IPLong = srs.IPLong
       inner join [Dflt].[ReportsData_ALLPluginsTotalsOS] as rd On rs.Plugin = rd.Plugin
 
WHERE rs.ScandateID in (Select top 6 ID From Dflt.ScanDates Order by ID desc)  
 
Group By rd.ScanDate, rd.Plugin

Open in new window


When I introduce the line:
,Sum(rd.[Total Vulnerabilities]) as [Total Vulnerabilities]

This query will come from .37 to > 2 mins. on timing.

What can I do to the Sum line to make this more faster?

Thank You for helping...
SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you can post the query execution plan when you're using the SUM it would be helpful to understand what's causing the issue.
Avatar of Amour22015
Amour22015

ASKER

Thank you all for helping as for a Execution plan.  I know that the tables a large and the Vulnerablity total would take time.  Just looking for a way to improve query performance.