Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the byte size of a row in PostgreSQL

Assuming I have a table in PostgreSQL, how can I find the exact byte size used by the system in order to save a specific row of my table?

For example, assume I have a table with a VARCHAR(1000000) field and some rows contain really big strings for this field while others really small. How can I check the byte size of a row in this case? (including the byte size even in the case TOAST is being used).

like image 935
insumity Avatar asked Nov 12 '13 12:11

insumity


1 Answers

Use pg_column_size and octet_length.

See:

  • How can pg_column_size be smaller than octet_length?
  • How can I find out how big a large TEXT field is in Postgres?
  • How can pg_column_size be smaller than octet_length?
like image 197
Craig Ringer Avatar answered Oct 20 '22 22:10

Craig Ringer