• jeff.mason (10/4/2010)


    This is just wrong. I know of no requirement like that. Partitioning has nothing to do with referential integrity and it shouldn't even enter into the discussion.

    I also understand that this is an old post but need to comment on the above now that I've seen it.

    I agree that you don't need to add the partitioning column to the PK (a unique index under the hood) or any other unique index [font="Arial Black"]BUT [/font] then you lose some of the advantages of having a partitioned table making it almost not worth while.

    Not adding the partitioning column to PK/Unique indexes means that the indexes will not be "aligned". That not only means that you can't use SWITCH to archive older data, it can also mean that the index isn't partitioned unless you partition it separately (non-aligned unless you add the partitioning column to it for unique indexes. If you don't, you still won't be able to use SWITCH in such a case). If the index isn't partitioned, then you don't enjoy the benefits of lighter index maintenance periods. Of course, if the clustered index isn't partitioned, neither is your table.

    SWITCH may not be important, though. You generally only need that if you want to very quickly SWITCH in millions of rows from a staging table to the main table or if you want to very quickly SWITCH out older data into a separate table and drop the table (takes milliseconds).

    So there is a requirement to add the partitioning column to PK/UNIQUE indexes but only if you want SWITCH to be available.

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