Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eH4cs-0006m4-4n for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Nov 2017 09:13:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eH4cr-0005XC-NF for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Nov 2017 09:13:53 +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 1eH4cr-0005X2-EG for pgsql-hackers@lists.postgresql.org; Tue, 21 Nov 2017 09:13:53 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eH4ck-00040R-Nj for pgsql-hackers@postgresql.org; Tue, 21 Nov 2017 09:13:52 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 5A3854777F; Tue, 21 Nov 2017 10:13:42 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id toQDhd3RcZAI; Tue, 21 Nov 2017 10:13:36 +0100 (CET) From: Antonin Houska To: Tom Lane cc: Robert Haas , Tatsuro Yamada , "pgsql-hackers@postgresql.org" Subject: Re: [HACKERS] CLUSTER command progress monitor In-reply-to: <16114.1511198753@sss.pgh.pa.us> References: <59A77072.3090401@lab.ntt.co.jp> <15653.1511197525@localhost> <16114.1511198753@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 20 Nov 2017 12:25:53 -0500." MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 21 Nov 2017 10:14:11 +0100 Message-ID: <18222.1511255651@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane wrote: > Antonin Houska writes: > > Robert Haas wrote: > >> These two phases overlap, though. I believe progress reporting for > >> sorts is really hard. >=20 > > Whatever complexity is hidden in the sort, cost_sort() should have take= n it > > into consideration when called via plan_cluster_use_sort(). Thus I thin= k that > > once we have both startup and total cost, the current progress of the s= ort > > stage can be estimated from the current number of input and output > > rows. Please remind me if my proposal appears to be too simplistic. >=20 > Well, even if you assume that the planner's cost model omits nothing > (which I wouldn't bet on), its result is only going to be as good as the > planner's estimate of the number of rows to be sorted. And, in cases > where people actually care about progress monitoring, it's likely that > the planner got that wrong, maybe horribly so. I think it's a bad idea > for progress monitoring to depend on the planner's estimates in any way > whatsoever. The general idea was that some sort of prediction of the total cost is need= ed anyway if we should tell during execution what fraction of work has already been done. And also that the cost computation that we perform during execut= ion shouldn't (ideally) differ from cost_sort(). So I thought that it's easier = to refine cost_sort() than to implement the same computation from scratch elsewhere. Besides that I see 2 circumstances that make the estimate of the number of input tuples simpler in the CLUSTER case: * There's only 1 input relation w/o any kind of clause. * CLUSTER uses SnapshotAny, so pg_class(reltuples) is closer to the actual number of input rows than it would be in general case. (Of course, pg_cla= ss would only be useful for the initial estimate.) Unlike planner, the executor could recalculate the cost estimate at some point(s) as it recognizes that the actual number of tuples per page appears= to differ from the density derived from pg_class initially. Still wrong? --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26 A-2700 Wiener Neustadt Web: http://www.postgresql-support.de, http://www.cybertec.at