Given that the size is variable, I am trying to calculate the average cost of a numeric(p, s) attribute. In my case, numeric(10, 2).
From what I understand of the Postgres documentation, this means I have a total of 10 digits where 2 of them are exclusive of the decimal part, hence, the maximum value I can store is 99999999,99.
What I do not understand is this part of the documentation:
The actual storage requirement is two bytes for each group of four decimal digits, plus three to eight bytes overhead.
My two questions here are:
- If I have two decimal digits, that means the storage requirement for them would be one byte?
- If I have three to eight bytes overhead, how can I know which value corresponds to my case?
I ran a query with an average of pg_column_size that gave me a total of 6.95 bytes. However, I want to know if there is any way I can calculate the approximate value before checking the actual one. (Same with other variable types in Postgres)