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;

postgresql-查看表大小的更多相关文章

  1. PostgreSQL查看表大小的命令

    SELECT table_name, pg_size_pretty(table_size) AS table_size, pg_size_pretty(indexes_size) AS indexes ...

  2. mysql查看表大小

    mysql查看表大小 一:命令 show table status like 'table_name'\G; mysql> show table status like 'x'\G; . row ...

  3. sql server查看表大小

    查看SqlServer 数据库中各个表多少行 : SELECT A.NAME ,B.ROWS FROM sysobjects A JOIN sysindexes B ON A.id = B.id WH ...

  4. PostgreSQL查看表、表索引、视图、表结构

    -- 表索引select * from pg_indexes where tablename='person_wechat_label';select * from pg_statio_all_ind ...

  5. SQL Server 2008系统信息查询常用命令 查看表大小、记录数等

    1.返回所有数据库信息(数据库名,创建日期,存储路径等).   use master; GO select * from dbo.sysdatabases 2.返回当前数据库所有对象(可根据type字 ...

  6. MySQL 查看表大小

    当遇到数据库占用空间很大的情况下,可以用以下语句查找大数据量的表 SELECT TABLE_NAME ,),) 'DATA_SIZE(M)' ,),) 'INDEX_SIZE(M)' ,AVG_ROW ...

  7. PostgreSQL查看表、表索引、视图、表结构以及参数设置

    -- 表索引select * from pg_indexes where tablename='person_wechat_label';select * from pg_statio_all_ind ...

  8. PostgreSQL 查看表、索引等创建时间

    select s.oid,s.relname,t.stausename,t.stasubtype from pg_class s,pg_stat_last_operation t where s.re ...

  9. postgresql 查看数据库,表,索引,表空间以及大小

    转载 http://blog.51yip.com/pgsql/1525.html 1,查看数据库 playboy=> \l //\加上字母l,相当于mysql的,mysql> show d ...

  10. mysql工具——使用mysqlshow查看mysql对象信息,查看mysql表大小

    关键词:查看表大小,mysqlshow mysqlshow --count -uroot -p test

随机推荐

  1. 前端之javascript的数据类型1和BOM对象

    一 js对象 BOM对象:browser object model浏览器模型对象 window对象:定时器 DOM对象:文档对象模型 js对象:字符串对象,数组对象,日期对象,math对象 new关键 ...

  2. 2019.01.20 bzoj2238: Mst(kruskal+树链剖分)

    传送门 树链剖分菜题. 题意简述:给一个无向图,边有边权,每次询问删一条边(对后面的询问无影响)之后的最小生成树. 思路: 先跑一次kruskalkruskalkruskal并把跑出来的最小生成树给链 ...

  3. poj-2777(区间线段树,求种类数模板)

    题目链接:http://poj.org/problem?id=2777 参考文章:https://blog.csdn.net/heucodesong/article/details/81038360 ...

  4. 使用bat批处理文件定时自动备份oracle数据库并上传ftp服务器

    一.使用bat批处理文件备份oracle(前提是配置好oracle数据库客户端) @echo off set databasename=orcl  //数据库名 set username=ninic ...

  5. tp5,thinkphp5,隐藏index.php,隐藏入口文件

    一.找到/public/.htaccess文件 Apache: <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews R ...

  6. DDR4控制笔记

      DDR4接口 A[17:0] input 为激活命令提 供行地址,为读.写命令地址输入:提供列地址,也为模式寄存器设 置提供操作码,A[16]只用于8Gb和16Gb,A[17]只用于16Gb,另外 ...

  7. C++遍历目录和文件夹

    我们需要一个结构体和几个函数.这些函数和结构体在<io.h>的头文件中,结构体为struct _finddata_t ,函数为_findfirst._findnext和_fineclose ...

  8. 转:【衬线字体与无衬线字体】font-family之Serif和Sans-Serif

    CSS的font-family(字体系列)的值有许多,如Arial,Georgia,宋体,幼圆等. 一般可以分为两种,衬线字体(serif)和无衬线字体(sans-serif). 如果字体的笔画有末端 ...

  9. 1143 Lowest Common Ancestor

    The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U ...

  10. C#-ado.net学习笔记-会有更新

    ado.net 通用类对象.在本地内存暂存数据 托管类对象.让本地通用类对象连接数据库,让本地通用类对象和数据库同步 连接数据库 new connection(connectstring) comma ...