troubleshooting Question


Avatar of n_srikanth4
n_srikanth4Flag for India asked on
Microsoft SQL Server 2005Microsoft SQL Server 2008SSISMicrosoft SQL Server
13 Comments1 Solution199 ViewsLast Modified:
Hi Experts,

  I have some performance issue with my T-SQL Query attached , here are the details below.

1. I am processing 1000 records in a batch first by insert in to temporary table and then eventually to the fact table.
2. Problem is with the query of the  temporary table.
3. When I check the execution plan , sort is taking longer time , is it because of the use of Group By and Order By statement in the select ? How to Optimize this ?
4. Any missing Indexes . Please advice ?

Please help me to optimize the performance of this query and also advice me on missing indexes.

Here are the indexes on the various tables used in the query (excluding the dimension tables) as the dimension tables are not large size, hence I have not listed the indexes of the dimension tables.


create clustered index idx1 on #FACT_Labor_Demand_Ideal ([calendar_day],[business_unit_id],[labor_workgroup_id],[labor_role_id],[time_quarter_hour_id],daypart_id,comparable_flag_id,day_comparable_flag_id,business_unit_status_id,[datasource_id],[labor_schedule_version_id] )


create clustered index idx1 on #FACT_Labor_Schedule_Version ([calendar_day],[business_unit_id],[labor_workgroup_id],[labor_role_id],[time_quarter_hour_id],daypart_id,labor_schedule_version_id,comparable_flag_id,business_unit_status_id,[datasource_id] )

Will appreciate your quick reply and your help and support in this regard.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros