Pg扩展查询sql

Pg查看每个表所占用磁盘空间大小

参考连接:https://blog.csdn.net/yueludanfeng/article/details/86487585

-- 方法1
select
    table_full_name,
    round( CAST ( size as numeric ) / 1024 / 1024 / 1024, 2 ) || 'G' size 
from
    (
    SELECT
        table_schema || '.' || table_name AS table_full_name,
        pg_total_relation_size ( '"' || table_schema || '"."' || table_name || '"' ) AS size 
    FROM
        information_schema.tables 
    ORDER BY
    pg_total_relation_size ( '"' || table_schema || '"."' || table_name || '"' ) DESC 
    ) t

-- 方法2
SELECT
    schemaname,
    relname,
    round( CAST ( pg_total_relation_size ( relid ) as numeric ) / 1024 / 1024 / 1024, 2 ) || 'G' as table_size,
    n_live_tup 
FROM
    pg_stat_user_tables 
where 1 = 1
    and schemaname = 'rf_supervision' 
  and relname like  't_user%'
    ORDER BY pg_total_relation_size ( relid ) desc

pg查询表记录数

select
    relname as TABLE_NAME,
    reltuples,
    to_char(reltuples, 'FM99999999') as rowCounts 
from
    pg_class 
where
    relkind = 'r' 
    and relnamespace = ( select oid from pg_namespace where nspname = 's_system' ) 
    --and relname = 't_user'
order by
    reltuples desc;
;
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇