locked
Partition switching taking lots of time RRS feed

  • Question

  • I have a partitioned table. All the partitions of this table are mapped to a single filegroup.

    When I am trying to switch partition, it is taking lots of time more than 5 mins for a single partition.

    I can see that there is a file in the filegroup and its size is very high that is 234GB.

    Can partition switching take more time due to file size?

    or is there any other issue?

    I need help in finding out what is the problem.

    Thanks,

    • Changed type Olaf HelperMVP Wednesday, April 2, 2014 12:23 PM More a question rather then a discussion
    Wednesday, April 2, 2014 9:44 AM

Answers

  • So you are running ALTER TABLE SWITCH? Check for blocking. The operation requires an Sch-M lock which means that it is blocked any query that is running, including queries using NOLOCK.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Proposed as answer by Olaf HelperMVP Thursday, April 3, 2014 6:39 AM
    • Marked as answer by Sofiya Li Wednesday, April 9, 2014 2:17 AM
    Wednesday, April 2, 2014 10:36 AM
  • Can partition switching take more time due to file size?

    No, SWITCH is a meta-data only operation.  The likely cause is the blocking Erland mentioned.  However, SPLIT/MERGE may require data movement depending on the boundaries created/removed.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    • Proposed as answer by Olaf HelperMVP Thursday, April 3, 2014 6:39 AM
    • Marked as answer by Sofiya Li Wednesday, April 9, 2014 2:17 AM
    Wednesday, April 2, 2014 12:19 PM

All replies

  • So you are running ALTER TABLE SWITCH? Check for blocking. The operation requires an Sch-M lock which means that it is blocked any query that is running, including queries using NOLOCK.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Proposed as answer by Olaf HelperMVP Thursday, April 3, 2014 6:39 AM
    • Marked as answer by Sofiya Li Wednesday, April 9, 2014 2:17 AM
    Wednesday, April 2, 2014 10:36 AM
  • Can partition switching take more time due to file size?

    No, SWITCH is a meta-data only operation.  The likely cause is the blocking Erland mentioned.  However, SPLIT/MERGE may require data movement depending on the boundaries created/removed.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    • Proposed as answer by Olaf HelperMVP Thursday, April 3, 2014 6:39 AM
    • Marked as answer by Sofiya Li Wednesday, April 9, 2014 2:17 AM
    Wednesday, April 2, 2014 12:19 PM