Re: progress report for ANALYZE

From: Tatsuro Yamada <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: progress report for ANALYZE
Date: 2019-12-04 08:53:42
Message-ID: 269f26cd-d90c-5ede-e29c-fd58a44a6884@nttcom.co.jp_1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Amit-san,

Thanks for your comments!

>> Attached patch is the revised patch. :)
>>
>> I wonder two things below. What do you think?
>>
>> 1)
>> For now, I'm not sure it should be set current_child_table_relid to zero
>> when the current phase is changed from "acquiring inherited sample rows" to
>> "computing stats". See <Test result> bellow.
>
> In the upthread discussion [1], Robert asked to *not* do such things,
> that is, resetting some values due to phase change. I'm not sure his
> point applies to this case too though.

Yeah, I understood.
I'll check target relid of "computing stats" to re-read a code of
analyze command later. :)


>> 2)
>> There are many "finalizing analyze" phases based on relids in the case
>> of partitioning tables. Would it better to fix the document? or it
>> would be better to reduce it to one?
>>
>> <Document>
>> ---------------------------------------------------------
>> <entry><literal>finalizing analyze</literal></entry>
>> <entry>
>> The command is updating pg_class. When this phase is completed,
>> <command>ANALYZE</command> will end.
>> ---------------------------------------------------------
>
> When a partitioned table is analyzed, its partitions are analyzed too.
> So, the ANALYZE command effectively runs N + 1 times if there are N
> partitions -- first analyze partitioned table to collect "inherited"
> statistics by collecting row samples using
> acquire_inherited_sample_rows(), then each partition to collect its
> own statistics. Note that this recursive application to ANALYZE to
> partitions (child tables) only occurs for partitioned tables, not for
> legacy inheritance.

Thanks for your explanation.
I understand Analyzing Partitioned table a little.
Below is my understanding. Is it right?

==================================================
In the case of partitioned table (N = 3)

- Partitioned table name: p (relid is 100)
- Partitioning table names: p1, p2, p3 (relids are 201, 202 and 203)

For now, We can get the following results by executing "analyze p;".

Num Phase relid current_child_table_relid
1 acquire inherited sample rows 100 201
2 acquire inherited sample rows 100 202
3 acquire inherited sample rows 100 203
4 computing stats 100 0
5 finalizing analyze 100 0

6 acquiring sample rows 201 0
7 computing stats 201 0
8 finalizing analyze 201 0

9 acquiring sample rows 202 0
10 computing stats 202 0
11 finalizing analyze 202 0

12 acquiring sample rows 203 0
13 computing stats 203 0
14 finalizing analyze 203 0
==================================================

Thanks,
Tatsuro Yamada

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2019-12-04 09:09:28 Re: Proposal: Add more compile-time asserts to expose inconsistencies.
Previous Message Michael Paquier 2019-12-04 08:20:49 Re: Update minimum SSL version