Row Count of each table

  • Hi,

    I have few queries.

    1. Is there any way to get the Table Row Count if we are not maintaining the count.

    2. This is for Update statistics

    a. Should we run update statistics in our database for all the tables? The database is highly transactional.

    b. How should i calculate the sample size that will suite for all the tables.

    There are some tables which gets reindex, this we will ignore. We have a job, which reorganise some tables. Now the decision need to be taken what table should we update statistics to:

    1. The table which has been reorganised

    Or. 2. Table which has its statistics outdated.

    Thanks,

    H

  • For the row counts, you can use the following:

    SELECT OBJECT_NAME( object_id) AS TableName,

    SUM( row_count) AS Row_Count

    FROM sys.dm_db_partition_stats

    WHERE index_id IN(1,0)

    GROUP BY object_id

    For statistics and index maintenance, you could review what it's used in the scripts from https://ola.hallengren.com/ and use them yourself or create your own.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thank you Luis for the quick reply.

    The query does give me a count, but i wanted historical growth. Like, we can get for the database growth from the backupset.

    Its not a problem to get Ola Hallengren scripts. I have downloaded them.

    The problem is the decision for the sample size and for which table to take into consideration.

    How do we calculate the sample or percentage size.

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

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