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;
  • 相关阅读:
    散点图增加趋势线
    asp.net自动刷新获取数据
    jQuery在asp.net中实现图片自动滚动
    tornado 学习笔记一:模板
    node.js 学习笔记二:创建属于自己的模块
    mysql 5.6 innodb memcache 操作学习一
    unicode,str
    node.js 学习笔记四:读取文件
    gevent 学习笔记一
    while 循环居然可以用else
  • 原文地址:https://www.cnblogs.com/zhangfx01/p/10216227.html
Copyright © 2011-2022 走看看