作者
digoal
背景
PostgreSQL 12 psql客户端支持快捷键dP列出分区表。
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)