Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icQQH-0003Yy-5j for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 08:54:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icQQE-0000SW-Nm for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 08:54:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icQQE-0000QG-D0 for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 08:54:10 +0000 Received: from dish-sg.nttdocomo.co.jp ([202.19.227.74]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icQQ5-0005JG-TT for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 08:54:09 +0000 X-dD-Source: Outbound Received: from zssg-mailmd101.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou102.ddreams.local (Postfix) with ESMTP id 956691200F5; Wed, 4 Dec 2019 17:53:56 +0900 (JST) Received: from t113sg-mailcc12.ddreams.local (t113sg-mailcc12.ddreams.local [100.66.13.87]) by zssg-mailmd101.ddreams.local (dDREAMS) with ESMTP id <0Q1Z00X3LCPWCYC0@dDREAMS>; Wed, 04 Dec 2019 17:53:56 +0900 (JST) Received: from t113sg-mailcc11 (localhost [127.0.0.1]) by t113sg-mailcc12.ddreams.local (unknown) with SMTP id xB48ruf5049798; Wed, 4 Dec 2019 17:53:56 +0900 Received: from zssg-mailmf104.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf104.ddreams.local (Postfix) with ESMTP id C5D817E6038; Wed, 4 Dec 2019 17:53:48 +0900 (JST) Received: from zssg-mailmf104.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3C368E6050; Wed, 4 Dec 2019 17:53:48 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id C1EC28E605A; Wed, 4 Dec 2019 17:53:48 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf104.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66B508E6050; Wed, 4 Dec 2019 17:53:48 +0900 (JST) Received: from zssg-mailua104.ddreams.local (unknown [10.160.172.62]) by zssg-mailmf104.ddreams.local (Postfix) with ESMTP; Wed, 4 Dec 2019 17:53:48 +0900 (JST) Received: from [10.132.20.173] (unknown [10.160.179.1]) by zssg-mailua104.ddreams.local (dDREAMS) with ESMTPA id <0Q1Z00IZMCPIPJE0@dDREAMS>; Wed, 04 Dec 2019 17:53:42 +0900 (JST) From: Tatsuro Yamada Subject: Re: progress report for ANALYZE References: <20191128133717.GA22933@alvherre.pgsql> <5331546a-7ec4-5539-6912-8c13829de1d8@nttcom.co.jp_1> Message-id: <269f26cd-d90c-5ede-e29c-fd58a44a6884@nttcom.co.jp_1> Date: Wed, 04 Dec 2019 17:53:42 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-language: en-US Content-transfer-encoding: 7bit X-TM-AS-GCONF: 00 To: Amit Langote Cc: Alvaro Herrera , vignesh C , Pg Hackers X-CC-Mail-RelayStamp: CC/Mail Relayed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 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? >> >> >> --------------------------------------------------------- >> finalizing analyze >> >> The command is updating pg_class. When this phase is completed, >> ANALYZE 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