enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW

Lists: pgsql-hackers
From: Katsuragi Yuta <btkatsuragiyu(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-09-25 08:55:35
Message-ID: 71f6bc72f8bbaa06e701f8bd2562c347@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

pg_stat_statements tracks the number of rows processed
by some utility commands.
But, currently, it does not track the number of rows
processed by REFRESH MATERIALIZED VIEW.

Attached patch enables pg_stat_statements to track
processed rows by REFRESH MATERIALIZED VIEW.

Regards,
Katsuragi Yuta

Attachment Content-Type Size
pg_stat_statements_mt_refresh_v1.patch text/x-diff 7.4 KB

From: legrand legrand <legrand_legrand(at)hotmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-09-25 10:04:21
Message-ID: 1601028261006-0.post@n3.nabble.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: legrand legrand <legrand_legrand(at)hotmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-09-25 10:17:33
Message-ID: a4dc7e94-d7ca-21b8-71e8-b98ad6646159@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020/09/25 19:04, legrand legrand wrote:
> Hi,
>
> isn't this already fixed in pg14
> https://www.postgresql.org/message-id/E1k0mzG-0002Vn-2W@gemulon.postgresql.org
> ?

IIUC that commit handled CREATE TABLE AS, SELECT INTO, CREATE MATERIALIZED VIEW
and FETCH commands, but not REFRESH MATERIALIZED VIEW. Katsuragi-san's patch is
for REFRESH MATERIALIZED VIEW.

Regards,

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


From: legrand legrand <legrand_legrand(at)hotmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-09-25 11:57:37
Message-ID: 1601035057635-0.post@n3.nabble.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

oups, sorry
so +1 for this fix

Regards
PAscal

--
Sent from: https://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html


From: Yuki Seino <seinoyu(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: yuta katsuragi <btkatsuragiyu(at)oss(dot)nttdata(dot)com>
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-11-02 05:02:47
Message-ID: 160429336715.4948.9375456832119681180.pgcf@coridan.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passed

+1.
I checked the patch and there were no problems.
I hope this fix will be reflected.

The new status of this patch is: Ready for Committer


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Yuki Seino <seinoyu(at)oss(dot)nttdata(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-11-02 11:01:40
Message-ID: aab41011-887e-6cae-ba1f-d47b56412b88@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020/11/02 14:02, Yuki Seino wrote:
> The following review has been posted through the commitfest application:
> make installcheck-world: tested, passed
> Implements feature: tested, passed
> Spec compliant: tested, passed
> Documentation: tested, passed
>
> +1.
> I checked the patch and there were no problems.

+ PG_END_TRY();
+ SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);

Isn't it better to call SetQueryCompletion() in ExecRefreshMatView()
instead of ProcessUtilitySlow() (e.g., ExecCreateTableAs() does)?

Regards,

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


From: Seino Yuki <seinoyu(at)oss(dot)nttdata(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-11-05 14:54:53
Message-ID: a1833f6059560bc063a11ee3d94c6a40@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

2020-11-02 20:01 に Fujii Masao さんは書きました:
> On 2020/11/02 14:02, Yuki Seino wrote:
>> The following review has been posted through the commitfest
>> application:
>> make installcheck-world: tested, passed
>> Implements feature: tested, passed
>> Spec compliant: tested, passed
>> Documentation: tested, passed
>>
>> +1.
>> I checked the patch and there were no problems.
>
> + PG_END_TRY();
> + SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);
>
> Isn't it better to call SetQueryCompletion() in ExecRefreshMatView()
> instead of ProcessUtilitySlow() (e.g., ExecCreateTableAs() does)?
>
> Regards,

Sorry. I missed it.
I've incorporated your point into this patch.
So the changes to "matview.h" and "utility.c" have been canceld.

We also confirmed that the new patch passed the regression test.

Regards,

Attachment Content-Type Size
pg_stat_statements_mt_refresh_v2.patch text/x-diff 4.3 KB

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Seino Yuki <seinoyu(at)oss(dot)nttdata(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-11-10 08:29:22
Message-ID: b07129b6-b211-8d48-f328-e2e517d97e1c@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020/11/05 23:54, Seino Yuki wrote:
> 2020-11-02 20:01 に Fujii Masao さんは書きました:
>> On 2020/11/02 14:02, Yuki Seino wrote:
>>> The following review has been posted through the commitfest application:
>>> make installcheck-world:  tested, passed
>>> Implements feature:       tested, passed
>>> Spec compliant:           tested, passed
>>> Documentation:            tested, passed
>>>
>>> +1.
>>> I checked the patch and there were no problems.
>>
>> +        PG_END_TRY();
>> +        SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);
>>
>> Isn't it better to call SetQueryCompletion() in ExecRefreshMatView()
>> instead of ProcessUtilitySlow() (e.g., ExecCreateTableAs() does)?
>>
>> Regards,
>
>
> Sorry. I missed it.
> I've incorporated your point into this patch.
> So the changes to "matview.h" and "utility.c" have been canceld.
>
> We also confirmed that the new patch passed the regression test.

Thanks for updating the patch!

+ /* save the rowcount if we're given a qc to fill */
+ SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);

I added the check "if (qc)" into the above. I also added the following
comments about that we don't display the rowcount in the command
completion tag output though we save it in qc. There is the discussion
related to this topic, at [1]. Thought?

+ * Save the rowcount so that pg_stat_statements can track the total number
+ * of rows processed by REFRESH MATERIALIZED VIEW command. Note that we
+ * still don't display the rowcount in the command completion tag output,
+ * i.e., the display_rowcount flag of CMDTAG_REFRESH_MATERIALIZED_VIEW
+ * command tag is left false in cmdtaglist.h. Otherwise, the change of
+ * completion tag output might break applications using it.

Attached is the updated version of the patch.
Barring no objection, I will commit that.

Regards,

[1]
https://postgr.es/m/aadbfba9-e4bb-9531-6b3a-d13c31c8f4fe@oss.nttdata.com

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

Attachment Content-Type Size
pg_stat_statements_mt_refresh_v3.patch text/plain 4.9 KB

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Seino Yuki <seinoyu(at)oss(dot)nttdata(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: enable pg_stat_statements to track rows processed by REFRESH MATERIALIZED VIEW
Date: 2020-11-12 02:28:32
Message-ID: f2193779-62b2-a091-b553-739389630515@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020/11/10 17:29, Fujii Masao wrote:
>
>
> On 2020/11/05 23:54, Seino Yuki wrote:
>> 2020-11-02 20:01 に Fujii Masao さんは書きました:
>>> On 2020/11/02 14:02, Yuki Seino wrote:
>>>> The following review has been posted through the commitfest application:
>>>> make installcheck-world:  tested, passed
>>>> Implements feature:       tested, passed
>>>> Spec compliant:           tested, passed
>>>> Documentation:            tested, passed
>>>>
>>>> +1.
>>>> I checked the patch and there were no problems.
>>>
>>> +        PG_END_TRY();
>>> +        SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);
>>>
>>> Isn't it better to call SetQueryCompletion() in ExecRefreshMatView()
>>> instead of ProcessUtilitySlow() (e.g., ExecCreateTableAs() does)?
>>>
>>> Regards,
>>
>>
>> Sorry. I missed it.
>> I've incorporated your point into this patch.
>> So the changes to "matview.h" and "utility.c" have been canceld.
>>
>> We also confirmed that the new patch passed the regression test.
>
> Thanks for updating the patch!
>
> +    /* save the rowcount if we're given a qc to fill */
> +    SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);
>
> I added the check "if (qc)" into the above. I also added the following
> comments about that we don't display the rowcount in the command
> completion tag output though we save it in qc. There is the discussion
> related to this topic, at [1]. Thought?
>
> +     * Save the rowcount so that pg_stat_statements can track the total number
> +     * of rows processed by REFRESH MATERIALIZED VIEW command. Note that we
> +     * still don't display the rowcount in the command completion tag output,
> +     * i.e., the display_rowcount flag of CMDTAG_REFRESH_MATERIALIZED_VIEW
> +     * command tag is left false in cmdtaglist.h. Otherwise, the change of
> +     * completion tag output might break applications using it.
>
> Attached is the updated version of the patch.
> Barring no objection, I will commit that.

Pushed. Thanks!

Regards,

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