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 1tmcNz-00880c-4e for pgsql-general@arkaria.postgresql.org; Mon, 24 Feb 2025 17:36:55 +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 1tmcNy-005hNf-0H for pgsql-general@arkaria.postgresql.org; Mon, 24 Feb 2025 17:36:54 +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 1tmcNx-005hMy-L3 for pgsql-general@lists.postgresql.org; Mon, 24 Feb 2025 17:36:53 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tmcNu-000Zjn-1s for pgsql-general@lists.postgresql.org; Mon, 24 Feb 2025 17:36:53 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-855bb6041a6so113496039f.0 for ; Mon, 24 Feb 2025 09:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740418609; x=1741023409; darn=lists.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=ORyTzq1ZKcfDun6YVfqHMsYmbHGTsSXSScnOHzjBVJ4=; b=eIDC5zIGySe97H7/nvkWtb4GRJ9/XWyst7ETlb9ArY2+HUpG1XxuRTuWIMpR3vp8AJ BIibFXRln5LzFc1Jer+AmpFFe8KSqlM/f2VBleaUncx9vJIkYj4Hwso2EuGNNay+3lyo iB0Cof2HRicrDMvPG+hOO/OCDp3uHEJLYrsB/VIz9W8L8mfuPWL3ge19+Rj9CKqn31yx oblEYKTTPT6kVga1Rz0RcJDYjSx/wLdWz2bNuHioJJoIz3Kmt0CmxfNdspHAfjOmcfNm lu5peWgOKTGc2pwebnA5e1aCFajrlAP9jyPuUwPIb95eWChk3SDfRdy5HDeI9rfS2ACn TQsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740418609; x=1741023409; 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=ORyTzq1ZKcfDun6YVfqHMsYmbHGTsSXSScnOHzjBVJ4=; b=bhI3LZtk4tqa8/GOIJGEnjRWPZk6QTt5XgIZ5b7uX0XLPJqDjN1O7EIhOfK8t1CVYa hbqZCNCZ4F0tous/Egakmyp1CDa5ShNs11/3iH7hZQoDxTS6+QvuA15W66HzUL46DV9d mhwfwwPPYvvBk8dNIZY4wShpAvUzMJQEsAdUPFhiQFUuXviGUQhs771tygHO0JrlgmPi Ib9pb/++eFA82EYeQO+wlHyVL/2z64oNHuzYVbZaHJjNGyHdxfkRycSwB7TJzDkyk8Ed 6PLC1SSzJpEEumEorsYZLwVPCXMm+Pe5ZlRfCgLQMRm/dKNFvM80cP9yZ8CBcFCIywkG MAkQ== X-Gm-Message-State: AOJu0YyDXN6s9w98Gs9ED7nDD0TfoNAvVuX9hH7fUf92Oj1ECSZt+pW5 MaoXenjejrUnCuKbcdhlvuD4mZ8lG7JZVjz27P9IwovjMVhZzqd/TAb5cNAlNRDnl3TbphX67zK yvYcX05A+zn6eb32u0zqqazy+lZjkhRdP X-Gm-Gg: ASbGncsY/zOkfvOvyFnElcOncK631EAVktPp41yIRL7EUIQ5M5musD3wPYFV363pVos MlFh8CHlhJLssZV/LPSMbOlYBSEdbklAjhl0E3zZ2bA/LSiHmZZFDXZz2SfVQnDuXLxUVfM2uSO bju8ii6hnwcLwQVfAWJ5ANYGHSKGd36Wx0roiFxb10Zw== X-Google-Smtp-Source: AGHT+IE9Il76Hkxv041ZzPXER8PURFE62nInWfGMz+4HkGh+plQcnsF4k6JeO9LMgfn9cQLpdEiwQ7jn679ETyoLD+o= X-Received: by 2002:a05:6e02:3e06:b0:3d0:4a82:3f40 with SMTP id e9e14a558f8ab-3d2cae69466mr132915255ab.7.1740418608893; Mon, 24 Feb 2025 09:36:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Mon, 24 Feb 2025 12:36:10 -0500 X-Gm-Features: AWEUYZlJsg7jpR41nAwWM2MMTLngZY7GTZFQ3dIvti5X4JOHpIMzu4ViumB9XoQ Message-ID: Subject: Re: Keep specialized query pairs, or use single more general but more complex one To: Dominique Devienne Cc: pgsql-general@lists.postgresql.org, andrew@tao11.riddles.org.uk Content-Type: multipart/alternative; boundary="000000000000f19a91062ee6c854" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f19a91062ee6c854 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Feb 24, 2025 at 11:50=E2=80=AFAM Dominique Devienne wrote: > We lookup whether there's a list of aliases for "Allison". If there are, > we send them in $3 as an array of string (e.g. ['All', 'Alli', ...], and the first one matching (thanks to > order by ord limit 1) is returned, if any. > Thanks, I understand it now. While the unnest will create a different plan, it should fundamentally be the same. The join order will not matter. The only consideration is if the unnest list grows very, very large, which seems unlikely given your situation. And yes, it should be fine to set the first name as the leading item in the array and only run a single query for both cases. As always, it's best to test on your data and your exact queries, but from here it seems sane. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support --000000000000f19a91062ee6c854 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Feb 24, 2025 at 11:50=E2=80=AFAM = Dominique Devienne <ddevienne@gma= il.com> wrote:
of string (e.g. [= 9;All', 'Alli', ...], and the first one matching (thanks to ord= er by ord limit 1) is returned, if any.
=
Thanks, I understand it now. While the unnest will create a = different=C2=A0plan, it should fundamentally be the same. The join order wi= ll not matter. The only consideration is if the unnest list grows very, ver= y large, which seems unlikely given your situation. And yes, it should be f= ine to set the first name as the leading item in the array and only run a s= ingle query for both cases.

As always, it's be= st to test on your data and your exact queries, but from here it seems sane= .

Cheers,
Greg

--
<= div>Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Pr= oducts & Tech Support

--000000000000f19a91062ee6c854--