暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

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

digoal 2019-04-09
351

作者

digoal

日期

2019-04-09

标签

PostgreSQL , psql , 快捷命令 , dP , 列出分区表


背景

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 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论