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:

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

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