Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shEdK-00F0wy-CI for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Aug 2024 20:42:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1shEdH-005QK2-C5 for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Aug 2024 20:42:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shEdH-005QJs-3Q for pgsql-bugs@lists.postgresql.org; Thu, 22 Aug 2024 20:42:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shEdA-0010Rj-5b for pgsql-bugs@lists.postgresql.org; Thu, 22 Aug 2024 20:42:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 47MKg35j2073209; Thu, 22 Aug 2024 16:42:03 -0400 From: Tom Lane To: Maxim Boguk cc: David Rowley , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18588: Cannot force/let database use parallel execution in simple case. In-reply-to: <2059550.1724353316@sss.pgh.pa.us> References: <18588-204730f9394441a8@postgresql.org> <2059550.1724353316@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 22 Aug 2024 15:01:56 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2073207.1724359323.1@sss.pgh.pa.us> Date: Thu, 22 Aug 2024 16:42:03 -0400 Message-ID: <2073208.1724359323@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Hmm, you can see both behaviors on the small version of t1, just by > varying the comparison constant in the WHERE clause. For me, it'll > use only one worker with "where a<1", and not parallelize at all > with "where a<0". It looks like it's deciding that it's not worth > starting workers when too few rows are expected to be returned. That > would be unsurprising with a normal setting of parallel_setup_cost, > but it does seem odd with parallel_setup_cost=0. Ah, I traced through it, and here's what's happening: at small enough estimated rowcounts, the parallel and non-parallel plans have fuzzily the same cost (parallel is a shade cheaper, but only a shade). Their other properties such as pathkeys are the same too. So we get to the tie-breaking logic in add_path, and what breaks the tie is the difference in parallel safety: the non-parallel plan is marked parallel_safe and the parallel one (which by this point is a Gather) is not. That tie-break rule is not wrong, because preserving parallel safety can be a good thing when we come to consider use of the path at higher plan levels. So I think there's nothing to see here. regards, tom lane