count(*) sysindexes.rows

  • Could someone please explain why my count(*) does not match sysindexes.rows?

    select rows, rowcnt

    from sysindexes 

    where id = 100195407

    rows        rowcnt              

    ----------- --------------------

    365         365

    select count(*), object_id(N'[dbo].[censusdataundergradexp]')

    from dbo.censusdataundergradexp

                          

    ----------- -----------

    366         100195407

    Thanks in advance.

  • Because sysindexes.rows,rowcnt  does not contain real-time data.

    I presume it is updated with the statistics.

  • Thanks Jo.

    I'll stick with select count(*) when I need to know the real time row count.

    I tried "UPDATE STATISTICS censusdatageneric with FULLSCAN" and I tried simply updating one of the rows in the table, but sysindexes.rows wouldn't budge from its old count (which is several days old).  We have "auto update statistics" turned on for the database.

  • try:

    DBCC UPDATEUSAGE(0)

    it will put them in synch

    Cheers,

     


    * Noel

  • Thanks Noel.

     

    This worked just great:

    DBCC UPDATEUSAGE(0) WITH COUNT_ROWS

Viewing 5 posts - 1 through 4 (of 4 total)

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