Search Postgresql Archives

Re: PostgreSQL 9.6 Temporary files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/19/2018 10:17 AM, Melvin Davidson wrote:



*
*I think your problem is that SELECT pg_size_pretty(pg_total_relation_size('table_name')); only looks at the current database


*
*but SELECT pg_size_pretty(pg_database_size('Database Name')); looks at ALL databases.

Not according to here:

https://www.postgresql.org/docs/10/static/functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT

*
*Try this query instead to show individual database sizes.

SELECT oid,
        datname,
        pg_size_pretty(pg_database_size(datname))as size_pretty,
        pg_database_size(datname) as size,
        (SELECT pg_size_pretty (SUM( pg_database_size(datname))::bigint)
           FROM pg_database)  AS total,
       ((pg_database_size(datname) / (SELECT SUM( pg_database_size(datname))                                        FROM pg_database) ) * 100)::numeric(6,3) AS pct
   FROM pg_database
   ORDER BY datname;
*

--
*Melvin Davidson**
Maj. Database & Exploration Specialist**
Universe Exploration Command – UXC***
Employment by invitation only!


--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux