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 1t8T7t-004OZv-IV for pgsql-general@arkaria.postgresql.org; Tue, 05 Nov 2024 23:38:20 +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 1t8T7q-001dje-Ax for pgsql-general@arkaria.postgresql.org; Tue, 05 Nov 2024 23:38:18 +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 1t8T7p-001djT-V1 for pgsql-general@lists.postgresql.org; Tue, 05 Nov 2024 23:38:18 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t8T7n-000NeK-UF for pgsql-general@postgresql.org; Tue, 05 Nov 2024 23:38:17 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-539ee1acb86so6141245e87.0 for ; Tue, 05 Nov 2024 15:38:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730849893; x=1731454693; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cHM+rqoVvFLakDD2rTboq4yvFWoKL2ogYioP2jU0gmg=; b=JjcgKzbcOVfCxo24W8PjVO6ve0my3P3LF4ETmk1hZ/c0MBsgsvuUnTeF2gu0lWMUyG 4GvGXmR/1SvJZnD9yIdwpTHg6ir4MWXkYth/Bm3zKsGVT4S1u4vDlZprkmQ1zsfIcx3l 7gUvPGHKkrlgJrba8rgsADe7GvZIBNd3FJADCCnqmZhZ6GUfMIT68e1qZYE2ACdRInyB aiUeVvOUIUwB72wVy3jnlGM5ypgg691O9XWkrlYYNmmDpKIJM41RLysy9RwqLzFOK1Qp zgBxR3W5RT40bNyTeDMEh96uVW0dpEPipO5r0Dv2ckqd1iYCs2wzQq4MkRY7QcxYUGj6 Lgmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730849893; x=1731454693; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cHM+rqoVvFLakDD2rTboq4yvFWoKL2ogYioP2jU0gmg=; b=RUG7azhUArN3BEYqWcJlWnCXHxb+Rdm2hUrqX4NOl6T6f3QbeFuOg0a7QOIH5MWi4x tXKiYdgMeD2CPfksdw54WkSJYiP6OgbxOAOcmlJuHZvJgFqkyMwrS9SPspqyZBk8BHaR xSq4zBHcqGDhY8VRFSBoAzYhrbKVrjB+FL5tIfgavKcPlaSB2RuxkbVCAnziLgBHvRWU Z0chaDk11AaWSbzwd0RRYp99eIwUZhfUQFWkFBFBmJcO5MAecFQnbCOnMaDhsC6hIjQj 4WTvl+qVDMyvskTzTSKVGXWUbaMbzcdn2ZPHfUV+Y/hJe3Cfon/iK9TYf+T5eg5NP34q IGcw== X-Forwarded-Encrypted: i=1; AJvYcCUMjHPBohnMvN1xUpyJ3l1dHWjbMWGcaJTqcL18QNKASBalGTFE9LuHsBmyUDt8JlPOsA6nDO1gduGYxjD0@postgresql.org X-Gm-Message-State: AOJu0Yxx1ZlD/dTStzlyx5+5IYnBid84XwCfwrM9xN4/EjUrY7FPHolu GVFabcjm7ELk2GSwk8ZbslNgoVRxp88/gpGWzVWAZ/SM1elbVe4Ji6uLIk0wO12Lv887aHkznrb wL3I0PBEehoDpTRbk3eqV+vz2T8w= X-Google-Smtp-Source: AGHT+IE2DbojW2HaDqOkYJky6RopgfAMA4HuZhuF0ffzzl0K3uyWMynUZ7+NmNEXE8A1SHc0YphCsRCGnrRrrF3Ojdk= X-Received: by 2002:a05:6512:3b28:b0:539:8d9b:b624 with SMTP id 2adb3069b0e04-53d65e2648fmr8221073e87.55.1730849892970; Tue, 05 Nov 2024 15:38:12 -0800 (PST) MIME-Version: 1.0 References: <2631313.1730733484@sss.pgh.pa.us> <3119567.1730848181@sss.pgh.pa.us> In-Reply-To: <3119567.1730848181@sss.pgh.pa.us> From: David Rowley Date: Wed, 6 Nov 2024 12:38:00 +1300 Message-ID: Subject: Re: Why not do distinct before SetOp To: Tom Lane Cc: ma lz , "pgsql-general@postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 6 Nov 2024 at 12:09, Tom Lane wrote: > Of course, I might be overestimating the performance benefit we'd get. > But I'm tempted to give it a try. I'm glad. I'm curious to see if you're right about the projection overhead of the flags. If you're right, it seems like a not too difficult optimisation to get in. I like the idea as it also gets rid of the flag cruft from prepunion.c, which saves having to add flags conditionally if INTERCEPT/EXCEPT were ever made to use joins. David