ITPub博客

首页 > > > PostgreSQL 12 preview - psql 快捷命令 \dP 列出

PostgreSQL 12 preview - psql 快捷命令 \dP 列出

作者:wangliyun 时间:2019-04-24 14:20:57 0 删除 编辑

作者

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


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69917105/viewspace-3118021/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2019-04-19

  • 博文量
    213
  • 访问量
    317