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.96) (envelope-from ) id 1vdhu6-003imz-03 for pgsql-performance@arkaria.postgresql.org; Thu, 08 Jan 2026 04:45:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdhu4-0005Wr-2y for pgsql-performance@arkaria.postgresql.org; Thu, 08 Jan 2026 04:45:45 +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.96) (envelope-from ) id 1vdhsu-0001P6-2m for pgsql-performance@lists.postgresql.org; Thu, 08 Jan 2026 04:44:33 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdhst-005D7E-19 for pgsql-performance@lists.postgresql.org; Thu, 08 Jan 2026 04:44:33 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-803474aaa8bso853510b3a.0 for ; Wed, 07 Jan 2026 20:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767847469; x=1768452269; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hptgZ2PLaUnYyMvti4BtGhKkt1G+qvzJ6X/U5S9Y/zs=; b=kN3YmwIOPJSBHt9p1J3cJZdiHMzGsGEQHnCYLq86W1z1R7Wq7ivgeWBIx/rKtxVnvT Au8cY2xu1l/fQKLQfKPHzF/N7L5bSbxJ4zcuxWlvcrcuAY7kJ4c5kjMLQiBRV4qBRdl3 /Un68A8d+pi566WgXGi7I4jLa5MqNW1FRUVVpXEimDfaf2up7RGKiCA7WX52TIC+JCwR OpUKTDur0DZxWVvI6YrD9S8XeLfh/M74WUpgEXS2ccjucegvqr2aMFfVsmafRThc1JEK j+cdCqrcCPCE0oeCsGrw3rmA4X+slpkxpLgGFtrjxfes7wn44wgEDIAI8jxVshQOp3nz nn8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767847469; x=1768452269; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hptgZ2PLaUnYyMvti4BtGhKkt1G+qvzJ6X/U5S9Y/zs=; b=fTifhD6wUme4i1+ZZUsmQjjoACTrf3uJCoZVIlhOL/5hC8hJ5bKcBLXeXwzDJE1osY 0eSJFqYIwfLEuaY+9M1hzXYg0JIKYhlzzWXfrC5+I712utWlkWSifBQfTm/tnFkX1Y5G 9XhGoPCbkKHmBd+rbhZNMllsunRtW1OK3DaYqqgM0dMUq0v1lgizvpmztXl2CsQgvM0h EV94gHN0PYk3JzBtWpgBhXrEyUBVK6GFV0UYHNvrXbBX04sYvtvfjp7Kah93PUIhfdQ3 YLHVt6eUdUO3BrhuVcfCIl73YNQRrftGFoEm9Kd2kAvBSuqJOlD2vpjb/aT9wxXgs1z6 obig== X-Forwarded-Encrypted: i=1; AJvYcCXOa0ri4ne/aYfPdEB2MsdHKj8OH/0xZnIMNxTctCVNRrHtZ2SPliBchnRLDF+VN4kgcnLwhFPfLKeL2gadwq54sw==@lists.postgresql.org X-Gm-Message-State: AOJu0YxUPGzgn3oZ2MuYitNxAnY/SYBtCfqpy49CNZ2E25b3CkLaZFgX jpDCbo2qVs7BNjSKfepq83srPyZlbyPMnnvp7cKrHNQma6enyOXx7mnT9cHYnA== X-Gm-Gg: AY/fxX4WmzVs+OelNasWibuup7Lpl3OItPW8MJlICdPw3Htd6xeN2kOIxOPW3vkuyTE HKAi5a3Eus66EuBnstkSFhMKU8purkmP/JVzQTPTEUu+9qns+GHTywaV6sK/b3tHLkhdLtw3UjI C6ieNBhJacV94uC3zwFTdyDJbIYmhUlqUm0yMj0pQxH32eGuWBzUpLNcyMnbxRp6QTrO3l5rQZE DsW2Ao0sgcgcVRcT6WJrWa37m1FiRdkwax9tb3kGQ/UA4pTicp0H+lD1ATCGE/r6l8zSl4cuxkJ QXPTb3OCqOGzvzAdKzK3TPCvXOWFiXQ0qdI7eC/WZWcPw9hCj0ywzPCVzmjZnEdRVv9Gme5BcLh WRYwt4tFMzoGhqBHjxmMOwafDlkk9XvF+df7Bk+HxkNVfK/Djf2PTMJY67cSWkkhs/hWfYN1Xpr leHqV00jmssLs72DcT/AW02fIXlWmTox/chm2ENreO0BGAWZeLENofSj/KWqde+16g1A== X-Google-Smtp-Source: AGHT+IFTO4s2YEIeU1YYYHoz7FEWdwpL/unMmWcYo3rmb5kJCUDV7llJbO4w2lN6Br2Y/4CJkI2wTw== X-Received: by 2002:a05:6a00:b21:b0:77d:98ee:e1c5 with SMTP id d2e1a72fcca58-819440cd4cfmr5311785b3a.15.1767847469053; Wed, 07 Jan 2026 20:44:29 -0800 (PST) Received: from ?IPV6:2404:4400:414b:1700:b092:c6d0:7613:982b? ([2404:4400:414b:1700:b092:c6d0:7613:982b]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-819bb0de919sm6218809b3a.28.2026.01.07.20.44.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jan 2026 20:44:28 -0800 (PST) Message-ID: <02d73d5c-bfd8-4d88-9c5d-2f298bcffa78@gmail.com> Date: Thu, 8 Jan 2026 17:44:25 +1300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Unexpected planner choice in simple JOIN To: Tom Lane Cc: David Rowley , pgsql-performance@lists.postgresql.org References: <71afdb09-0583-4af2-a3b3-50da4f987b9b@gmail.com> <1895375.1767846864@sss.pgh.pa.us> Content-Language: en-US From: Mark Kirkwood In-Reply-To: <1895375.1767846864@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Yeah, that seems to do the trick: test0=# SET parallel_setup_cost=24000; SET Time: 0.150 ms test0=# EXPLAIN ANALYZE SELECT t0.id0, t1.val FROM tab0 AS t0 JOIN tab1 AS t1 ON (t0.id0 = t1.id0) WHERE t0.id0 < 5;  QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------  Nested Loop  (cost=97.84..64355.16 rows=5000 width=98) (actual time=0.038..0.819 rows=3500.00 loops=1)    Buffers: shared hit=113    ->  Index Only Scan using tab0_pkey on tab0 t0 (cost=0.29..4.38 rows=5 width=4) (actual time=0.003..0.005 rows=5.00 loops=1)          Index Cond: (id0 < 5)          Heap Fetches: 0          Index Searches: 1          Buffers: shared hit=3    ->  Bitmap Heap Scan on tab1 t1  (cost=97.55..12837.19 rows=3297 width=98) (actual time=0.023..0.111 rows=700.00 loops=5)          Recheck Cond: (t0.id0 = id0)          Heap Blocks: exact=97          Buffers: shared hit=110          ->  Bitmap Index Scan on tab1_id0_hash (cost=0.00..96.73 rows=3297 width=0) (actual time=0.018..0.018 rows=700.00 loops=5)                Index Cond: (id0 = t0.id0)                Index Searches: 5                Buffers: shared hit=13  Planning:    Buffers: shared hit=9  Planning Time: 0.168 ms  Execution Time: 0.935 ms (19 rows) A point comes to mind - this is not a particularly unusual setup (i.e relatively small parent table with big child one), so maybe the defaults are not ideal here? Anyway,, thanks for your help! regards Mark On 08/01/2026 17:34, Tom Lane wrote: > Mark Kirkwood writes: >> Good suggestion. The results are...interesting: > It's clear that the planner is underestimating the costs of using a > parallel worker in your setup. Try increasing parallel_setup_cost > and/or parallel_tuple_cost to bring things more in line with reality. > > regards, tom lane