Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drEcU-000501-3Q for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Sep 2017 02:38:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1drEcS-0002xR-Vc for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Sep 2017 02:38:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1drEat-0007NY-5u for pgsql-hackers@postgresql.org; Mon, 11 Sep 2017 02:37:03 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drEao-0007Ty-C5 for pgsql-hackers@postgresql.org; Mon, 11 Sep 2017 02:37:00 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id v8B2asDH008936; Mon, 11 Sep 2017 11:36:54 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 787E85F65A; Mon, 11 Sep 2017 11:36:54 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 6C7AA5F623; Mon, 11 Sep 2017 11:36:54 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.68]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 67B00400A99; Mon, 11 Sep 2017 11:36:54 +0900 (JST) Message-ID: <59B5F6C0.1090008@lab.ntt.co.jp> Date: Mon, 11 Sep 2017 11:36:48 +0900 From: Tatsuro Yamada User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 Subject: Re: CLUSTER command progress monitor References: <59A77072.3090401@lab.ntt.co.jp> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: Robert Haas Cc: "pgsql-hackers@postgresql.org" X-TM-AS-MML: disable List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2017/09/08 18:55, Robert Haas wrote: > On Wed, Aug 30, 2017 at 10:12 PM, Tatsuro Yamada > wrote: >> 1. scanning heap >> 2. sort tuples > > These two phases overlap, though. I believe progress reporting for > sorts is really hard. In the simple case where the data fits in > work_mem, none of the work of the sort gets done until all the data is > read. Once you switch to an external sort, you're writing batch > files, so a lot of the work is now being done during data loading. > But as the number of batch files grows, the final merge at the end > becomes an increasingly noticeable part of the cost, and eventually > you end up needing multiple merge passes. I think we need some smart > way to report on sorts so that we can tell how much of the work has > really been done, but I don't know how to do it. Thanks for the comment. As you know, CLUSTER command uses SEQ SCAN or INDEX SCAN as a scan method by cost estimation. In the case of SEQ SCAN, these two phases not overlap. However, in INDEX SCAN, it overlaps. Therefore I created the phase of "scan heap and write new heap" when INDEX SCAN was selected. I agree that progress reporting for sort is difficult. So it only reports the phase ("sorting tuples") in the current design of progress monitor of cluster. It doesn't report counter of sort. >> heap_tuples_total | bigint | | | > > The patch is getting the value reported as heap_tuples_total from > OldHeap->rd_rel->reltuples. I think this is pointless: the user can > see that value anyway if they wish. The point of the progress > counters is to expose things the user couldn't otherwise see. It's > also not necessarily accurate: it's only an estimate in the best case, > and may be way off if the relation has recently be extended by a large > amount. I think it's pretty important that we try hard to only report > values that are known to be accurate, because users hate (and mock) > inaccurate progress reports. Do you mean to use the number of rows by using below calculation instead OldHeap->rd_rel->reltuples? estimate rows = physical table size / average row length I understand that OldHeap->rd_rel->reltuples is sometimes useless because it is correct by auto analyze and it can't perform when under a threshold. I'll add it in next patch and also share more detailed the current design of progress monitor for cluster. Regards, Tatsuro Yamada -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers