Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Huge transaction logs and row count discrepancy

Author  Topic 

lebedev
Posting Yak Master

126 Posts

Posted - 2009-09-15 : 14:59:25
I have noticed that one of our SQL Server 2005 databases is extremely slow. I noticed that the LDF file is 25GB in size. I realized that the database did not have a maintenance plan set up, which is the root of the problem.

My question is about the strange behavior that I observed while the database was in that state. When I right-click and view properties of one of the tables I see that the row count is over 4B, however when I run count(*) query it returns 13K. Why such a discrepancy?

Thanks,

Alec

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-15 : 18:41:29
Was this database upgraded from SQL Server 2000? If so, then you need to run DBCC UPDATEUSAGE to fix the inaccuracies in sysindexes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

lebedev
Posting Yak Master

126 Posts

Posted - 2009-09-16 : 12:28:44
No, this was a fresh SQL Server 2005 SP1 installation.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-16 : 13:14:55
Try running DBCC UPDATEUSAGE anyway as I've read that even in 2005 (not upgraded from 2000) it can be inaccurate. This was common in versions 2000 or lower but shouldn't happen anymore in 2005.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

lebedev
Posting Yak Master

126 Posts

Posted - 2009-09-16 : 13:47:23
I tried the following to no vail:
dbcc UPDATEUSAGE(mydb)
dbcc UPDATEUSAGE(mydb, "dbo.mytable")
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-16 : 15:22:41
I don't have an answer, but perhaps you've encountered a bug. What does SELECT @@VERSION show?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

lebedev
Posting Yak Master

126 Posts

Posted - 2009-09-17 : 15:42:57
FYI, the number of rows displayed in the table properties is 4294982522.

The output of "select @@version" is:
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) Nov 24 2008 13:01:59 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-17 : 17:56:42
I'm out of ideas. Perhaps open a case with MS if this discrepancy bugs you.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -