Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Sarah_MacG
Engaged Sweeper II

Hey guys,

I'm not a reporting pro what so ever and so I'm turning to the community for some help!  I have this custom report that takes roughly 30 minutes to load. Was wondering if I could get some help with making it more efficient.  File attached..

2 REPLIES 2
rinks
Champion Sweeper

1. Just a few observations based on the code, but you can filter the tblQuickFixEngineering before joining: 

LEFT JOIN (
SELECT AssetID, MAX(Convert(date, InstalledOn)) AS lastPatchDate
FROM tblQuickFixEngineering
GROUP BY AssetID
) AS patch ON patch.AssetID = tblAssets.AssetID

Then refer to patch.lastPatchDate in the SELECT and ORDERBY.

2. To hit indexes faster, change LIKE '%forti%' to: softwareName LIKE 'forti%' OR softwareName LIKE '%forticlient%'
or pre-filter tblSoftwareUni by name first and then join.

3. There's also a duplicate calculation. You can format into a CTE or simplify it:
-- Remove from GROUP BY:
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) / 3600 / 24))) + ...

Instead, alias this once in SELECT and remove it from the GROUP BY:
, tblAssets.Uptime AS RawUptime -- Group by this

4. Change FULL JOIN to LEFT JOIN unless you need unmatched users from both sides, LEFT JOIN is more appropriate:
LEFT JOIN tblADusers ON tblADusers.Username = tblAssetUserRelations.Username

5. Add a date filter if you're only interested in assets seen recently:
WHERE tblAssets.Lastseen > DATEADD(month, -3, GETDATE())

Summary:

Issue Recommendation

Slow MAX() and date conversionPre-aggregate tblQuickFixEngineering in a subquery
Multiple LIKE %...% filtersUse more specific matches or indexes
Duplicate uptime calculationMove to CTE or simplify
FULL JOINChange to LEFT JOIN
No data limitAdd time-based filters if appropriate

 

------------------------------------------------
Union Home Mortgage's "Lansweeper Guy"
------------------------------------------------
Sarah_MacG
Engaged Sweeper II

Thank you!  I will try these reccomendations and let you know.  🙂

Reports & Analytics

Ask about reports you're interested in and share reports you've created. Subscribe to receive daily updates of reports shared in the Community.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now