Re: Avoid calling SetMatViewPopulatedState if possible

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: cca5507 <cca5507(at)qq(dot)com>
Cc: Zizhuan Liu <44973863(at)qq(dot)com>, David Geier <geidav(dot)pg(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid calling SetMatViewPopulatedState if possible
Date: 2026-08-10 08:10:03
Message-ID: CAHGQGwEpFT=hiqC_jxWEsnoOVLz=wsfVXGLVL0Tnkpmf2=6ACA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 18, 2026 at 6:28 PM cca5507 <cca5507(at)qq(dot)com> wrote:
> > 5. A small suggestion
> > After further consideration, I suggest using the condition:
> > if (RelationIsPopulated(matviewRel) != !skipData)
> > This is much more readable and intuitive compared to the original:
> > if (RelationIsPopulated(matviewRel) == skipData)
> > Especially when paired with the original call:
> > SetMatViewPopulatedState(matviewRel, !skipData);
>
> Both are ok for me.

Thanks for the patch! I went with the following form:

if (RelationIsPopulated(matviewRel) != !skipData)
SetMatViewPopulatedState(matviewRel, !skipData);

Attached is an updated patch. I also adjusted the nearby comment and
expanded the commit message to explain the unnecessary pg_class update
and resulting dead tuple generation.

Barring any objections, I'm thinking to commit this.

Regards,

--
Fujii Masao

Attachment Content-Type Size
v3-0001-Avoid-unnecessary-matview-populated-state-updates.patch application/octet-stream 2.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-08-10 08:11:38 Re: Fix detection of truncated zstd-compressed backups
Previous Message Michael Paquier 2026-08-10 08:03:35 Re: Support for 8-byte TOAST values, round two