CXPACKET on Inserting

  • 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.

  • 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.

  • 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.

  • 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;-)

  • 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.

  • 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;-)

  • 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".

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply