all groups > sql server (alternate) > june 2007 >
You're in the

sql server (alternate)

group:

Mismatch between Count(*) and Properties -> Rows


Mismatch between Count(*) and Properties -> Rows teddysnips NO[at]SPAM hotmail.com
6/29/2007 7:28:03 AM
sql server (alternate): I have a client who has reported a discrepancy in their database. In
their test database a certain report returns 5,333 rows, but in the
production database it returns 5, 332 rows.

I'll get to the bottom of it in due course, but I came across an
oddity. I wanted to know how many rows there were in a particular
[quoted text, click to view]

SELECT COUNT(*) AS NumRows FROM Answer

It returned 1,919,456. However, if I click on the Answer table in
Enterprise Manager and select Properties it tells me that there are
1,919,421 rows. I've tried doing a refresh but it didn't work.

The thing is that the database is pretty static - in fact there's been
no activity (apart from me examining it) for a couple of days.

Thoughts?

Edward
Re: Mismatch between Count(*) and Properties -> Rows Roy Harvey
6/29/2007 2:42:35 PM
[quoted text, click to view]

Those statistics are not always accurate. To fix them run

DBCC UPDATEUSAGE(0) WITH COUNT_ROWS

Roy Harvey
Re: Mismatch between Count(*) and Properties -> Rows Ed Murphy
6/29/2007 6:53:15 PM
[quoted text, click to view]

Is it COUNT(*) or EM - Properties that is sometimes inaccurate? Under
Re: Mismatch between Count(*) and Properties -> Rows Roy Harvey
6/29/2007 10:10:31 PM
On Fri, 29 Jun 2007 18:53:15 -0700, Ed Murphy <emurphy42@socal.rr.com>
[quoted text, click to view]

Enterprise Manager. EM gets the count from index information
maintained by the system. The overhead of keeping the numbers
absolutely accurate at all times would be prohibitive, so the row
count gets out of sync with reality at times. The same goes for space
allocation, which UPDATEUSAGE also fixes.

SELECT COUNT(*) will always be correct.

Roy Harvey
AddThis Social Bookmark Button