|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Saturday, May 04, 2013 11:13 AM
Points: 9,855,
Visits: 9,374
|
|
Jeff Moden (8/10/2008)
rbarryyoung (8/10/2008) Gimme time to eat lunch, Jeff! :P :)Heh... hey! I need to know... does brother Darth have to take off the Chevy look-alike to eat?
Straws. And shakes. Lots of shakes. Milk shakes, oatmeal shakes, yam shakes, broccoli shakes, steak shakes, spinach shakes, etc.
-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung Proactive Performance Solutions, Inc. "Performance is our middle name."
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: 2 days ago @ 11:21 AM
Points: 4,317,
Visits: 9,216
|
|
Jeff Moden (8/10/2008) Again, I ask... do you have to update usage for the rowcounts to be accurate?
Well, according to BOL - no, you don't have to update usage.
Reports and corrects pages and row count inaccuracies in the catalog views. These inaccuracies may cause incorrect space usage reports returned by the sp_spaceused system stored procedure. In SQL Server 2005 and later, these values are always maintained correctly. Databases upgraded from SQL Server 2000 may contain invalid counts. We recommend running DBCC UPDATEUSAGE after upgrading to correct any invalid counts.
But, as we all know - BOL is not always correct. There are situations where you will need to update usage, but I am not sure what those are. We just went through a large purge operation and these numbers were updated accurately.
Jeffrey Williams Problems are opportunites brilliantly disguised as insurmountable obstacles.
How to post questions to get better answers faster Managing Transaction Logs
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, February 22, 2013 9:04 AM
Points: 241,
Visits: 928
|
|
Since I went ahead and made the query which actually does provide the table and associated rowsize without cursors thought I would post it. (though I am sure Barry's does a LOT more ).
SELECT so.name 'Table', si.rows 'Rows' FROM (SELECT Name FROM sysobjects WHERE type='U') so JOIN (SELECT rows,id,indid FROM sysindexes) si ON si.id = OBJECT_ID(so.name) AND si.indid < 2
Toni
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 8:21 PM
Points: 32,893,
Visits: 26,765
|
|
So... hedging a bet against BOL and changing the code to something a bit more conventional, we end up with this...
DBCC UPDATEUSAGE (0) SELECT so.Name AS TableName, si.Rows AS [Rows] FROM sys.SysObjects so INNER JOIN sys.SysIndexes si ON si.ID = so.ID WHERE si.IndID < 2 AND so.XType = 'U' AND OBJECTPROPERTY(so.ID,'IsMSShipped') = 0
--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."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 8:21 PM
Points: 32,893,
Visits: 26,765
|
|
... and, with SQL Server 2000, we end up with this...
DBCC UPDATEUSAGE (0) SELECT so.Name AS TableName, si.Rows AS [Rows] FROM dbo.SysObjects so INNER JOIN dbo.SysIndexes si ON si.ID = so.ID WHERE si.IndID < 2 AND so.XType = 'U' AND OBJECTPROPERTY(so.ID,'IsMSShipped') = 0 Yeah... I know... if I didn't use the two part naming convention, they'd both work and they'd both be identical. Actually, the code above will work in both environments... I just have an affinity for the two part naming convention for a lot of reasons. :P
--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."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Saturday, May 04, 2013 11:13 AM
Points: 9,855,
Visits: 9,374
|
|
Jeffrey Williams (8/10/2008)
Well, according to BOL - no, you don't have to update usage.
Hmm, yeah I see where it says that Jeff. I may be wrong here, when I wrote my view (about 2-3 years ago) I was still working on both 2000 & 2005 most days and I remember having accuracy problems that ultimately caused my to add DBCC UpdateUsage periodically. But it may have been only happening on SQL 2000.
-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung Proactive Performance Solutions, Inc. "Performance is our middle name."
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: 2 days ago @ 11:21 AM
Points: 4,317,
Visits: 9,216
|
|
rbarryyoung (8/10/2008)
Hmm, yeah I see where it says that Jeff. I may be wrong here, when I wrote my view (about 2-3 years ago) I was still working on both 2000 & 2005 most days and I remember having accuracy problems that ultimately caused my to add DBCC UpdateUsage periodically. But it may have been only happening on SQL 2000.
Either way, it doesn't hurt to update usage as long as you have the time. The important thing about any of these techniques (yours, mine and Jeff's) are that they are not cursor based and return the desired results.
Jeffrey Williams Problems are opportunites brilliantly disguised as insurmountable obstacles.
How to post questions to get better answers faster Managing Transaction Logs
|
|
|
|