Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqOPZ-0007MQ-TT for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jun 2021 23:12:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqOPY-0002wm-Tb for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jun 2021 23:12:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqOPY-0002vd-Lu for pgsql-hackers@lists.postgresql.org; Mon, 07 Jun 2021 23:12:00 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqOPW-0002mB-O7 for pgsql-hackers@lists.postgresql.org; Mon, 07 Jun 2021 23:11:59 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id BF0A45C013B; Mon, 7 Jun 2021 19:11:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 07 Jun 2021 19:11:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=fbdBbDWw5Xf2mH0uGmnS/GlwtuYH5IMEebVYvb7c8YA=; b=tueL1C63 k6nOlG1+foBndjKUttYUvQXTOg5340W4QMAts2BkZASliqNCzoDZkYPnEL3lqT9l 1FYz4fibkz6yVhT1Xb9fdQz/tX0psTTFV8jnLcWw3dx10iBCQQ5Ftghi2qdHTDnT CC1J0pQKcLOfH089Z1iAiW82Hq9ACBMlB2bqJbdw6nV+46sIVNJNM1B/KQDzvROo QqDWfSm0dYNDqVIjUolMy2ln11Z4pXzEf4cRoiDzZjRyIcssYgSMpI276m6jZfib h29+cI62m1dO+KQY22WCvcmEBEjZSnt0sGVKdJSoc46R5lL2OmsPtLIIjnJonTFT muOeOKy8mhdwvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtkedguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttddunecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeekkeelvefgieduleffieegkedvledtledvveeiteeltdet hfefffelffekjeefleenucffohhmrghinhepphhoshhtghhrrdgvshenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Jun 2021 19:11:56 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id B4EC72A097C; Mon, 7 Jun 2021 19:11:53 -0400 (-04) Date: Mon, 7 Jun 2021 19:11:53 -0400 From: Alvaro Herrera To: Peter Geoghegan , Robert Haas Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Support parallel btree index builds. Message-ID: <202106072311.6zryr7i2xuhx@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2018-Feb-02, Robert Haas wrote: > Support parallel btree index builds. While looking at a complaint related to progress report of parallel index builds[1], I noticed this comment + /* + * Execute this worker's part of the sort. + * + * Unlike leader and serial cases, we cannot avoid calling + * tuplesort_performsort() for spool2 if it ends up containing no dead + * tuples (this is disallowed for workers by tuplesort). + */ + tuplesort_performsort(btspool->sortstate); + if (btspool2) + tuplesort_performsort(btspool2->sortstate); I've been trying to understand why this says "Unlike leader and serial cases, ...". I understand the "serial" part -- it refers to _bt_leafbuild. So I'm to understand that that one works differently; see below. But why does it say "the leader case"? As far as I can see, the leader executes exactly the same code, so what is the comment talking about? Now, if you do look at _bt_leafbuild(), it can be seen that nothing is done differently there either; we're not actually skipping any calls to tuplesort_performsort(). Any differentiation between serial/leader/ worker cases seems to be done inside that routine. So the comment is not very useful there either. I am wondering if these comments are leftovers from early development versions of this patch. Maybe we could remove them -- or rewrite them to indicate not that we avoid calling tuplesort_performsort(), but instead to say that that function behaves differently. [1] https://postgr.es/m/CAEze2Wgm-NnZe3rOnwjYTVriS8xsVhzzVBCGj34h06cDNuaTig@mail.gmail.com -- Álvaro Herrera 39°49'30"S 73°17'W "Puedes vivir sólo una vez, pero si lo haces bien, una vez es suficiente"