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 1shGff-00FVSV-4Y for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Aug 2024 22:52:47 +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 1shGfc-006MfL-BN for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Aug 2024 22:52:44 +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 1shGfc-006MfD-2R for pgsql-bugs@lists.postgresql.org; Thu, 22 Aug 2024 22:52:44 +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 1shGfZ-0011MA-6e for pgsql-bugs@lists.postgresql.org; Thu, 22 Aug 2024 22:52:44 +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 47MMqeof2088499; Thu, 22 Aug 2024 18:52:40 -0400 From: Tom Lane To: David Rowley cc: Maxim Boguk , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18588: Cannot force/let database use parallel execution in simple case. In-reply-to: References: <18588-204730f9394441a8@postgresql.org> <2059550.1724353316@sss.pgh.pa.us> <2073208.1724359323@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Fri, 23 Aug 2024 10:44:27 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2088497.1724367160.1@sss.pgh.pa.us> Date: Thu, 22 Aug 2024 18:52:40 -0400 Message-ID: <2088498.1724367160@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I played around with the attached script and set some breakpoints in > cost_index(). I'm seeing the same thing as you with the parallel path > being only slightly cheaper, but when looking at cost_index(), it's > easy to see why. > It's only the cpu_run_cost that's divided by the parallel_divisor. D'oh. What Maxim is observing is that he's getting I/O concurrency from multiple workers; and that's an effect we're simply not accounting for here. cost_seqscan excuses the same omission with * It may be possible to amortize some of the I/O cost, but probably * not very much, because most operating systems already do aggressive * prefetching. For now, we assume that the disk run cost can't be * amortized at all. but I don't think this prefetch argument applies to index scans. regards, tom lane