绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
PostgreSQL 12 preview - psql 快捷命令 \dP 列出
2019-04-24 14:20:57

作者

digoal

背景

PostgreSQL 12 psql客户端支持快捷键dP列出分区表。

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1c5d9270e339662cdd78d51d0b859d4f0a11aa91

psql \dP: list partitioned tables and indexes  
author	Alvaro Herrera <alvherre@alvh.no-ip.org>	  
Sun, 7 Apr 2019 19:59:12 +0800 (07:59 -0400)  
committer	Alvaro Herrera <alvherre@alvh.no-ip.org>	  
Mon, 8 Apr 2019 03:07:21 +0800 (15:07 -0400)  
commit	1c5d9270e339662cdd78d51d0b859d4f0a11aa91  
tree	ff2f59ecd3e90c999f081121748b44ab1400804c	tree | snapshot  
parent	159970bcadbbdefd312d75ce7ad90f19add19b40	commit | diff  
psql \dP: list partitioned tables and indexes  
  
The new command lists partitioned relations (tables and/or indexes),  
possibly with their sizes, possibly including partitioned partitions;  
their parents (if not top-level); if indexes show the tables they belong  
to; and their descriptions.  
  
While there are various possible improvements to this, having it in this  
form is already a great improvement over not having any way to obtain  
this report.  
  
Author: Pavel Stěhule, with help from Mathias Brossard, Amit Langote and  
Justin Pryzby.  
Reviewed-by: Amit Langote, Mathias Brossard, Melanie Plageman,  
Michaël Paquier, Álvaro Herrera

例子

create table p (id int , info text, crt_time timestamp) partition by hash (id);    
create table p0 partition of p  for values WITH (MODULUS 4, REMAINDER 0);    
create table p1 partition of p  for values WITH (MODULUS 4, REMAINDER 1);    
create table p2 partition of p  for values WITH (MODULUS 4, REMAINDER 2);   
create table p3 partition of p  for values WITH (MODULUS 4, REMAINDER 3);    
insert into p select generate_series (1,100000000) , md5(random()::text), now();  
  
  
postgres=# \dP+  
                           List of partitioned relations  
 Schema | Name |  Owner   |       Type        | On table | Total size | Description   
--------+------+----------+-------------------+----------+------------+-------------  
 public | p    | postgres | partitioned table |          | 7303 MB    |   
(1 row)

参考

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1c5d9270e339662cdd78d51d0b859d4f0a11aa91


分享好友

分享这个小栈给你的朋友们,一起进步吧。

PostgreSQL中文社区小栈
创建时间:2019-04-19 17:47:49
PostgreSQL中文社区是一个非盈利的民间组织,已经在中国成功举办过8届技术大会。目前成员都以志愿者身份加入,成立的目的在于构建PG数据库技术生态圈子(内核、用户、培训机构、厂商、服务商、软件开发商、高校形成“业务与利益双向驱动”的良性发展生态圈);帮助企业解决人才培养和企业商用数据库成本问题。社区会在各运营平台发布PG新信息和PG相关技术文章,推动PG技术在中国的发展。
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

栈主、嘉宾

查看更多
  • wangliyun
    栈主
  • digoal
    嘉宾
  • 飘絮絮絮丶
    嘉宾

小栈成员

查看更多
  • 栈栈
  • 喵呜
  • osdba
  • 一号管理员
戳我,来吐槽~