Re: Resetting spilled txn statistics in pg_stat_replication

From: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: "Shinoda, Noriyoshi (PN Japan A&PS Delivery)" <noriyoshi(dot)shinoda(at)hpe(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Ajin Cherian <itsajin(at)gmail(dot)com>
Subject: Re: Resetting spilled txn statistics in pg_stat_replication
Date: 2020-10-19 03:34:01
Message-ID: CA+fd4k7c+WWXihjN62wYAsEod8HBx+MAvxcGyemdb8GXa3T41Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 15 Oct 2020 at 17:51, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Tue, Oct 13, 2020 at 5:41 AM Masahiko Sawada
> <masahiko(dot)sawada(at)2ndquadrant(dot)com> wrote:
> >
> > On Mon, 12 Oct 2020 at 23:45, Shinoda, Noriyoshi (PN Japan A&PS
> > Delivery) <noriyoshi(dot)shinoda(at)hpe(dot)com> wrote:
> > >
> > >
> > > > As it may have been discussed, I think the 'name' column in pg_stat_replication_slots is more consistent with the column name and data type matched to the pg_replication_slots catalog.
> > > > The attached patch changes the name and data type of the 'name' column to slot_name and 'name' type, respectively.
> > >
> > > It seems a good idea to me. In other system views, we use the name data type for object name. When I wrote the first patch, I borrowed the code for pg_stat_slru which uses text data for the name but I think it's an oversight.
> >
> > Hmm, my above observation is wrong. All other statistics use text data
> > type and internally use char[NAMEDATALEN].
> >
>
> AFAICS, we use name data-type in many other similar stats views like
> pg_stat_subscription, pg_statio_all_sequences, pg_stat_user_functions,
> pg_stat_all_tables. So, shouldn't we consistent with those views?
>

Yes, they has the name data type column but it actually comes from
system catalogs. For instance, here is the view definition of
pg_stat_subscription:

SELECT su.oid AS subid,
su.subname,
st.pid,
st.relid,
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
st.latest_end_lsn,
st.latest_end_time
FROM pg_subscription su
LEFT JOIN pg_stat_get_subscription(NULL::oid) st(subid, relid,
pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest
_end_lsn, latest_end_time) ON st.subid = su.oid;

This view uses the subscription name from pg_subscription system
catalog. AFAICS no string data managed by the stats collector use name
data type. It uses char[NAMEDATALEN] instead. And since I found the
description about name data type in the doc, I thought it's better to
have it as text. Probably since pg_stat_replication_slots
(pg_stat_get_replication_slots()) is the our first view that doesn’t
use system catalog to get the object name I'm okay with changing to
name data type but if we do that it's better to update the description
in the doc as well.

Regards,

--
Masahiko Sawada http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tang, Haiying 2020-10-19 03:57:00 RE: Use of "long" in incremental sort code
Previous Message Tatsuo Ishii 2020-10-19 03:24:32 Re: Implementing Incremental View Maintenance