Following on from this prior question about relation sizes:
This query:
query = "CREATE TEMPORARY TABLE query_out AS SELECT * FROM users WHERE is_admin = false"
ActiveRecord::Base.connection.execute(query)
will generate a temporary table and insert all the records from this query i.e
SELECT * FROM users WHERE is_admin = false
then
ActiveRecord::Base.connection.execute("SELECT pg_size_pretty(pg_relation_size('query_out'))")
I am only getting the the size of one table.
What doI need to do so that I can the size of multiple tables in one single query?
Any help would be appreciated.
Thanks
It will give the size of that temporary table.
Following select query will returns all the table and its size's
Create a VIEW with this select
and now you can query on this view to get the size like this
As per OP's Comment
and get the size sum of multiple columns using
Create
vTableAndSize_1
in yourPostgreSQL
database and query like below in your front end(am not familiar withRuby
)