Skip to content

Instantly share code, notes, and snippets.

@databoffin
Created October 17, 2017 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save databoffin/e153ce5bc8e3d222d7118c582a8aab68 to your computer and use it in GitHub Desktop.
Save databoffin/e153ce5bc8e3d222d7118c582a8aab68 to your computer and use it in GitHub Desktop.
Query to track the throughput of SQL Server distribution databases
USE distribution;
GO
--Track the throughput per minute
SELECT CONVERT(SMALLDATETIME, t.entry_time) AS EntryTime,
COUNT(1) AS Commands
FROM MSrepl_commands cmds
INNER JOIN MSarticles a ON a.article_id = cmds.article_id
INNER JOIN MSrepl_transactions t ON cmds.xact_seqno = t.xact_seqno
GROUP BY CONVERT(SMALLDATETIME, t.entry_time)
ORDER BY CONVERT(SMALLDATETIME, t.entry_time) DESC;
--Track the throughput per article, per minute
SELECT a.article,
CONVERT(SMALLDATETIME, t.entry_time) AS EntryTime,
COUNT(1) AS Commands
FROM MSrepl_commands cmds
INNER JOIN MSarticles a ON a.article_id = cmds.article_id
INNER JOIN MSrepl_transactions t ON cmds.xact_seqno = t.xact_seqno
--WHERE a.article = 'SuspectedTable'
GROUP BY a.article, CONVERT(SMALLDATETIME, t.entry_time)
HAVING COUNT(1) > 1000
ORDER BY CONVERT(SMALLDATETIME, t.entry_time) DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment