Table Row Count

  • Hi Experts,

    We have a very Large table which hold almost 185GB of data.

    When ran the Count it was giving 159709 records but when ran sys.dm_db_index_physical_stats it gave 23346074 records for LOB data alone and IN_ROW_DATA (Clustered Index) it was giving the same record. I am trying to figure out the per row size ,do i need to consider the LOB record number while calculating the per row size

    We are planning to delete data till Dec-17 from this table and the data comes around 130GB .

  • VastSQL - Sunday, April 8, 2018 4:53 AM

    Hi Experts,

    We have a very Large table which hold almost 185GB of data.

    When ran the Count it was giving 159709 records but when ran sys.dm_db_index_physical_stats it gave 23346074 records for LOB data alone and IN_ROW_DATA (Clustered Index) it was giving the same record. I am trying to figure out the per row size ,do i need to consider the LOB record number while calculating the per row size

    We are planning to delete data till Dec-17 from this table and the data comes around 130GB .

    Please post the CREATE TABLE statement for the table in question so the we can help you better.

    Also, doing DELETEs on this table would probably NOT be the way to go but we need that CREATE TABLE statement to help you figure out what the best way to do it is.  It would also be useful if you posted the output from sys.dm_db_index_physical_stats for this table.  Don't use the 'LIMITED' option here... it won't give us the information we need to help.

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

  • Jeff Moden - Sunday, April 8, 2018 8:33 AM

    VastSQL - Sunday, April 8, 2018 4:53 AM

    Hi Experts,

    We have a very Large table which hold almost 185GB of data.

    When ran the Count it was giving 159709 records but when ran sys.dm_db_index_physical_stats it gave 23346074 records for LOB data alone and IN_ROW_DATA (Clustered Index) it was giving the same record. I am trying to figure out the per row size ,do i need to consider the LOB record number while calculating the per row size

    We are planning to delete data till Dec-17 from this table and the data comes around 130GB .

    Please post the CREATE TABLE statement for the table in question so the we can help you better.

    Also, doing DELETEs on this table would probably NOT be the way to go but we need that CREATE TABLE statement to help you figure out what the best way to do it is.  It would also be useful if you posted the output from sys.dm_db_index_physical_stats for this table.  Don't use the 'LIMITED' option here... it won't give us the information we need to help.

    Thanks Jeff.

    CREATE TABLE [dbo].[PLM](
        [ID] [int] IDENTITY(1,1) NOT NULL,
        [FileName] [varchar](100) NULL,
        [Message] [nvarchar](max) NULL,
        [Type] [varchar](50) NULL,
        [ToProcess] [int] NULL,
        [CreateDate] [datetime] NULL,
    CONSTRAINT [PK_PLM] PRIMARY KEY CLUSTERED
    (
        [ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    GO

    database_idobject_idindex_idpartition_numberindex_type_descalloc_unit_type_descindex_depthindex_levelavg_fragmentation_in_percentfragment_countavg_fragment_size_in_pagespage_countavg_page_space_used_in_percentrecord_countghost_record_countversion_ghost_record_countmin_record_size_in_bytesmax_record_size_in_bytesavg_record_size_in_bytesforwarded_record_countcompressed_page_count
    699410258211CLUSTERED INDEXIN_ROW_DATA302.7472532497.309237182097.394271597200043719387.85NULL0
    699410258211CLUSTERED INDEXIN_ROW_DATA31061648.69451182000111111NULL0
    699410258211CLUSTERED INDEXIN_ROW_DATA3201110.938967600111111NULL0
    699410258211CLUSTERED INDEXLOB_DATA100NULLNULL2334607498.951923402993001680547989.682NULLNULL
    699410258261NONCLUSTERED INDEXIN_ROW_DATA204.2402831420.2142928397.5974915972220121212NULL0
    699410258261NONCLUSTERED INDEXIN_ROW_DATA21011169.9036328300181818NULL0

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

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