Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMZ9v-0002kZ-CD for pgsql-hackers@arkaria.postgresql.org; Fri, 03 May 2019 14:27:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hMZ9u-0001xi-58 for pgsql-hackers@arkaria.postgresql.org; Fri, 03 May 2019 14:27:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMZ9t-0001qe-Lq for pgsql-hackers@lists.postgresql.org; Fri, 03 May 2019 14:27:29 +0000 Received: from mail-it1-x133.google.com ([2607:f8b0:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMZ9p-0003pD-Ms for pgsql-hackers@postgresql.org; Fri, 03 May 2019 14:27:28 +0000 Received: by mail-it1-x133.google.com with SMTP id q65so7907035itg.2 for ; Fri, 03 May 2019 07:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ueMn4iEUxnApxOs5ftAescF4+k1a9rb2fS/r+KnDH1c=; b=1xUrdmPZsAvWbc9A1fU2of+S5GlyltTDuoYBlZbsywcwJd5iTlxrJDIwp79lBfqs7d ET8y91w519v+YNyXnuWnPZzgRAxZ22tYw6GTfjjiBshp4avpv5/X7qgoiha3FYdkfy9o 4m8PO3gIki05lvQdTsV7HRyNN7pkJDgykALsA2suzCZHlabtRPwyDaS+frSGND7XC/LW jNsPEyCTHvtmZR7Z+PWw5JWD2M99Ol7EVP9pHaK06Ech9f42TzGrdOWAo9l+yxgsyhZT Loy1aEHY+o6vJXFDeyy07i94qv/z1qJc62SeLFYqsy1qy4XTwHtTFINRazNkimE1GXw1 3PJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ueMn4iEUxnApxOs5ftAescF4+k1a9rb2fS/r+KnDH1c=; b=Qhjj9wqDSsyXzIKyBxnxVxpNUuL+xXishkrtyG23igWcyR7nQF32LShKzVxMW5qLcI K8kTeak4ztcAvADXyt5BidchT53RUdf8oHv2LUVzeVpHKqougER4PI5vkXPdy/6ZWOES xlxC5HVX1L+VgFmxVFvtgFnpGxACPJhIYuiSalB20KdMbQ/OuLoZZIK5Z1VP9EBl1Xgb FHVHOshJ1LQP3vK9nXPdSAGdg1grwyeURgcEM5tWuA0/YOpUmmwjkqv96rwreyINao/r D4iPCQ63AyBZ/mLd0eFJcQfMMT98jftliTvENiiY2fHbKfWlxbhBH+ImZw2/r4+IjnAq dJQA== X-Gm-Message-State: APjAAAUJ4KVF7z+UArZCo4rpynTaIRmva1VuCkbRV1B6TD8oxZjxWhQ0 g04bsqevkMQSGtRPSO17mMPJFQ== X-Google-Smtp-Source: APXvYqwbOYaHIW8FPyKYZiOC8oT69RQG9o4qe7xpqYdAKkekHkv0RKmmigxww89qt394/vdXtCIeAw== X-Received: by 2002:a24:9d96:: with SMTP id f144mr6966263itd.139.1556893644773; Fri, 03 May 2019 07:27:24 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id l191sm1444003itc.8.2019.05.03.07.27.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 07:27:23 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 1DA2D800BA5; Fri, 3 May 2019 09:27:22 -0500 (CDT) Date: Fri, 3 May 2019 09:27:22 -0500 From: Justin Pryzby To: Rafia Sabih Cc: PostgreSQL-development Subject: Re: make \d pg_toast.foo show its indices Message-ID: <20190503142721.GC3925@telsasoft.com> References: <20190422154902.GH14223@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="brEuL7wsLY8+TuWz" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --brEuL7wsLY8+TuWz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, May 03, 2019 at 02:55:47PM +0200, Rafia Sabih wrote: > On Mon, 22 Apr 2019 at 17:49, Justin Pryzby wrote: > > > > It's deliberate that \dt doesn't show toast tables. > > \d shows them, but doesn't show their indices. > > > > It seems to me that their indices should be shown, without having to think and > > know to query pg_index. > > > > postgres=# \d pg_toast.pg_toast_2600 > > TOAST table "pg_toast.pg_toast_2600" > > Column | Type > > ------------+--------- > > chunk_id | oid > > chunk_seq | integer > > chunk_data | bytea > > Indexes: > > "pg_toast_2600_index" PRIMARY KEY, btree (chunk_id, chunk_seq) > > +1. Thanks - what about also showing the associated non-toast table ? postgres=# \d pg_toast.pg_toast_2620 TOAST table "pg_toast.pg_toast_2620" Column | Type ------------+--------- chunk_id | oid chunk_seq | integer chunk_data | bytea FOR TABLE: "pg_catalog.pg_trigger" Indexes: "pg_toast_2620_index" PRIMARY KEY, btree (chunk_id, chunk_seq) That could be displayed differently, perhaps in the header, but I think this is more consistent with other display. Justin --brEuL7wsLY8+TuWz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-make-d-pg_toast.foo-show-its-indices.patch" From 7c15ebe408cc5f2af51120ea152e7997ee768f81 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Fri, 3 May 2019 09:24:51 -0500 Subject: [PATCH v2 1/2] make \d pg_toast.foo show its indices --- src/bin/psql/describe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index d7390d5..d26d986 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2274,6 +2274,7 @@ describeOneTableDetails(const char *schemaname, else if (tableinfo.relkind == RELKIND_RELATION || tableinfo.relkind == RELKIND_MATVIEW || tableinfo.relkind == RELKIND_FOREIGN_TABLE || + tableinfo.relkind == RELKIND_TOASTVALUE || tableinfo.relkind == RELKIND_PARTITIONED_TABLE) { /* Footer information about a table */ -- 2.7.4 --brEuL7wsLY8+TuWz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0002-print-table-associated-with-given-TOAST-table.patch" From 38f50cdb727c67ae7aece8e85caf2960e824cb65 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Tue, 30 Apr 2019 19:05:53 -0500 Subject: [PATCH v2 2/2] print table associated with given TOAST table --- src/bin/psql/describe.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index d26d986..ebdf18a 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2152,6 +2152,28 @@ describeOneTableDetails(const char *schemaname, } } + /* print table associated with given TOAST table */ + if (tableinfo.relkind == RELKIND_TOASTVALUE) + { + PGresult *result = NULL; + printfPQExpBuffer(&buf, + "SELECT relnamespace::pg_catalog.regnamespace, relname FROM pg_class WHERE reltoastrelid = '%s'", + oid); + result = PSQLexec(buf.data); + if (!result) { + goto error_return; + } else if (1 != PQntuples(result)) { + PQclear(result); + goto error_return; + } else { + char *schemaname = PQgetvalue(result, 0, 0); + char *relname = PQgetvalue(result, 0, 1); + appendPQExpBuffer(&tmpbuf, _("For table: \"%s.%s\""), + schemaname, relname); + printTableAddFooter(&cont, tmpbuf.data); + } + } + if (tableinfo.relkind == RELKIND_PARTITIONED_TABLE) { /* Get the partition key information */ -- 2.7.4 --brEuL7wsLY8+TuWz--