psql_tablesize.patch
application/octet-stream
Filename: psql_tablesize.patch
Type: application/octet-stream
Part: 0
Message:
psql \dt and table size
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/bin/psql/describe.c | 0 | 0 |
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index a89c938..f21d8a1 100644
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
*************** listTables(const char *tabtypes, const c
*** 2522,2531 ****
",\n c2.relname as \"%s\"",
gettext_noop("Table"));
! if (verbose && pset.sversion >= 80100)
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(c.oid)) as \"%s\"",
gettext_noop("Size"));
if (verbose)
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",
--- 2522,2546 ----
",\n c2.relname as \"%s\"",
gettext_noop("Table"));
! if (pset.sversion >= 80100 && pset.sversion < 90000)
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(c.oid)) as \"%s\"",
gettext_noop("Size"));
+ else if (pset.sversion >= 90000) {
+ /*
+ * As of PostgreSQL 9.0, use pg_table_size() to show a more acurate size
+ * of a table, including FSM, VM and TOAST tables.
+ */
+ if (showTables)
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) as \"%s\"",
+ gettext_noop("Size"));
+ else
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(c.oid)) as \"%s\"",
+ gettext_noop("Size"));
+ }
+
if (verbose)
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",