pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: Ahsan Hadi <ahsan.hadi@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Soumyadeep Chakraborty <soumyadeep2007@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Add session statistics to pg_stat_database
Date: Fri, 08 Jan 2021 12:00:10 +0900
Message-ID: <7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com> (raw)
In-Reply-To: <4fed6634053fe2c0e40278a4244a9f8f46c07ad2.camel@cybertec.at>
References: <b07e1f9953701b90c66ed368656f2aef40cac4fb.camel@cybertec.at>
	<CA+9bhC+pGpp9xezwk-maOWmOCNg-0xm5OnPSSMmb2S=n7fTwMA@mail.gmail.com>
	<68050bc3d927050061d0b106905d69b3bb39fed2.camel@cybertec.at>
	<70a90a9b4a7e1df47ede3b01774608246bd929ee.camel@cybertec.at>
	<CAE-ML+_z17fYZ_R-EeusTNk_8ewYgn5WyeKnC5ctNFjvVw9xdw@mail.gmail.com>
	<95a4c49710cdf8be220bc8267872b171c2e3f182.camel@cybertec.at>
	<CAE-ML+_MGVnMdwbCjZP6ZxDbT1980J2Az-C6bshHhGwSrijRng@mail.gmail.com>
	<f6849f80b02d2fa857687c67be4a6d5875500dd4.camel@cybertec.at>
	<20201013225548.GQ9241@telsasoft.com>
	<f9553a0de5f13b89e8e0c3823a5ff17d56fa8a82.camel@cybertec.at>
	<CA+9bhCJjE-+QPyyUWah1Be2J=oDy7_J3o3WM902YF4HHD+ep=g@mail.gmail.com>
	<9e1c7bf4a654e50973b1be7770dda31431538351.camel@cybertec.at>
	<CABUevEyg197S7dDgq8dhttg+u-cz+4REUA13BLMd1NvjvOXSTg@mail.gmail.com>
	<2099659e5d679d070f0bb2edb573f296f3c9813f.camel@cybertec.at>
	<CABUevEzx9bFWkarv7rc+CCZemG-77y0wHOn8fg3e-OePVS=D-Q@mail.gmail.com>
	<27530e647d14ef49199694ea3c376935fa7285e8.camel@cybertec.at>
	<6fac65dcf175175f95d5fb2aeae731b70bec0a58.camel@cybertec.at>
	<26160fe79298a55c191b867f723acfd1557b506d.camel@cybertec.at>
	<CABUevEzM+N5nG-32jTVXYn-P4B_ALj-e-WP2Qy6rpFCU4oS9=Q@mail.gmail.com>
	<be38f278907d32334c07b55485f3abc7d944978e.camel@cybertec.at>
	<e9e5bbb6b4b8551e9c1b3452ecd30e720cf8f4ed.camel@cybertec.at>
	<c93cbb71109c7c0465ce3541a9ec98ad@oss.nttdata.com>
	<4fed6634053fe2c0e40278a4244a9f8f46c07ad2.camel@cybertec.at>

On 2021-01-08 00:47, Laurenz Albe wrote:
> On Fri, 2020-12-25 at 20:28 +0900, Masahiro Ikeda wrote:
>> As a user, I want this feature to know whether
>> clients' session activities are as expected.
>> 
>> I have some comments about the patch.
> 
> Thanks you for the thorough review!

Thanks for updating the patch!

>> 1. pg_proc.dat
>> 
>> The unit of "session time" and so on says "in seconds".
>> But, is "in milliseconds" right?
> 
> You are right.  Fixed.
> 
>> 2. monitoring.sgml
>> 
>> IIUC, "active_time" includes the time executes a fast-path function 
>> and
>> "idle in transaction" includes "idle in transaction(aborted)" time.
>> 
>> Why don't you reference pg_stat_activity's "state" column and
>> "active_time" is the total time when the state is "active" and "fast
>> path"?
>> "idle in transaction" is as same too.
> 
> Good idea; I have expanded the documentation like that.

BTW, is there any reason to merge the above statistics?
IIUC, to separate statistics' cons is that two columns increase, and
there is no performance penalty. So, I wonder that there is a way to 
separate them
corresponding to the state column of pg_stat_activity.

>> 3. pgstat.h
>> 
>> The comment of PgStat_MsgConn says "Sent by pgstat_connection".
>> I thought "pgstat_connection" is a function, but it doesn't exist.
>> 
>> Is "Sent by the backend" right?
> 
> The function was renamed and is now called "pgstat_send_connstats".
> 
> But you are right, I might as well match the surrounding code and
> write "Sent by the backend".
> 
>> Although this is a trivial thing, the following row has too many tabs.
>> 
>> Other structs have only one space.
>> 
>> // }<tab><tab><tab>Pgstat_MsgConn;
> 
> Yes, I messed that up during the pgindent run.  Fixed.
> 
> Patch version 11 is attached.

There are some following codes in pgstatfuncs.c.
int64 result = 0.0;

But, I think the following is better.
int64 result = 0;

Although now pg_stat_get_db_session_time is initialize "result" to zero 
when it is declared,
another pg_stat_XXX function didn't initialize. Is it better to change 
it?

Regards,
-- 
Masahiro Ikeda
NTT DATA CORPORATION





view thread (34+ messages)  latest in thread

Message-ID: <7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com>
Permalink:  ../7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com/
Also on:    postgresql.org/message-id/7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: ikedamsh@oss.nttdata.com, laurenz.albe@cybertec.at, magnus@hagander.net, ahsan.hadi@gmail.com, pryzby@telsasoft.com, soumyadeep2007@gmail.com
  Subject: Re: Add session statistics to pg_stat_database
  In-Reply-To: <7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com>
  References: <b07e1f9953701b90c66ed368656f2aef40cac4fb.camel@cybertec.at> <CA+9bhCJjE-+QPyyUWah1Be2J=oDy7_J3o3WM902YF4HHD+ep=g@mail.gmail.com> <9e1c7bf4a654e50973b1be7770dda31431538351.camel@cybertec.at> <CABUevEyg197S7dDgq8dhttg+u-cz+4REUA13BLMd1NvjvOXSTg@mail.gmail.com> <2099659e5d679d070f0bb2edb573f296f3c9813f.camel@cybertec.at> <CABUevEzx9bFWkarv7rc+CCZemG-77y0wHOn8fg3e-OePVS=D-Q@mail.gmail.com> <27530e647d14ef49199694ea3c376935fa7285e8.camel@cybertec.at> <6fac65dcf175175f95d5fb2aeae731b70bec0a58.camel@cybertec.at> <26160fe79298a55c191b867f723acfd1557b506d.camel@cybertec.at> <CABUevEzM+N5nG-32jTVXYn-P4B_ALj-e-WP2Qy6rpFCU4oS9=Q@mail.gmail.com> <be38f278907d32334c07b55485f3abc7d944978e.camel@cybertec.at> <e9e5bbb6b4b8551e9c1b3452ecd30e720cf8f4ed.camel@cybertec.at> <c93cbb71109c7c0465ce3541a9ec98ad@oss.nttdata.com> <4fed6634053fe2c0e40278a4244a9f8f46c07ad2.camel@cybertec.at> <7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox