patternsqlMinor
What is the overhead for an array in Postgres?
Viewed 0 times
thewhatpostgresarrayforoverhead
Problem
What is the additional overhead of an array compared to a normal column of that same datatype? In other words, if an array will almost always have one value in it, how much space would I be "wasting" by using an array instead of a normal column?
Solution
You can check that using
returns:
So the overhead is substantial for just a single value.
pg_column_size():select pg_column_size(1::integer) as int_size,
pg_column_size(array[1]::integer[]) as array_sizereturns:
int_size | array_size
---------+-----------
4 | 28
So the overhead is substantial for just a single value.
Code Snippets
select pg_column_size(1::integer) as int_size,
pg_column_size(array[1]::integer[]) as array_sizeContext
StackExchange Database Administrators Q#156423, answer score: 6
Revisions (0)
No revisions yet.