Open In App

PostgreSQL – Size of value

Last Updated : 28 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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:


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads