1

We use MS SQL Server transactional replication in our environment. I would like to know if there is a way or script to figure out how much data is being pushed per day to replicated databases?

How to determine how much data is being replicated on a daily basis based on the number of commands?

2
  • What version are you using? Sep 13, 2021 at 15:00
  • How much data is being transmitted over the network, or how much is being stored in the target database, or how much transaction volume would you like to focus in on? Jul 14, 2022 at 23:05

1 Answer 1

1

In the distribution database, there is 2 tables that could help you:

  • MSrepl_transactions
  • MSrepl_commands

For example, you could get the number of commands replicated per day per publisher database with this query:

select t.publisher_database_id,convert(date,entry_time) as entry_date, count(*) as nb_commands 
from MSrepl_transactions t
    INNER JOIN MSrepl_commands c ON t.publisher_database_id=c.publisher_database_id and t.xact_seqno=c.xact_seqno
GROUP BY t.publisher_database_id,convert(date,entry_time) 

2 details to be aware of:

  • By default, transaction retention period is 72 hours, so you should be able to get statistics for that period, unless your distributor has a different configuration.
  • MSrepl_transactions' entry_time is the time when the transaction was inserted into distribution database, not the execution time on publisher database.
1
  • 2
    Additionally useful would be analyzing SUM(DATALENGTH(c.command)) (or SUM(DATALENGTH(c.command/1024.0/1024.0))) to get the total size of the commands being pushed across replication to estimate the "how much data" in bytes (or megabytes).
    – AMtwo
    Sep 13, 2021 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.