PostgreSQL – Size of value
Last Updated :
28 Aug, 2020
The size of a value means the space needed to store a specific value in the database table.In this article we will look into function that is used to get the size of the PostgreSQL database value.
The pg_column_size()
function is used to get the size of a value.
Syntax: select pg_column_size(no. of values :: type of value)
Here we will be using a sample database for reference which is described here and can be downloaded from here
Example 1:
Here we will query for space required to store 10 values of smallint
type using the below command:
select pg_column_size(10::smallint);
Output:
Example 2:
Here we will query for space required to store 10 values of int
type using the below command:
select pg_column_size(10::int);
Output:
Example 3:
Here we will query for space required to store 10 values of bigint
type using the below command:
select pg_column_size(10::bigint);
Output:
Share your thoughts in the comments
Please Login to comment...