why query slow?

avatar image By hsncfr 1 asked Sep 11, 2014 at 06:43 AM
more ▼
(comments are locked)
avatar image Aaron Bertrand ♦ Sep 11, 2014 at 06:43 PM

Quick observation: you have to scan all 3 million rows of the clustered index because you don't have a narrower index on LG_001_07_STINVTOT to satisfy the correlated subquery. How about an index on (date,stockref,onhand,actsorder) WHERE invenno < 4, and changing SUM(onhand)-SUM(ACTSORDER) to SUM(onhand-ACTSORDER), and changing the WHERE IN to match the where clause of the filtered index?

10|10000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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:

x641
x455
x24
x24

asked: Sep 11, 2014 at 06:43 AM

Seen: 181 times

Last Updated: Sep 11, 2014 at 06:43 PM