I've inherited a server/application. This query seems to be my biggest problem child.

The is the link to the Paste A Plan site https://www.brentozar.com/pastetheplan/?id=HJklGsOR- .

avatar image By Steve Malcolm 1 asked Nov 02 at 02:07 PM
more ▼
(comments are locked)
10|10000 characters needed characters left

1 answer: sort voted first

Steve,

While the Paste the Plan is a great way to make a plan available for everyone to see, it is not the same as getting an Actual Plan with Plan Explorer and uploading it to this site.

Your biggest cost is obviously the SORT, does the data need to be sorted by SQL Server? Or could the application perform the sort?

I would also investigate the Key Lookup on the OrdMain table. Initially, it does an index seek on the OrderNumber index but then it must use the PK to return the BillingDate, HSTTaxAmount, and TotalOrder columns data. I would consider adding the three columns to the OrderNumber index as INCLUDE columns.

avatar image By SDyckes2 81 answered Nov 02 at 02:30 PM
more ▼
(comments are locked)
10|10000 characters needed characters left
Your answer
toggle preview:

Up to 50 attachments (including images) can be used with a maximum of 209.7 MB each and 209.7 MB total.

Follow this question

Topics:

x117
x8
x1

asked: Nov 02 at 02:07 PM

Seen: 6 times

Last Updated: Nov 02 at 02:30 PM