Candidate for partitioned table?

  • patreddy

    SSC Enthusiast

    Points: 176

    I have a table that contains about 8 billion rows.  The table has a FK in it called fk_client.  The data is split, fairly evenly, among 14 distinct client keys.  So...about 500k records per client.  ANY and EVERY time we query this table we do so for a particular fk_client.  Would it make sense to partition this table by fk_client so each file contains a subset of data by client?  Wouldn't querying the table be more efficient if Sql could look to a single partition (or file in the partition) for data related to a client?

    Thank you.

  • Sue_H

    SSC Guru

    Points: 90165

    patreddy - Tuesday, February 27, 2018 1:08 PM

    I have a table that contains about 8 billion rows.  The table has a FK in it called fk_client.  The data is split, fairly evenly, among 14 distinct client keys.  So...about 500k records per client.  ANY and EVERY time we query this table we do so for a particular fk_client.  Would it make sense to partition this table by fk_client so each file contains a subset of data by client?  Wouldn't querying the table be more efficient if Sql could look to a single partition (or file in the partition) for data related to a client?

    Thank you.

    It might benefit from partition elimination but it depends on the queries. You'd want to test to see. Reading the following can also help when testing:
    Why Doesn’t Partition Elimination Work?

    Sue

  • Jeff Moden

    SSC Guru

    Points: 994542

    patreddy - Tuesday, February 27, 2018 1:08 PM

    I have a table that contains about 8 billion rows.  The table has a FK in it called fk_client.  The data is split, fairly evenly, among 14 distinct client keys.  So...about 500k records per client.  ANY and EVERY time we query this table we do so for a particular fk_client.  Would it make sense to partition this table by fk_client so each file contains a subset of data by client?  Wouldn't querying the table be more efficient if Sql could look to a single partition (or file in the partition) for data related to a client?

    Thank you.

    I've found that partitioning doesn't do much in the area of performance except to usually make it slower even if your code is written well enough to take advantage of so called partition elimination.  A monolithic table with the correct indexes and the correct code playing against it will usually beat the identical index/code combination on a partitioned table.  I say "usually" a bit tongue in cheek because I've not yet seen a partitioned table beat a monolithic table for performance.

    My disclaimer there is that I have seen some people claim that partitioning helped performance but, for those I'm aware of, it was the indexing they had to do to partition the tables that really made the difference.  Doing similar indexing on their old monolithic table was still faster.  Fixing  bad code is even better. 

    Partitioning <> Performance.  What partitioning is really good for is index maintenance, backups, and the ability to do "Piece Meal" restores if the need should ever arise.

    --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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

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

Viewing 3 posts - 1 through 3 (of 3 total)

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