I've got a large query that has many joins and returns roughly 13k records. I've noticed lately that there's a long pause within the program which this SP is executed, so I decided to run it in the Management Environment to see what's up. Here's the SQL:
I found this for execution times:
But when I comment out the Order By, I get a HUGE difference in Total time and wait time:
so is an Order By that costly? I am using the PK of the table but only in descending order (DESC).
Code:
SELECT Issues.*, c.CustomerName, l.LocationName, l.LocationShortName, r.RoomName,
poc.FirstName + ' ' + poc.LastName AS [POC], g.Name AS [Assigned Group], u.FirstName + ' ' + u.LastName AS [Created By],
u2.FirstName + ' ' + u2.LastName AS [Assigned User], ist.IssueStatus AS [Status], iss.IssueStatus AS [Sub-Status],
p.Priority, issueCat.IssueCategory, o.Origin, it.IssueType, csd_p.Product, csd_v.VersionNumber, svt.SupportVisitType,
u3.FirstName + ' ' + u3.LastName AS [Resolved By], csd_psv.ProjectedSoftwareVersion, poc.OfficePhone, poc.Email, poc.CustomerID,
poc.LocationID, csd_psv.ProjectedReleaseDate
FROM Issues Issues
LEFT OUTER JOIN AllPOCs poc ON Issues.POCID = poc.AllPOCID
LEFT OUTER JOIN Customers c ON poc.CustomerID = c.CustomerID
LEFT OUTER JOIN Locations l ON l.LocationID = poc.LocationID
LEFT OUTER JOIN Origins o ON Issues.OriginID = o.OriginID
LEFT OUTER JOIN Rooms r ON Issues.RoomID = r.RoomID
LEFT OUTER JOIN Groups g ON Issues.AssignedGroupID = g.GroupID
LEFT OUTER JOIN Users u ON Issues.CreatedByUserID = u.UserID
LEFT OUTER JOIN Users u2 ON Issues.AssignedUserID = u2.UserID
LEFT OUTER JOIN Users u3 ON Issues.ResolvedByUserID = u3.UserID
LEFT OUTER JOIN (SELECT * FROM IssueStatuses WHERE IsSubStatus = 0) ist ON Issues.IssueStatusID = ist.IssueStatusID
LEFT OUTER JOIN (SELECT * FROM IssueStatuses WHERE IsSubStatus = 1) iss ON Issues.IssueSubStatusID = iss.IssueStatusID
LEFT OUTER JOIN Priorities p ON Issues.PriorityID = p.PriorityID
LEFT OUTER JOIN SCMaster.dbo.Products csd_p ON Issues.ProductID = csd_p.ProductID
LEFT OUTER JOIN SCMaster.dbo.Versions csd_v ON Issues.VersionID = csd_v.VersionID
LEFT OUTER JOIN SCMaster.dbo.ProjectedSoftwareVersions csd_psv ON Issues.ProjectedSoftwareVersionID = csd_psv.ProjectedSoftwareVersionID
LEFT OUTER JOIN SupportVisitTypes svt ON Issues.SupportVisitTypeID = svt.SupportVisitTypeID
LEFT OUTER JOIN IssueCategories issueCat ON Issues.IssueCategoryID = issueCat.IssueCategoryID
LEFT OUTER JOIN IssueTypes it ON Issues.IssueTypeID = it.IssueTypeID
ORDER BY Issues.IssueID DESC
I found this for execution times:
Code:
Client Process Time: 234
Total Execution Time: 826
Wait time on Server Replies: 592
But when I comment out the Order By, I get a HUGE difference in Total time and wait time:
Code:
Client Process Time: 203
Total Execution Time: 296
Wait time on Server Replies: 93
so is an Order By that costly? I am using the PK of the table but only in descending order (DESC).