Basically i want to be able to get the size of a table in bytes used by a particular user.
I have a user table and i have the id of this table in every other table in the database.
This code gets me the size in bytes of all tables in the database.
SELECT relname as "Table", pg_size_pretty(pg_total_relation_size(relid)) As "Size" FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
But i want to add a where clause to get only for a particular user id in the tables.
EDITED: The possible duplicate answers only half of my question. I basically want a more specific size based on a column present in every table.
Something like this. SELECT relname as "Table", pg_size_pretty(pg_total_relation_size(relid)) As "Size" FROM pg_catalog.pg_statio_user_tables WHERE "table_name"."user_id" = 1 ORDER BY pg_total_relation_size(relid) DESC;