Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxi0i-0006Sv-R7 for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Jan 2021 03:00:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kxi0h-00017Q-1B for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Jan 2021 03:00:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxi0g-00017H-Qe for pgsql-hackers@lists.postgresql.org; Fri, 08 Jan 2021 03:00:18 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxi0d-0005K4-7u for pgsql-hackers@lists.postgresql.org; Fri, 08 Jan 2021 03:00:17 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTP id 0B8D9626E3; Fri, 8 Jan 2021 12:00:11 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 08 Jan 2021 12:00:10 +0900 From: Masahiro Ikeda To: Laurenz Albe Cc: Magnus Hagander , Ahsan Hadi , Justin Pryzby , Soumyadeep Chakraborty , PostgreSQL Hackers Subject: Re: Add session statistics to pg_stat_database In-Reply-To: <4fed6634053fe2c0e40278a4244a9f8f46c07ad2.camel@cybertec.at> References: <68050bc3d927050061d0b106905d69b3bb39fed2.camel@cybertec.at> <70a90a9b4a7e1df47ede3b01774608246bd929ee.camel@cybertec.at> <95a4c49710cdf8be220bc8267872b171c2e3f182.camel@cybertec.at> <20201013225548.GQ9241@telsasoft.com> <9e1c7bf4a654e50973b1be7770dda31431538351.camel@cybertec.at> <2099659e5d679d070f0bb2edb573f296f3c9813f.camel@cybertec.at> <27530e647d14ef49199694ea3c376935fa7285e8.camel@cybertec.at> <6fac65dcf175175f95d5fb2aeae731b70bec0a58.camel@cybertec.at> <26160fe79298a55c191b867f723acfd1557b506d.camel@cybertec.at> <4fed6634053fe2c0e40278a4244a9f8f46c07ad2.camel@cybertec.at> Message-ID: <7fb85177ef7d13efa2ed40787fc00d12@oss.nttdata.com> X-Sender: ikedamsh@oss.nttdata.com User-Agent: Roundcube Webmail/1.1.9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. >> >> // }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