Re: analyze-in-stages post upgrade questions

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>, "Zechman, Derek S" <Derek(dot)S(dot)Zechman(at)snapon(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: analyze-in-stages post upgrade questions
Date: 2026-08-07 04:30:57
Message-ID: CAHGQGwHKFDTnxd9mfPXgSvuKwhZRa9H-eFVfPXzHy6f7sG7_eg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Thu, Aug 6, 2026 at 11:31 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> I had a look at this open item today and the proposal and patch looks good to
> me. Just one small comment: don't we need a check for the applicable server
> version (as per the attached v2) before issuing ANALYZE ONLY since it's not
> supported in all versions?

Yes, you're right! Thanks!

I made one small cosmetic change to the version check so that it now reads:

if (use_only && serverVersion >= 180000)

I also updated the commit message to mention that vacuumdb falls back to
plain ANALYZE on older servers, and to clarify the behavior when
partitioned tables are selected via schema filters.
Attached is an updated v3 patch. Barring any objections, I'll commit it.

While looking at this, I found one related point. This patch only uses
ANALYZE ONLY for partitioned tables. However, since v18, plain ANALYZE
on an inheritance parent also recursively analyzes its inheritance
children. Therefore, when vacuumdb automatically enumerates both an
inheritance parent and its child tables, the child tables can still be
analyzed twice: once via the parent and once as separately selected
targets.

This seems similar to the partitioned-table issue fixed here, but
it strikes me as an enhancement rather than a stabilization fix for v19.
If we decide to address it, I think it would be better targeted at v20.
Does that sound reasonable?

Regards,

--
Fujii Masao

Attachment Content-Type Size
v3-0001-vacuumdb-Use-ANALYZE-ONLY-for-partitioned-tables.patch application/octet-stream 13.2 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-07 06:31:42 Re: analyze-in-stages post upgrade questions
Previous Message Daniel Verite 2026-08-06 14:39:00 Re: ICU database?

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2026-08-07 05:00:01 Re: [bug fix] prepared transaction might be lost when max_prepared_transactions is zero on the subscriber
Previous Message Ashutosh Bapat 2026-08-07 04:12:25 Re: Wrong query result w/ propgraph single lateral col reference