I am trying to understand and analyse a CPU intensive select query in SQL Server, however, I see something strange which is a negative number as logical reads. I wonder if it is a mathematical overflow issue or it is a meaningful number.
I’m using:
Microsoft SQL Server 2019 (RTM-CU29-GDR) (KB5046860) - 15.0.4410.1 (X64)
I used Statistics Parser:
Here is the raw output:
Table 'T1'. Scan count 26722, logical reads -571819170, physical reads 194, page server reads 0, read-ahead reads 13211, page server read-ahead reads 0,
lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
0
I see something strange which is a negative number as logical reads. I wonder if it is a mathematical overflow issue or it is a meaningful number.
It’s not meaningful. There appears to be an integer overflow happening somewhere.
Statistics Parser just reformats the output from SET STATISTICS IO
. It doesn’t appear to have any problems displaying logical reads over 2,147,483,647.
Your raw STATISTICS IO
output also shows a negative number. I don’t remember ever experiencing this myself, but then I only use recent versions of SSMS.
Perhaps you’re using an old SSMS version, a different client altogether, or SQL Server connection driver. Something that can only handle 32 bits anyway.
The root cause is difficult to identify from the information provided, but then again, that’s not the question you asked.
0