|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 11:03 AM
Points: 12,
Visits: 347
|
|
Comments posted to this topic are about the item Using T-SQL to Verify Tables Row Counts in Transactional Replication
Hi Experts!
I would like to thank you for your comments surrounding this topic. Of course there are many ways to achieve the rowcount verification and I totally agree with your methods described below. My script was originally written for purpose of documenting our current transactional replication setup. It later evolved into rowcount verification. So I thought since I've read many of your articles and made use many of your scripts, I here contribute my tiny part back to the community. Again I appreciate for your comments. It's just few hours since my article got posted, I've learnt a great deal from your idea and comments...
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 6:45 AM
Points: 9,
Visits: 91
|
|
While this works it is on the basis that the row count at the subscriber is supposed to be the same as the publisher. I have seen many cases where vertical and horizontal filtering is used on publications and the table at the subscriber is therefore significantly different from the publisher both in columns and in row count.
Have you looked at tracer tokens. These are simple to use and give very quick indication of any latency which can be investigated further and with the use of the underlying stored procedures very easy to set up to generate email alerts. There is also the dmv sys.dm_os_performance_counters which can be used to monitor latency and throughput.
These two features available within SQL Server are in fact simpler to use than your TSQL script and less of an overhead for very busy replication systems.
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Wednesday, October 03, 2012 6:35 AM
Points: 97,
Visits: 501
|
|
I have put something similar in place a couple of years ago.. I do a simple count on Publisher tables, and a count at the destination, then query to find differences (plus some extended formulas for certain tables), this is then emailed to the team responsible for the clone database (reporting) as attached.
This is all done as sequence of tasks within the replication jobs...
Oraculum
|
|
|
|
|
SSCertifiable
       
Group: Moderators
Last Login: Thursday, May 09, 2013 12:38 PM
Points: 6,462,
Visits: 1,384
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Sunday, February 03, 2013 8:52 PM
Points: 11,
Visits: 45
|
|
My thoughts exactly... Uh...Why don't you use the article and publication validation that ships with the product and has been there for multiple versions?
sp_article_validation allows you to do both a rowcount and a rowcount+checksum sp_publication_validation just runs sp_article_validation for all articles in the publication
Both account for filtering. The reason that they both have a checksum option is because it is possible for the row counts to be the same, but the data is still out of synch.
If you are running replication on SQL Server 2005 and higher, tracer tokens tell you precisely what you throughput is. How fast a single article is sending data is completely irrelevant, because the replication engine doesn't transmit on an article by article basis. It transmits in batches for the entire publication. So, the throughput of one article is affected by every other article in the publication. As long as you are posting tracer tokens are regular intervals, then when things fall behind, you can use the tracer tokens to tell that your subscriber is caught up to the publisher as of an exact time of the day.
Additionally, the replication monitor will show you how many rows are still pending at any given time for each publication. It will also use the most recent throughput numbers (either from a tracer token or a batch that was just replicated) to compute "how long until I catch up".
There is a special set of validation procedures for merge replication, but tracer tokens are only valid for transactional replication.
While it's a nice academic exercise, I wouldn't use anything except the built in validation procedures + tracer tokens.
Michael Hotek President - Champion Valley Software, Inc. http://www.ChampionValleySoftware.com
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, August 05, 2010 9:54 AM
Points: 1,
Visits: 1
|
|
| What if sysindexes table does not have the most up to date counts? I have trouble with getting the accurate table row counts on sysindexes table. Would your script work on such cases? There are no built in tools in SQL 2000 I believe to check the accuracy of replication.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 11:03 AM
Points: 12,
Visits: 347
|
|
Hi tina.t.kurtluyan
Counting rows in sysindexes is much faster than counting rows in the actual table. However, because sysindexes is lazily updated, the rowcount may not be accurate. If that's the case, you may need to use a full COUNT(*).
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 11:03 AM
Points: 12,
Visits: 347
|
|
Hi bill.galashan
you're abso correct. My script only works when all data from table is relicated. If data fiterring is used, it of course will cause diff in rowcounts between pub and sub. I forgot to mention it in the article. Thanks.
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 7:19 AM
Points: 18,733,
Visits: 12,331
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 11:03 AM
Points: 12,
Visits: 347
|
|
Good point, Jason. Thanks!
Instead of using dbo.sysindexes, sys.partitions can be used to obtain the rowcount
SELECT ( SCHEMA_NAME(o.schema_id) + '.' + OBJECT_NAME(o.object_id) ) AS TblName, p.rows AS RowCnt FROM sys.partitions AS p INNER JOIN sys.objects AS o ON p.object_id = o.object_id WHERE o.type_desc = 'USER_TABLE' AND p.index_id IN ( 0, 1 )
|
|
|
|