PostgreSQL View Table Size

Source: Internet
Author: User
Tags postgresql

Turn from: http://blog.csdn.net/rocklee/article/details/51251174 invasion and deletion

Simple.
select pg_size_pretty(pg_relation_size(‘table_name‘));
View table size and sort
SELECT table_schema || ‘.‘ || table_name AS table_full_name, pg_size_pretty(pg_total_relation_size(‘"‘ ||table_schema || ‘"."‘ || table_name || ‘"‘)) AS sizeFROM information_schema.tablesORDER BY    pg_total_relation_size(‘"‘ || table_schema || ‘"."‘ || table_name || ‘"‘)DESC limit 20
Find table size and detach data and index
SELECT    table_name,    pg_size_pretty(table_size) AS table_size,    pg_size_pretty(indexes_size) AS indexes_size,    pg_size_pretty(total_size) AS total_sizeFROM (    SELECT        table_name,        pg_table_size(table_name) AS table_size,        pg_indexes_size(table_name) AS indexes_size,        pg_total_relation_size(table_name) AS total_size    FROM (        SELECT (‘"‘ || table_schema || ‘"."‘ || table_name || ‘"‘) AS table_name        FROM information_schema.tables    ) AS all_tables    ORDER BY total_size DESC) AS pretty_sizes

PostgreSQL View Table Size

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.