Re: ANALYZE ONLY

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Michael Harris <harmic(at)gmail(dot)com>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, postgres(at)jeltef(dot)nl, ilya(dot)evdokimov(at)tantorlabs(dot)com
Subject: Re: ANALYZE ONLY
Date: 2024-09-23 10:04:09
Message-ID: CAApHDvq2vikCtDEkSa6DVYUT6ZaPSXyhmG4EGefpjSFk4Zj-ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 23 Sept 2024 at 19:39, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> sql-analyze.html
> For partitioned tables, ANALYZE gathers statistics by sampling rows
> from all partitions. Each leaf partition is also recursively analyzed
> and the statistics updated. This recursive part may be disabled by
> using the ONLY keyword, otherwise, leaf partitions are analyzed only
> once, even with multi-level partitioning. No statistics are collected
> for only the parent table (without data from its partitions), because
> with partitioning it's guaranteed to be empty.
>
> allow me to ask anenglish language question.
> here "otherwise" means specify ONLY or not?
> As far as i understand.
> if you specify ONLY, postgres will only do "For partitioned tables,
> ANALYZE gathers statistics by sampling rows from all partitions"
> if you not specify ONLY, postgres will do "For partitioned tables,
> ANALYZE gathers statistics by sampling rows from all partitions *AND*
> also recursively analyze each leaf partition"
>
> Is my understanding correct?

The "Otherwise" case applies when "ONLY" isn't used.

If this is confusing, I think there's a bunch of detail that I tried
to keep that's just not that useful. The part about analyzing
partitions just once and the part about not collecting non-inheritance
stats for the partitioned table seems like extra detail that's either
obvious or just not that important.

Can you have a look at the attached and let me know if it's easier to
understand now?

David

Attachment Content-Type Size
v8-0001-Add-ONLY-support-for-VACUUM-and-ANALYZE.patch application/octet-stream 19.6 KB
v8-0002-fixup-Implementation-of-the-ONLY-feature-for-ANAL.patch application/octet-stream 20.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2024-09-23 10:26:40 Re: scalability bottlenecks with (many) partitions (and more)
Previous Message Jakub Wartak 2024-09-23 10:02:24 Re: scalability bottlenecks with (many) partitions (and more)