PostgreSQL: How to measure the size of a Table Row and Data Page?

In this post, I am sharing one script to measure the size of a PostgreSQL Table Row.

I have taken reference from this dba.statckexchange.

But again, I would like to share this information with some additional information.

I have recently shared one article on Fillfactor storage parameter of PostgreSQL Table.

Before changing the default value of Fillfactor, we should measure the size of Table Row.
This is very important to know because if table row is larger, we should not change the default value of Fillfactor.

When we are doing performance optimization, this is very important to find the size of Data page and Table row, otherwise unnecessary we are dealing with high fragmentation and executing VACUUM FULL again and again.

If your total row size is under 8kb, you can take decision to alter table storage parameters.

Create sample table using JSON data type:

Insert few sample JSON formatted record:

Script to measure the size of Table row and Data page:

Anvesh Patel

Leave a Reply

2 Comments on "PostgreSQL: How to measure the size of a Table Row and Data Page?"

Notify of
Sort by:   newest | oldest | most voted

ERROR: relation “public.tbl_testjson” does not exist
LINE 7: FROM public.tbl_testjson AS t