Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
cosy
Starting Member
22 Posts |
Posted - 2009-01-29 : 18:35:01
|
HI All, This query take 10 min and lock up few users and everyone is going to non responding so please some one advice or anything wrong in this view?-------------------------------------------------------------SELECTim.part_no,pa.moms_no,im.sku_no,im.description,pa.category,im.category as itemgroup,pa.brand_studio,pa.status,pa.classification_no,pa.genre,im.entered_date,pa.rights_acq_date,pa.cat_first_rel as release_date,isnull(pp.price_a,0) as 'Whsale',isnull(pa.RRP,0)as 'Retail',isnull(RetailSales.sales,0) as 'TotalSalesRetail',isnull(WholesaleSales.sales,0) as 'TotalSalesWholesale',isnull(TotSales.sales,0) as 'TotalSales',case when qoh1.instock is null then 0 else qoh1.instock end QtyOnHand,case when qoh1.instock is null then (0 - isnull(qa1.avail,0)) else (qoh1.instock - isnull(qa1.avail,0)) end QtyAvail,case when pur1.orders is null then 0 else pur1.orders end purtotalFROMinv_master imLeft Joinpa_inv_attributes paonim.part_no = pa.part_noleft join part_price as pponim.part_no = pp.part_noleft join(select ol.part_no,sum(shipped - cr_shipped) as salesfrom ord_list ol, orders od,pa_inv_attributes pawhere ol.part_no = pa.part_no and pa.category = 'D' and od.date_shipped > (getdate()-365) and od.order_no = ol.order_no and od.ext = ol.order_ext and ol.location like 'A%' and od.user_code = 'RETAIL' group by ol.part_no) RetailSaleson im.part_no = RetailSales.part_noleft join(select ol.part_no,sum(shipped - cr_shipped) as salesfrom ord_list ol, orders od, pa_inv_attributes pawhere ol.part_no = pa.part_no and pa.category = 'D' and od.date_shipped > (getdate()-365) and od.order_no = ol.order_no and od.ext = ol.order_ext and ol.location like 'A%' and od.user_code <> 'RETAIL' group by ol.part_no) WholesaleSaleson im.part_no = WholesaleSales.part_noleft join(select ol.part_no,sum(shipped - cr_shipped) as salesfrom ord_list ol, orders od,pa_inv_attributes pawhere ol.part_no = pa.part_no and pa.category = 'D' and od.date_shipped > (getdate()-365) and od.order_no = ol.order_no and od.ext = ol.order_ext and ol.location like 'A%'group by ol.part_no) TotSaleson im.part_no = TotSales.part_noleft join(select lbs.part_no,sum(lbs.qty) as instockfrom lot_bin_stock lbs, tdc_bin_master tbmwhere lbs.bin_no = tbm.bin_no and lbs.location = tbm.locationand tbm.location not in ('ADA', 'MSR', 'SSR', 'MDA', 'SDA', 'AFL')andusage_type_code not in ('quarantine', 'prodin', 'stlbin')group by lbs.part_no) qoh1on im.part_no = qoh1.part_no and im.void = 'N'left join(select invs.part_no,sum(invs.commit_ed) as availfrom inv_sales invsgroup by invs.part_no) qa1on im.part_no = qa1.part_no and im.void = 'N'left join(select pl.part_no,sum(qty_ordered - qty_received) as ordersfrom pur_list plwhere pl.status = 'o' or pl.status = 'q'group by pl.part_no) pur1on im.part_no = pur1.part_no and im.void = 'N'where pa.category = 'D'and pa.status <> 'DIS'and im.void = 'N' |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-29 : 18:40:24
|
Check Execution plan and indexes on joined column and Where clause and Aggregates. How many rows is this query fetching? |
|
|
cosy
Starting Member
22 Posts |
Posted - 2009-01-29 : 22:05:46
|
HI, I'm not sure about "Check Execution plan and indexes on joined column and Where clause and Aggregates." how do i check?This returned 2636rows |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-30 : 09:28:50
|
quote: Originally posted by cosy HI, I'm not sure about "Check Execution plan and indexes on joined column and Where clause and Aggregates." how do i check?This returned 2636rows
Press Actual Execution plan tab Query Analyzer and post snapshots of it over here so we can analyze. |
|
|
|
|
|
|
|