0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Redshiftでテーブルごとの容量とカラムごとの容量を出力する

Last updated at Posted at 2020-04-08

いずれも管理者で実行する

テーブルごとの容量

SELECT
    TRIM(du.name) AS table_name,
    COUNT(1) AS mb
FROM
    svv_diskusage du
GROUP BY table_name
ORDER BY mb;

カラムごとの容量

SELECT
    TRIM(du.name) AS table_name,
    TRIM(atr.attname) AS column_name,
    COUNT(1) AS mb
FROM
    svv_diskusage du, pg_attribute atr
WHERE
        du.col = atr.attnum-1 AND
        du.tbl = atr.attrelid
GROUP BY 1, 2
ORDER BY 1, 3;

参考

https://docs.aws.amazon.com/ja_jp/redshift/latest/dg/r_SVV_DISKUSAGE.html
https://qiita.com/nabewata07/items/5c474b62c0c1c24df01a
https://gist.github.com/yujihamaguchi/b817e518117c63c73d8a

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?