Show statistics target in \d+
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.
Comments/reivews?
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
Attachments:
psql_stats_target.patchtext/x-patch; charset=US-ASCII; name=psql_stats_target.patchDownload
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index d5466f8..426d934 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1280,6 +1280,7 @@ describeOneTableDetails(const char *schemaname,
if (verbose)
{
appendPQExpBuffer(&buf, ",\n a.attstorage");
+ appendPQExpBuffer(&buf, ",\n a.attstattarget");
/*
* In 9.0+, we have column comments for: relations, views, composite
* types, and foreign tables (c.f. CommentObject() in comment.c).
@@ -1374,6 +1375,8 @@ describeOneTableDetails(const char *schemaname,
if (verbose)
{
headers[cols++] = gettext_noop("Storage");
+ if (tableinfo.relkind == 'r')
+ headers[cols++] = gettext_noop("Statistics");
/* Column comments, if the relkind supports this feature. */
if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v' ||
tableinfo.relkind == 'c' || tableinfo.relkind == 'f')
@@ -1473,10 +1476,18 @@ describeOneTableDetails(const char *schemaname,
(storage[0] == 'e' ? "external" :
"???")))),
false, false);
+
+ /* Statistics target, if the relkind supports this feature */
+ if (tableinfo.relkind == 'r')
+ {
+ printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1),
+ false, false);
+ }
+
/* Column comments, if the relkind supports this feature. */
if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v' ||
tableinfo.relkind == 'c' || tableinfo.relkind == 'f')
- printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1),
+ printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 2),
false, false);
}
}
2011/11/4 Magnus Hagander <magnus@hagander.net>:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.Comments/reivews?
Interesting, can the ouput be clear on the value being a default or an
explicit stat target ? (not mandatory but I believe I would like to
have it only when the stat target is jnot the default)
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Cédric Villemain +33 (0)6 20 30 22 52
http://2ndQuadrant.fr/
PostgreSQL: Support 24x7 - Développement, Expertise et Formation
On Fri, Nov 4, 2011 at 14:53, Cédric Villemain
<cedric.villemain.debian@gmail.com> wrote:
2011/11/4 Magnus Hagander <magnus@hagander.net>:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.Comments/reivews?
Interesting, can the ouput be clear on the value being a default or an
explicit stat target ? (not mandatory but I believe I would like to
have it only when the stat target is jnot the default)
It shows -1 when it's the default.
We could map that to the string "default" if we want, or just NULL, I
guess. Not sure which is best?
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
On Fri, Nov 4, 2011 at 9:34 AM, Magnus Hagander <magnus@hagander.net> wrote:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.Comments/reivews?
"Statistics" doesn't seem like a very clear name for the column header.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Fri, Nov 4, 2011 at 15:06, Robert Haas <robertmhaas@gmail.com> wrote:
On Fri, Nov 4, 2011 at 9:34 AM, Magnus Hagander <magnus@hagander.net> wrote:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.Comments/reivews?
"Statistics" doesn't seem like a very clear name for the column header.
Got any ideas for a better one? "Statistics Target" seemed too long to
me, and "Statstarget" not necessarily very user friendly?
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
On Fri, Nov 4, 2011 at 10:09 AM, Magnus Hagander <magnus@hagander.net> wrote:
On Fri, Nov 4, 2011 at 15:06, Robert Haas <robertmhaas@gmail.com> wrote:
On Fri, Nov 4, 2011 at 9:34 AM, Magnus Hagander <magnus@hagander.net> wrote:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.Comments/reivews?
"Statistics" doesn't seem like a very clear name for the column header.
Got any ideas for a better one? "Statistics Target" seemed too long to
me, and "Statstarget" not necessarily very user friendly?
I would prefer "Stats Target" to "Statistics", because I think it's more clear.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Fri, Nov 4, 2011 at 10:05 AM, Magnus Hagander <magnus@hagander.net> wrote:
On Fri, Nov 4, 2011 at 14:53, Cédric Villemain
Interesting, can the ouput be clear on the value being a default or an
explicit stat target ? (not mandatory but I believe I would like to
have it only when the stat target is jnot the default)It shows -1 when it's the default.
We could map that to the string "default" if we want, or just NULL, I
guess. Not sure which is best?
I thought -1 was just fine. The ALTER TABLE doc page is clear that -1
means the system default, and having another value may just confuse
users.
Josh
* Magnus Hagander (magnus@hagander.net) wrote:
On Fri, Nov 4, 2011 at 15:06, Robert Haas <robertmhaas@gmail.com> wrote:
Comments/reivews?
"Statistics" doesn't seem like a very clear name for the column header.
Got any ideas for a better one? "Statistics Target" seemed too long to
me, and "Statstarget" not necessarily very user friendly?
I don't think we need to kill ourselves over making it super
user-friendly. If they don't know what it is/means, they can go read
the docs. :) I agree w/ Robert that 'Statistics' is a bad name. I'd
suggest 'stat_target'.
Thanks,
Stephen
Magnus Hagander <magnus@hagander.net> wrote:
Interesting, can the ouput be clear on the value being a default
or an explicit stat target ? (not mandatory but I believe I would
like to have it only when the stat target is jnot the default)It shows -1 when it's the default.
We could map that to the string "default" if we want, or just
NULL, I guess. Not sure which is best?
I think it would be most useful for it to show as blank, so that
overrides stand out. NULL seems the best way to do that.
-Kevin
2011/11/4 Josh Kupershmidt <schmiddy@gmail.com>:
On Fri, Nov 4, 2011 at 10:05 AM, Magnus Hagander <magnus@hagander.net> wrote:
On Fri, Nov 4, 2011 at 14:53, Cédric Villemain
Interesting, can the ouput be clear on the value being a default or an
explicit stat target ? (not mandatory but I believe I would like to
have it only when the stat target is jnot the default)It shows -1 when it's the default.
We could map that to the string "default" if we want, or just NULL, I
guess. Not sure which is best?I thought -1 was just fine. The ALTER TABLE doc page is clear that -1
means the system default, and having another value may just confuse
users.
yes, it looks good to me.
Josh
--
Cédric Villemain +33 (0)6 20 30 22 52
http://2ndQuadrant.fr/
PostgreSQL: Support 24x7 - Développement, Expertise et Formation
Magnus Hagander <magnus@hagander.net> writes:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.
Comments/reivews?
Isn't this going to show -1 most of the time? Seems rather useless,
not to mention confusing to people who don't know what that means.
regards, tom lane
On Fri, Nov 4, 2011 at 15:23, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Magnus Hagander <magnus@hagander.net> writes:
The attached patch adds a column for statistics target when viewing
tables in psql using \d+.Comments/reivews?
Isn't this going to show -1 most of the time? Seems rather useless,
not to mention confusing to people who don't know what that means.
It will, but in the cases where it doesn't, it'll be very useful and
good to have thrown in your face.
Would you find it better if we showed blank (NULL) when it was -1?
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
Magnus Hagander <magnus@hagander.net> writes:
Would you find it better if we showed blank (NULL) when it was -1?
Yeah, I would. Seems less confusing.
regards, tom lane
On Fri, Nov 4, 2011 at 16:13, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Magnus Hagander <magnus@hagander.net> writes:
Would you find it better if we showed blank (NULL) when it was -1?
Yeah, I would. Seems less confusing.
Adjusted per this, renamed to "Stats target", and applied.
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/