zoukankan      html  css  js  c++  java
  • postgresql-查看表大小

    drop table tablesize
    create table tablesize( phone int)
    create table tablesize( phone text)
    create table tablesize( phone char(30))
    create table tablesize( phone varchar(3000))
    create index i_table_size_phone on tablesize(phone)
    insert into tablesize values('1111')
    insert into tablesize values(1111)
     
    select pg_size_pretty(pg_relation_size('tablesize'))--表达小,不包含索引和toast
     
    select pg_size_pretty(pg_relation_size('i_table_size_phone'))--索引大小
    select pg_size_pretty(pg_total_relation_size('tablesize')); --表达小包含toast,和索引大小
     
    select pg_size_pretty(pg_table_size('tablesize'))--表达小,包含toast大小
     
     
    select oid from pg_database where datname = 'test'
     
    select pg_relation_filepath('tablesize');
     
    select pg_column_size('phone')
    --查看表大小和索引大小
    select relname,pg_size_pretty(pg_relation_size(oid)) from pg_class where relname like '%t1%' order by relname;
     
    select oid,relfilenode,relname from pg_class where relfilenode = '20221126'
    select oid,relfilenode,relname from pg_class where relfilenode = '20221113'
     
    pg查看表膨胀:
    查看表膨胀(对所有表产进行膨胀率排序)
     
    SQL文如下:
     
    SELECT
    schemaname||'.'||relname as table_name,
    pg_size_pretty(pg_relation_size(schemaname||'.'||relname)) as table_size,
    n_dead_tup,
    n_live_tup,
    round(n_dead_tup * 100 / (n_live_tup + n_dead_tup),2) AS dead_tup_ratio
    FROM
    pg_stat_all_tables
    WHERE
    n_dead_tup >= 1000
    ORDER BY dead_tup_ratio DESC
    LIMIT 10;
  • 相关阅读:
    1.Basic Structure
    React生成组件类
    React遍历标签数组
    React遍历数组
    React节点插入内容
    -Dmaven.multiModuleProjectDirectory system property is not set
    Openstack_通用模块_Oslo_vmware 创建/删除 vCenter 虚拟机
    perl 安装AnyEvent::HTTP
    建立可视化决策平台,“数据化”首当其冲!
    建立可视化决策平台,“数据化”首当其冲!
  • 原文地址:https://www.cnblogs.com/zhangfx01/p/10216227.html
Copyright © 2011-2022 走看看