Jorriss / StatisticsParser

Parses and formats SQL Server Statistics IO and Statistics Time output.
http://statisticsparser.com
90 stars 42 forks source link

The intermediate totals rely on "row(s) affected" or other line separation between queries #42

Open RichardBrookfield opened 7 years ago

RichardBrookfield commented 7 years ago

I spotted this problem on a much more complicated piece of SQL where the same table was used in two consecutive queries. It reacts in the same way in simple cases too, e.g. SQL like this on AdventureWorks:

set statistics io on set nocount on select top 100 from Person.Address set nocount off select top 100 from Person.Address

will work correctly. However, if the count is completely turned off, e.g.:

set statistics io on set nocount on select top 100 from Person.Address select top 100 from Person.Address

then it will not.

Let's assume this generates 4 Logical Reads on Address for each execution.

  1. Without "rows affected", it reports subtotals of 8+4=12 (wrong), but total 8 (correct)
  2. With "rows affected", it correctly reports two queries of 4 each and then a correct total of 8

Even just a newline in the output (between the two queries) is enough to correct the issue.