Thread: Correct table size when a using short integer array type.

Correct table size when a using short integer array type.

From
"Shivin M"
Date:
Hello!

I'm trying to store an array of short integers in a table. The array that I have is very long, consisting of ~6000000 elements (each element is a value from a time-series, hence the length). Given that all the values in the time series are of short integer type, I'd expect them to use:

6000000 x 2 Bytes = 12 MB

So somewhere around 12 MB.

Here are the statistics of the table in which I inserted these values (the table has attributes: id - int4; digital_values - int2[] )

Table statisticsStatistic Value
Sequential Scans 2
Sequential Tuples Read 1
Index Scans 1
Index Tuples Fetched 1
Tuples Inserted 1
Tuples Updated 1
Tuples Deleted 0
Heap Blocks Read 0
Heap Blocks Hit 0
Index Blocks Read 0
Index Blocks Hit 0
Toast Blocks Read 0
Toast Blocks Hit 0
Toast Index Blocks Read 0
Toast Index Blocks Hit 0
Table Size 8192 bytes
Toast Table Size 19 MB
Indexes Size 16 kB

-----
 
The toast table size is 19 MB. Is there a reason why I see more physical storage used by the table than what I'd expect it to use? I have to do this for many more records and tables. Thus it makes a huge impact, storage-wise.

Thanks!

- Shivin