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 1v6nRv-009r7S-Jt for pgsql-performance@arkaria.postgresql.org; Thu, 09 Oct 2025 10:00:39 +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 1v6nRr-003ObG-Me for pgsql-performance@arkaria.postgresql.org; Thu, 09 Oct 2025 10:00:36 +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 1v6nRr-003OJU-9D for pgsql-performance@lists.postgresql.org; Thu, 09 Oct 2025 10:00:36 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6nRo-001CsU-1A for pgsql-performance@postgresql.org; Thu, 09 Oct 2025 10:00:34 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-41174604d88so365058f8f.2 for ; Thu, 09 Oct 2025 03:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760004031; x=1760608831; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=bv5lH8EP2rV2HPfpvJQzTEPbBIS4NNEAf7w6jtz/8hs=; b=S+rMpS9FzDDiJIctkaxFLl8sqY7QrO0bEU5rTFM9G1BnuXFmpmRUy18YNjVK52GaTB AlbEa1eulcGLXYwhIUebODnrLIOeJ2QifFqpJxb4Bw//CZt7PT5Y/HP5uuShZ7lN/ik1 DUUk8nWQvx3uQLnSnh6IZSzSs4n3JTHBcTSTmNRfappeN5meBc1ykBZ+r8YEX02Enkca V+xc29iOuCUl2XlYL6Az4zESOSuxERdszJJIUYFcQlgElGEIUCkPefTUt4PhnXJRcb2Q 9JrozgUm8h1735t4jdAOemj9+dCBVSEX96xiDbFTHz7WILRnO9Myf+pE6f4DPkKXoIef UxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760004031; x=1760608831; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bv5lH8EP2rV2HPfpvJQzTEPbBIS4NNEAf7w6jtz/8hs=; b=mafxf0NXwTleXvyQm0DJ43FiMEnjuHG1XrXSE/yBnDx6YmZw/PJ8UvTYLSnFRIOdTw /+57YSG5rUkLGLLkeQBcPidTLUig+JroxAY+2R/pu4dH8niTu3FVlWAZ5Uhs7+h5bgI/ 0emKk3zHfvR/I/Mzq/UiQhDrcyyEYsdAOtakHyBpdRGYCOao3oEwIvz3Syq/V/vIhY0b LjTcYeXsYQU07GRgX7vYSdo8RULLzvsHYO2S8XXgwYSc327o6EEyprYtV/a7F5pER1Dh Ni/dfLl8TZJqWbdVtjCaJxBHjQ1mL0+bh4E0dYp6JTRPwCOd3j86uTdFVlJCGTBvqsg3 QP/g== X-Forwarded-Encrypted: i=1; AJvYcCXABiL4DwGTRVT1e+q8+AKEqcWLJw/AEe4M34TiigZ9EvXDexKF8l0l14+p8+H1F+o898YmaeKwcolVt4gWa4XKZQ==@postgresql.org X-Gm-Message-State: AOJu0YyDDtUTKu3jw459ONHHcnl7ZvnbB4Wf/us0OLlkuJX47e+KeZtS IuWxn1PjyKdZM4vWutq6oGRAdaOlZqcRbMXYgNIjJv2qaPBQt9Zr94CH X-Gm-Gg: ASbGncsU9ivvOP5/HRCmtKL/EvhIZ15oUWjiCA0zrPiFE8GZTz44qcTxGbtO2y/aAgH hq+FtZ7AAXsjmgIr9wnBZzHe5h5yYvU3iv/eLhg1Haj88fs47AnfXVhBOaBGkJ9dBq9GUE93Zmf 48SBFKKnQ+DvBvxr7i2Z6DTcMLjXO981FYPcMVuEaQvRTajq2QfW7Oifkb6lf4IES3bKIPMoYcg GIXZOFcj+z6PSuo/GqGG7OYZmzugSMdA094T5wjnDYtrWgK03oXLNQ0hQQhyYB2hWXipo1QqqrZ BXN35MTcdtM+EcSAuivWK8EP2IHrfKDUDjxRfE8jCQpQ3DCYivLz5+z6AyrccRgYT6k63VZ//hy JFTeX7iMil069e/Kg2Q7he+Vo+l+Qojr7pK/fGE7lyQ4VBG77lZkMd/pdjA== X-Google-Smtp-Source: AGHT+IFwkEsC/qykVHQFkZ+T33/udZ1Xh73isKS4bC33ER3E7bC9lfhmbhJ298FCipakeDUOVWkiRw== X-Received: by 2002:a5d:5d03:0:b0:3ec:e0d0:60e5 with SMTP id ffacd0b85a97d-42667177bd4mr4536327f8f.15.1760004031309; Thu, 09 Oct 2025 03:00:31 -0700 (PDT) Received: from [192.168.15.198] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf185c7esm38970765e9.19.2025.10.09.03.00.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Oct 2025 03:00:30 -0700 (PDT) Message-ID: Date: Thu, 9 Oct 2025 12:00:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Question about nested loops.. To: Frits Jalvingh , "pgsql-performa." References: Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/10/2025 10:52, Frits Jalvingh wrote: > I do not understand why the simpler query (without the self join) > produces a plan that seems to require nested loops, I hope someone can > explain. It seems obvious. You have a join clause: 'enheid.id_h_eenheid = huurovereenkomst_s._l_eenheid' One side of this clause fits the underlying relation, but another one does not (references the external relation). According to the HashJoin rules, the hash join clause is quite strict: each side should depend on only the left or right side of the join. So, it is just impossible here. What can be done here without rewriting the query? This subject requires investigation to determine if the outer part of the hash clause can be parameterised or not. -- regards, Andrei Lepikhov pgEdge