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 1v79Qg-00Fiu7-Cj for pgsql-performance@arkaria.postgresql.org; Fri, 10 Oct 2025 09:28:50 +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 1v79Qe-00BL9H-5p for pgsql-performance@arkaria.postgresql.org; Fri, 10 Oct 2025 09:28:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v79Qd-00BL93-PR for pgsql-performance@lists.postgresql.org; Fri, 10 Oct 2025 09:28:48 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v79Qd-0010ve-05 for pgsql-performance@lists.postgresql.org; Fri, 10 Oct 2025 09:28:47 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-46e4f2696bdso19684865e9.0 for ; Fri, 10 Oct 2025 02:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760088525; x=1760693325; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=MfU7tTI0zbphLeCkm6MwFNxfF8cq1907pGigkwcyf8g=; b=AJaPGCSECVQ+MMWC76D9SmzU6LMKYlULJ7LFZFF8bHNd1HwiCd+u4oQ68+s02N6AJv pbJ1o/bmO7pWABx4JgyYMgSFN8Zntwt3/dVHGVne7crYGxsv1qvsNYNYahHy8RXZiq8m vFP1ti+W1l2F061d2lW2YwgrX/frRzap5shILc+Eq4xbpI8xgk4VMDmHSWrzhf6ETHnj Bsc4i49wLFR3eAN7FB1lcDMyWXihKFL1WzTai51qCzLFzBa1FjUU6MDyUfOzcTjR2yDi c3riqm6XwNexnS9kbUFg8Gim4Z0OAwmVIJNPWfmhl2Y5pqFuN/KPv2v4t3BXLNY9X/YF 2yTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760088525; x=1760693325; h=content-transfer-encoding:in-reply-to:from:cc: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=MfU7tTI0zbphLeCkm6MwFNxfF8cq1907pGigkwcyf8g=; b=mxzWBjPoD7J2jjn3VPWzV2D9VW6WoUswlhg+FfXG2IOnzywGsshpgJ0egBWAweHe8J UCclWO79+pERXd4Hhn96dwR1pXYKoP14PVX4SUnXENKRhAKu1uBed0JVkgz3t9uQSJHO jRIRJxSGCf8YJwyXWGtckQEminYuwpndtXF45rWJI4yUJ0ti16OelhQnYQE6H4qThmbm +6s7PomyqTeV/8rQx9AFVLabC0Sv1Xo8YLQtFOhPi7dU4KsddyP6ODY0GHzPTq5voqEP 7pFcXE65ucpenfKXHl4PZ+sq8cqhnz31Xmu2uy26PF1V5QarQ8LNgFkIosn8uV5LOaiz ymPQ== X-Gm-Message-State: AOJu0YxSfaLCGqmW8DSxB3GU5UVk6jAXsWGpqk1ie9N9nAeHi4NAAnZ3 n9SaLZMo0wwf4sJ2q7ret8aJ1Mvdsmo+XHQT+4Vat4nX09Lp1hdmO1sZNfRuJu+6JtA= X-Gm-Gg: ASbGnct3KFVCzYN91QsUp77GsO5BnIjkg48As+tsxzid4p4MdPoWoms6sxBPN5cz+HV dMXS6viYPiXIkzyAYgHXrzfBEoClJ4aBeN26Fs/QBovHFbjbbE/iqQfTTjGA/HStxTF6XuCPw+I hU4WUH1aNDHucNvfPfpPk2i5OYWj32GNUulLIVdSPcpzBB/4ynz3WJGnhYDNDTkxioRdmFPSNpd 8EjADDfeZvLW7qJWhKvCNSUfCQcweYZ2k5Z1PE6EaSLLSujAseReeEq0QS0YfWL5X8umJfrzSWf AFr6Oq6cwPsxS07J3soTir1iixzMdIwz03da/tjZSV2CqbbsmD/CXpbP0iAnu/79fo1Vhq8nCzk y0tfTEStVSatxPZZW8JdMIseTrKgnBRsvofX2gJMBGFRSb8MOAV7p X-Google-Smtp-Source: AGHT+IGAB0xUoog5RDI040ZsLBBG76OCcH9Fkc85wVcGzui63Ht0XkMz2tCwnv2M7d2BrCy6zEDTeQ== X-Received: by 2002:a05:600c:1990:b0:46e:1b89:77f1 with SMTP id 5b1f17b1804b1-46fa9aa1c74mr70980975e9.9.1760088525171; Fri, 10 Oct 2025 02:28:45 -0700 (PDT) Received: from [192.168.15.198] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb482b9easm38944035e9.1.2025.10.10.02.28.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Oct 2025 02:28:44 -0700 (PDT) Message-ID: Date: Fri, 10 Oct 2025 11:28:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Question about nested loops.. To: Frits Jalvingh References: Content-Language: en-US Cc: "pgsql-performance@lists.postgresql.org" 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 10/10/2025 10:51, Frits Jalvingh wrote: > Hi Andrei, > Thanks a lot for your response. I do not fully get it though because the > well-performing query also references the outer (external?) relation: > -> where eenheid.id_h_eenheid = eenheid_s.id_h_eenheid > But your response made me think a but more.This is the schema of EXPLAIN for the second 'optimal' query: Seq Scan on s_h_eenheid_ssm D SubPlan 2 -> Hash Join Hash Cond: (A.x = B.x) -> Seq Scan on A Filter: ... -> Hash -> Hash Join Hash Cond: (C.y = B.x) -> Seq Scan on s_h_huurovereenkomst_ssm C -> Hash -> Seq Scan on s_h_eenheid_ssm B There is no reference to the upper relation D - each HashJoin refers to its left and right side only. -- regards, Andrei Lepikhov, pgEdge