cancel
Showing results for 
Search instead for 
Did you mean: 

Data_length of all table and all columns in bytes

Question: How do we get data_length of all table and all columns in bytes

 

Answer: You can use the PG_COLUMN_SIZE function to check the size of every column in bytes.

For example:

 

edb=# create table aruntb1 (id numeric(10,0),text varchar(40),roll varchar(10));
CREATE TABLE

 

edb=# \d+ aruntb1
Table "enterprisedb.aruntb1"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+-----------------------+-----------+----------+---------+----------+--------------+-------------
id | numeric(10,0) | | | | main | |
text | character varying(40) | | | | extended | |
roll | character varying(10) | | | | extended | |


edb=# SELECT PG_COLUMN_SIZE(id) length_of_id_col, PG_COLUMN_SIZE(TEXT) length_of_text_col FROM aruntb1 ;

length_of_id_col | length_of_text_col
------------------+--------------------
5 | 26
5 | 39
5 | 39
5 | 41

 

Version history
Revision #:
4 of 4
Last update:
‎03-06-2019 11:44 AM
Updated by:
 
Contributors