6

When you are using things like sys.database_files it gives size of the file, in 8-KB pages, while many other things you are comparing to it to are in MB.

There are a number of ways to convert the 8-KB pages to MB, several ways are offered in the answers to Query to report disk space allocation and used space

The two most common are

  • Multiple by 8 and divide by 1024 (128000 * 8 / 1024 = 100)
  • Divide by 128 (128000 / 128 = 100)

The second is simpler, requiring only a single operation. But both seem to give the same answer.

Is there a good reason to choose one method over the other?

1 Answer 1

9

It's simple math. Those common equations are the same (not seem to give the same answer).

Simpler notation is the only benefit of the second one.

The first one just exlpains from where is the number 128 (8KB per page divides by 1024KB for MB size).

2
  • 3
    It's problem with round the float number in this link. Here we use integers. Feb 13, 2017 at 15:29
  • 3
    As @Pawel said, simple math: 8 is a divisor of 1024: 128000 * 8 / 1024 = 128000 * 8 / (8 * 128) = 12800 / 128.
    – Marian
    Feb 13, 2017 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.