SQL Server-Table having 40 Billion Records

  • Hi, I have one table in SQL server. Table is partitioned in 14 segment and in its latest partition (14th) records are around 40 Billion. I need to fetch the records from that 14th partition, but SQL is talking aorund 1 hour to execute. is there any suggestion on how can I improve my SQL performance ?

    SQL which I am using

    SELECT column1,column2 FROM

    tablename

    WHERE $PARTITION.Partition_Function (column_name) = 14

  • Are you executing that directly in SSMS?

    It's 40 billion (you sure it's not million?) rows, did you expect it to go fast?

    If it's in SSMS, return data as text instead of grid, it goes faster.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Hi Koren,

    Yes its 401415793 number of rows in that partition. As we are in TELECOM domain that table contain usage records for all subscribers.

    I am using SQL Server Managment studio.

  • 401,415,793 is about 400 million. It's not even close to 40 billion.

    Anyway, why would you want to select that amount of rows in SSMS?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Have you got a covering index for this query ? Is this index also partitionned ?

    However, it's a lot of data, it will take some time.

    Jonathan Bernardez Bernardez
    ___________________________________________________________
    DBD. MCSA SQL Server 2012

  • oops 🙂

    any ways is there any fastest way to retirval the data from this table.

    If I am fetching data for previous day then query is talking around 30 min.

  • Yes, that column is also indexed.

  • pawan.khandelwal (10/18/2013)


    Yes, that column is also indexed.

    Are column1 and column2 of your select clause included in the index ? If not, this is not a covering index.

    Hope it helps.

    Jonathan Bernardez Bernardez
    ___________________________________________________________
    DBD. MCSA SQL Server 2012

  • ok..can you just give me rough estimate how much time SQL to take to fetch 20 million records

  • pawan.khandelwal (10/18/2013)


    ok..can you just give me rough estimate how much time SQL to take to fetch 20 million records

    How can someone give an estimate on this?

    It depends on too many factors: network, I/O, server hardware, fragmentation, indexing, row size, ...

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • pawan.khandelwal (10/18/2013)


    ok..can you just give me rough estimate how much time SQL to take to fetch 20 million records

    What is it that you're doing with those "records"? If you're trying to display them to the screen, I have to as "WHY"? It's certainly not like someone can read them all.

    Like I said, what is it that you're actually trying to do with the "records"?

    --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)
    Intro to Tally Tables and Functions

  • Why are you retrieving hundreds of millions of rows? What are you going to do with them?

    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
  • Just a wild guess but...

    If are you returning 1k bytes per row for 40G rows...

    it can be a network bottleneck check how much time your bandwidth needs to handle that chunk of data.

Viewing 13 posts - 1 through 12 (of 12 total)

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