【PG常用命令】Postgresql常用命令之大小
--設定模式 set search_path to firsoul; --預設只列出當前模式下的表 \d --列出常用模式 \dn --列出所有模式 \dnS --檢視錶的大小 select pg_size_pretty(pg_relation_size('test')); --or \dt+ test --info SELECT n.nspname as "Schema", c.relname as "Name", CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'table' END as "Type", pg_catalog.pg_get_userbyid(c.relowner) as "Owner", pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) as "Size", pg_catalog.obj_description(c.oid, 'pg_class') as "Description" FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r','p','s','') AND n.nspname !~ '^pg_toast' AND c.relname OPERATOR(pg_catalog.~) '^(test)$' AND pg_catalog.pg_table_is_visible(c.oid) ORDER BY 1,2; --檢視模式大小,表,索引 select schemaname ,round(sum(pg_total_relation_size(schemaname||'.'||tablename))/1024/1024) "Size_MB" from pg_tables where schemaname='public' group by 1; select schemaname ,round(sum(pg_total_relation_size(schemaname||'.'||tablename))/1024/1024) "Size_MB" from pg_tables where schemaname='public' group by 1; select schemaname ,round(sum(pg_total_relation_size(schemaname||'.'||indexname))/1024/1024) "Size_MB" from pg_indexes where schemaname='public' group by 1; --查詢資料庫大小 select datname,pg_size_pretty(pg_database_size(datname)) from pg_database;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29487349/viewspace-2375628/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【PG常用命令】postgresql資料庫統計物件大小SQL資料庫物件
- PostgreSQL常用命令大全SQL
- PostgreSQL與MySQL常用命令對照MySql
- Docker之常用命令(二)Docker
- Kubernetes之kubectl常用命令
- 3、Git之常用命令Git
- Docker初探之常用命令Docker
- PostgreSQL-PG程式之checkpoint(四)SQL
- 常用命令
- Linux 常用命令之 top 命令詳解Linux
- DBA常用命令之東北大亂燉
- Git日常常用命令和ADB常用命令Git
- PostgreSQL-PG體系結構之WAL(五)SQL
- PostgreSQL DBA(40) - PG 12 pg_promoteSQL
- 容器技術之Docker常用命令說明Docker
- 大資料開發之常用命令大全大資料
- Maven筆記之核心概念及常用命令Maven筆記
- 常用命令列命令列
- lldb常用命令LLDB
- Solaris常用命令
- Dockers常用命令Docker
- RN常用命令
- MongoDB常用命令MongoDB
- DOS 常用命令
- HDFS常用命令
- hexo常用命令Hexo
- ffprobe常用命令
- 常用命令--curl
- Windows常用命令Windows
- PIP常用命令
- VIM常用命令
- mysql常用命令MySql
- 常用命令-cd
- Redis 常用命令Redis
- CentOS常用命令CentOS
- git 常用命令Git
- Linux 常用命令Linux
- supervisor 常用命令