Re: wal stats questions - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: wal stats questions
Date
Msg-id aef10441-c27a-80ce-20fb-4d9d60f2be52@oss.nttdata.com
Whole thread Raw
In response to Re: wal stats questions  (Masahiro Ikeda <ikedamsh@oss.nttdata.com>)
Responses Re: wal stats questions
List pgsql-hackers

On 2021/05/11 18:46, Masahiro Ikeda wrote:
> 
> 
> On 2021/05/11 16:44, Fujii Masao wrote:
>>
>>
>> On 2021/04/28 9:10, Masahiro Ikeda wrote:
>>>
>>>
>>> On 2021/04/27 21:56, Fujii Masao wrote:
>>>>
>>>>
>>>> On 2021/04/26 10:11, Masahiro Ikeda wrote:
>>>>>
>>>>> First patch has only the changes for pg_stat_wal view.
>>>>> ("v6-0001-performance-improvements-of-reporting-wal-stats-without-introducing-a-new-variable.patch")
>>>>>
>>>>>
>>>>
>>>> +        pgWalUsage.wal_records == prevWalUsage.wal_records &&
>>>> +        walStats.wal_write == 0 && walStats.wal_sync == 0 &&
>>>>> WalStats.m_wal_write should be checked here instead of walStats.wal_write?
>>>
>>> Thanks! Yes, I'll fix it.
>>
>> Thanks!
> 
> Thanks for your comments!
> I fixed them.

Thanks for updating the patch!

      if ((pgStatTabList == NULL || pgStatTabList->tsa_used == 0) &&
          pgStatXactCommit == 0 && pgStatXactRollback == 0 &&
+        pgWalUsage.wal_records == prevWalUsage.wal_records &&
+        WalStats.m_wal_write == 0 && WalStats.m_wal_sync == 0 &&

I'm just wondering if the above WAL activity counters need to be checked.
Maybe it's not necessary because "pgStatXactCommit == 0 && pgStatXactRollback == 0"
is checked? IOW, is there really the case where WAL activity counters are updated
even when both pgStatXactCommit and pgStatXactRollback are zero?


+    if (pgWalUsage.wal_records != prevWalUsage.wal_records)
+    {
+        WalUsage    walusage;
+
+        /*
+         * Calculate how much WAL usage counters were increased by substracting
+         * the previous counters from the current ones. Fill the results in
+         * WAL stats message.
+         */
+        MemSet(&walusage, 0, sizeof(WalUsage));
+        WalUsageAccumDiff(&walusage, &pgWalUsage, &prevWalUsage);

Isn't it better to move the code "prevWalUsage = pgWalUsage" into here?
Because it's necessary only when pgWalUsage.wal_records != prevWalUsage.wal_records.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION



pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: compute_query_id and pg_stat_statements
Next
From: Pavel Stehule
Date:
Subject: Re: proposal - psql - use pager for \watch command