Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 TSQL Optimization
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 10/07/2012 :  10:47:41  Show Profile  Reply with Quote

My query is running very slow.

Sale table have 6 million records
data item table have 1 million record
assignment chage table have 85000 record

query returning 81056 rows and taking around 5 second

case when Absolute_Value is null
(SUM(VOLUME) OVER(PARTITION BY t3.start_date_id,t3.end_date_id,T3.Source_business_Id,T3.Destination_business_id,T3.Product_id)) * (Percentage_Value)/100
else Absolute_Value end
FROM sales_order (nolock) T0
INNER hash JOIN data_item t1 ON and t1.Class=46
INNER JOIN rules_Assginment_Change T3 ON t3.data_set_id=21 and T3.Source_Business_Id=T0.source_id AND T3.Destination_Business_id=T0.destination_id AND T3.Product_id=T0.product_id
and t3.start_date_id=t1.start_date_id and t3.end_date_id=t1.end_date_id
where T0.data_selection=1
and exists(
SELECT * from data_set_item_mapping T2
where T0.data_item_id=t2.org_data_item_id AND T0.Version_id=T2.Org_Version_id
and T2.class_id=t1.Class and T2.data_set_id=21

Please suggest what things need to do to improve the query performance.

Flowing Fount of Yak Knowledge

United Kingdom
2179 Posts

Posted - 10/07/2012 :  13:35:41  Show Profile  Visit jackv's Homepage  Reply with Quote
Could you also post - the Execution Plan

Jack Vamvas
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/07/2012 :  14:01:20  Show Profile  Reply with Quote
did you check the execution plan? what does it suggest?

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000