Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

CXPACKET on Inserting Expand / Collapse
Author
Message
Posted Thursday, October 31, 2013 9:56 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 4:03 AM
Points: 903, Visits: 1,872
I came across a database today that was doing a lot of inserting onto a table. It was taking an exceptionally long time. On clearing the Wait Stats, the CXPACKET wait type kept coming to the top of the list. Generally CXPACKET is considered a secondary wait type, caused by some other issue. Im having trouble identifying what this main issue is though.

-The query is using a Parallel plan, utilizing most of the processors.
-The table being inserted into has no indexes of any type, I guess to speed up insert.
-Processor affinity is set to use 7 procs for processing & 1 for IO.

The job has complete, and I cant run it again so im a bit stuck with regard to reproducing and nailing down the cause of the issue, but any speculation would be much appreciated.
Post #1510291
Posted Thursday, October 31, 2013 11:24 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, December 16, 2013 12:24 PM
Points: 476, Visits: 1,376
I haven't comeacross CXPACKET waittype while inserting data.

Mostly sql server decides whether to execute the query on parallel threads or not, based on the estimate time the query completes i.e "cost threshold for parallelism". If sql server estimates that if the query takes more than 5 seconds then parallelism is kicked off, the session that is executing SQL will be executed on parallel threads if any of the threads yields or still executing and if other threads completed their tasks are waiting for completion of the thread that has yielded or still executing, then you will see CXPACKET waittype for threads that have completed its task and other waittype for the thread that is still executing.

Are you populating table through a query, if so please have fine tuned your query so that you don't run into issue, if you still run into issue you can suppress parallelism by calling maxdop query hint in your query and specificying value 1 so that your query runs only on one thread.



Post #1510354
Posted Thursday, October 31, 2013 11:25 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, December 16, 2013 12:24 PM
Points: 476, Visits: 1,376
murthykalyani (10/31/2013)


I haven't comeacross CXPACKET waittype while inserting data.

Mostly sql server decides whether to execute the query on parallel threads or not, based on the estimate time the query completes i.e "cost threshold for parallelism". If sql server estimates that if the query takes more than 5 seconds then parallelism is kicked off, the session that is executing SQL will be executed on parallel threads if any of the threads yields or still executing and if other threads completed their tasks are waiting for completion of the thread that has yielded or still executing, then you will see CXPACKET waittype for threads that have completed its task and other waittype for the thread that is still executing.

Are you populating table through a query, if so please have fine tuned your query so that you don't run into issue, if you still run into issue you can suppress parallelism by calling maxdop query hint in your query and specificying value 1 so that your query runs only on one thread.



Post #1510355
Posted Friday, November 1, 2013 2:27 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 5:01 AM
Points: 2,840, Visits: 3,968
winston Smith (10/31/2013)
I came across a database today that was doing a lot of inserting onto a table. It was taking an exceptionally long time.
How much data you are dealing with here ? is it periodic task or one time execution ?


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1510530
Posted Friday, November 1, 2013 3:17 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 4:03 AM
Points: 903, Visits: 1,872
Hey Guys.

I was viewing the information incorrectly and so phrased the problem incorrectly.
The waits were not due to the insert, but the select statement that was being used as the source for the insert, which makes things a lot clearer.

As inserts cant be parallel, the parallel plans were coming from the select statement used as the source for the insert.
Next step is to have a look at that statement and identify areas where it can be improved by rewriting, indexing etc.

Apols for any time wasted due to my incorrect posing of the question.
Post #1510535
Posted Friday, November 1, 2013 4:01 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 5:01 AM
Points: 2,840, Visits: 3,968
you havent answered my question ? as it might help us to frame resolution for ur issue.

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1510541
Posted Friday, November 1, 2013 8:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, June 2, 2014 2:54 PM
Points: 5, Visits: 50
If this is an OLAP environment CXPACKET is a good thing, and you would want it to be > 10%. If this is an OLTP environment CXPACKET > 5% would indicate a problem.

Google "SQL Server 2005 Waits and Queues".
Post #1510597
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse