Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lEU22-0000Ve-AQ for pgsql-general@arkaria.postgresql.org; Tue, 23 Feb 2021 09:31:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lEU21-00073C-9b for pgsql-general@arkaria.postgresql.org; Tue, 23 Feb 2021 09:31:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lEU21-000734-24 for pgsql-general@lists.postgresql.org; Tue, 23 Feb 2021 09:31:01 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lEU1z-0003Cp-BY for pgsql-general@lists.postgresql.org; Tue, 23 Feb 2021 09:31:00 +0000 Received: by mail-lj1-x235.google.com with SMTP id q23so2320040lji.8 for ; Tue, 23 Feb 2021 01:30:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=tlP428+mt9gYOOnCHJjn06o10LQjTGDgXZYkCv0dB88=; b=BOndjreudRsa86EZn5VpzEplam+PwOgjbBOTIkvZQfMBJiXGc9VfjiTK8C3IyzjANq Quhg4BEIajinxlcmhc0ucp/GecmUx22cZCxDa5RppnTGBuIvartHlxzFV397GiAZKfTz 3ZleM82iTBAJERPn6Bb5vrFNSHDFAhJTwpF8ECabGw4WBRfawa5lGCt54d2fK/OTrUoU zBy7hLXiP+U0pRsyjrN/Ugky+j4cjjLy7uWKIOibUkmtUDSSYAgmIlLX9ORNYUuunxfg z5UyM8F6Jk7efC8J1y81+4un/KJ9Eyd+Xi6vapSYxjJy5F/avPUHp9+phRofV/pAXRiW GDbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=tlP428+mt9gYOOnCHJjn06o10LQjTGDgXZYkCv0dB88=; b=U/5Fz060tt9d6lZjlIAfCuvH/sCryLOvOV86tw4GUP7JR28ywlw9LMNZopNr+zECS3 VDXU5XnM+eZ94AmtY1BPUXEm5l7n47DHfbabZOND0uhzYiK+IUemPYsAKsFMESOFcU47 FD8/+SI3X2cBFEpsgaMJ6A657b2bsEsqaNCbEaZepKlLZXHytlnycM1vi4XP9IUaRdkk k7uFgirUW6v4xqsKH8a8LuTH/4ijYdjNS4GfE3IuR3vWvtcOc7xE5X9pE86ab+1CJOhy vuP222F0vu+yBOtv6mozZNYbdcJWz8dzH7j7HWqzZ4UQCZJa4e4uMKQ/rszuFmZMO1a0 lzkQ== X-Gm-Message-State: AOAM531yUgHHYKunksGjbsJeG7FDOZhOOXIIBxvmSkkoEeTRD+9y1uvC pvKkZiG4ZnDpXyEqf6lCSak= X-Google-Smtp-Source: ABdhPJyu2LdusQ6uyO/0Jycs12gu/g+Iz7RFHMiKwIcEASSHJsCrDyS4xlg1QcqKYm0pGzaCAEKqGg== X-Received: by 2002:a05:651c:327:: with SMTP id b7mr16017422ljp.100.1614072658497; Tue, 23 Feb 2021 01:30:58 -0800 (PST) Received: from [192.168.0.151] ([94.45.128.150]) by smtp.gmail.com with ESMTPSA id o66sm1512976lfa.192.2021.02.23.01.30.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Feb 2021 01:30:57 -0800 (PST) From: Oleksandr Voytsekhovskyy Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_80074FCB-293C-4799-8B47-3AC5A0125051" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: Simple IN vs IN values performace Date: Tue, 23 Feb 2021 11:30:56 +0200 In-Reply-To: Cc: Ron , PostgreSQL General To: Michael Lewis References: <7334ed05-d880-d6c5-46ed-24f6b6491a2a@gmail.com> X-Mailer: Apple Mail (2.3654.60.0.2.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_80074FCB-293C-4799-8B47-3AC5A0125051 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Greetings, Didn=E2=80=99t get your ideas with materialized CTE or a subquery with = OFFSET 0 Could you please show simple example? > 23 =D1=84=D0=B5=D0=B2=D1=80. 2021 =D0=B3., =D0=B2 04:33, Michael Lewis = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >=20 > Insert the values into a TEMPORARY TABLE, then join that to your main = table? >=20 > In my experience, this is very performant but needs an analyze command = after populating the temp table to ensure there are statistics so the = plan doesn't go awry. Otherwise, I'm not sure it is different from a = materialized CTE or a subquery with OFFSET 0 at the end. --Apple-Mail=_80074FCB-293C-4799-8B47-3AC5A0125051 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Greetings,

Didn=E2=80=99t get your ideas with  materialized = CTE or a subquery with OFFSET 0

Could you please show simple = example?

23 =D1=84=D0=B5=D0=B2=D1=80. 2021 =D0=B3., =D0=B2= 04:33, Michael Lewis <mlewis@entrata.com> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0= =D0=BB(=D0=B0):

Insert the values = into a TEMPORARY TABLE, then join that to your main table?

In my experience, this is very = performant but needs an analyze command after populating the temp table = to ensure there are statistics so the plan doesn't go awry. = Otherwise, I'm not sure it is different from a materialized CTE or a = subquery with OFFSET 0 at the end.

= --Apple-Mail=_80074FCB-293C-4799-8B47-3AC5A0125051--