microsoft / azure-sql-tips

A T-SQL script for improving database configuration and design in Azure SQL DB.
https://aka.ms/sqldbtips
MIT License
144 stars 51 forks source link

Wrong table size filter expression in tip 1290 #64

Closed EitanBlumin closed 2 years ago

EitanBlumin commented 2 years ago

The parameter @CCICandidateMinSizeGB, based on its name, is in GB. When it's used within the WHERE expression, it's divided by 1024 when compared against a value in MB:

      tos.table_size_mb > @CCICandidateMinSizeGB / 1024. -- consider sufficiently large tables only

However, dividing a number that represents GB by 1024 would represent TB, not MB. In order to be represented in MB, it needs to be MULTIPLIED by 1024. Not divided by 1024.

Like this:

      tos.table_size_mb > @CCICandidateMinSizeGB * 1024. -- consider sufficiently large tables only

https://github.com/microsoft/azure-sql-tips/blob/main/sqldb-tips/get-sqldb-tips.sql#L3431

dimitri-furman commented 2 years ago

Thanks for catching this @EitanBlumin. We will be fixing this shortly.