Query Store "Log Memory Used" metric calculation is wrong
I used XE to capture the query being executed when viewing the "Log Memory Used (KB)" metric, and noticed it performs this calculation:
ROUND(CONVERT(float, SUM(rs.avglogbytesused*rs.countexecutions))*1024,2) totallogbytes_used
As you can see, it's attempting to convert bytes to kilobytes by multiplying the bytes by 1024. It should be dividing the bytes by 1024. As it stands, the values displayed in the Query Store reports are off by about a factor of a million.
There's a repro in this Database Administrators Stack Exchange post: https://dba.stackexchange.com/questions/231682/what-is-log-memory-in-query-store-2017
I ran an insert that generated 346,796 avglogbytesused in the sys.querystoreruntimestats view, and the Query Store user shows that it generated a total of 355,119,104 KB.
Dhananjay Kumar Singh commented
The calculation looks wrong and it should have been divide by 1024.. Pls. fix it.