4

In a multi-tenant only one DB, one column is used to isolate customers data, that is customer_id.

Is it possible to get the storage size of a certain customer in all tables?

simo
  • 301
  • 2
  • 4
  • 11

1 Answers1

10

You can use pg_column_size() to get the size of a complete row, not only for a single column.

So to find the size of all rows for a specific customer, you can use something like this:

select sum(pg_column_size(t) + 24) 
from the_table t
where customer_id = 42;

(The 24 is the storage overhead per row in a table)

You would need to do that for all tables you are interested in.

This does however not include the size of those rows in the indexes.