Table Partitioning

  • We have a table with almost 2 billion rows and we have partitioned this table based on date. The size of the table including indexes is 1.6 TB( 600 data + 1TB index). We have 14 indexes on this table. Recently a developer tried to query this table and got timed out issue because he was using the fields not in indexes. He was trying to pull last 3 months data.

    My question over here is how to maintain these indexes on this partitioned table? Is it good to seperate the old partitions(switch) into archive tables and add new partitions ? What's the best way to maintain this table?

  • The entire point of partitioning is ease of archiving and easier maintenance. It's not a performance tuning technique.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Gila.

    We are not archiving this table. Just adding rows to it which is causing more issues. As the table is growing bigger and bigger. So as said in my previous comment just switch the old partitions into individual archive tables.

  • Or switch them into a partioned archive table and maybe merge the partitions.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You have mentioned 1.6TB(600 date + 1Tb Index).

    What does this mean by 1Tb of Index.

    Please make me clear....

  • It's size of indexes 1 TB

  • Yes I understood that your Index size is 1Tb.But as per your question you have 14 indexes(if i am not wrong you must have 13 non clustered index and one clustered index). But one index is used on a column .Then how a data size is isolated from index size ?

    How Index size increases ?

    Give me a brief detail on it

  • Skpani (7/27/2013)


    Yes I understood that your Index size is 1Tb.But as per your question you have 14 indexes(if i am not wrong you must have 13 non clustered index and one clustered index). But one index is used on a column .Then how a data size is isolated from index size ?

    How Index size increases ?

    Give me a brief detail on it

    I'm sure that Gail will be able to explain in much more detail but, from a 60,000 foot view, Indexes are stored in a manner similar to tables. In fact, the Clustered Index IS the table (the leaf level of the clustered index is the actual data in the table). Non clustered indexes have a B-Tree and a leaf level. Storage of this index information is tracked separately by SQL Server and you can get a lot of the information about how much space an index uses from various system tables and data management views. If you want some grand detail, look at and analyze the code for the system stored procedure called sp_SpaceUsed.

    The indexes for a table can also be partitioned just like table data.

    As Gail said, the goal of partitioning usually isn't for any type of performance gain all though a performance gain can occasionally be realized (usually on bad code that does a table scan without the partitioning). The purpose of proper partitioning is to make index an other types of maintenance easier and certain types of backups take less space (especially on tape) and MUCH less time. With some real forethought, they can allow for "Piece-Meal" restores to allow the critical parts of a system to be restored much more quickly in the case of a total system failure or a database corruption failure.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • GilaMonster..please make me clear with details..

  • skpani (7/27/2013)


    GilaMonster..please make me clear with details..

    My recommendation would be to look up "Clustered Indexes" and "Non Clustered Indexes" in Books Online so that you'll at least be familiar with the terms before asking for such help. Just in case you don't know, "Books Online" is the "help" system that comes with SQL Server. In SSMS, press the {f1} key to get there.

    Also, did you do as I recommended and look at the code for sp_SpaceUsed?

    If you really want to learn something, you have to put your shoulder into it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 10 posts - 1 through 9 (of 9 total)

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