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 1m60WO-0002RW-LP for pgsql-general@arkaria.postgresql.org; Wed, 21 Jul 2021 00:55:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m60WN-0002b7-IT for pgsql-general@arkaria.postgresql.org; Wed, 21 Jul 2021 00:55:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m60WN-0002ay-7j for pgsql-general@lists.postgresql.org; Wed, 21 Jul 2021 00:55:35 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m60WI-0001XF-OR for pgsql-general@lists.postgresql.org; Wed, 21 Jul 2021 00:55:34 +0000 Received: by mail-pj1-x1036.google.com with SMTP id x13-20020a17090a46cdb0290175cf22899cso47462pjg.2 for ; Tue, 20 Jul 2021 17:55:30 -0700 (PDT) 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=T1Y/KUA54y+Yr1uRG8XK6bBuV3zVqPgMipiIk53CFk0=; b=L5zKzIXCV2XNaMqm4t9IO3DA2DoESkqob2AmWFvkDTnXvnHOnhlFv77839kAzYBIYv I2rlo39GQucr+dpdPXf106msiAixFl6C4HfXoXQBceoyRFU+Ajo4zuZaF0wqTz+sFCfC sK7E4DTL0qnj9e/ruW1BHkApSXpsxRyFVKJW3XHZYALE/VLjrv9PnNJKVPbbRnyFXvYI kLjN9AunLo9dGXJjPkG+dxirQd0gcPmcv6n0dKbo5zmns8WmLM7qWzc6YyjybXdD71Xg iZRYXYfc/B+Cxb7FPV3QMMpgSYrz4b3i8keB1IVcSlgBZI4t4CGxPAvG87aUuBKouas1 iaww== 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=T1Y/KUA54y+Yr1uRG8XK6bBuV3zVqPgMipiIk53CFk0=; b=D8IZapbCXnwJYNwNMlquq/pzRMe8M1bZ3lXSVmAYDWt9eMKQJ5UgqpGuyb3zAexW+O UMs4qACOOf3KIgowdWCBJXRZmslY9C/59UvxFKlc5q1rbYxqqJdEhDuqw2us9QfUihhO FNJqcUbV0V3u0LG1KXY8jZ9Q/CXOvyH8FSZTSF2SmO47eajpsnMB+AV6MaPVQdNwSKmv pgVh1vHoGvw4RazBAxDmhPbQVtBtAGwVkjHC5Moqw0ue+9dt1xHw3FHuzP/lltjGK7Hp s9D2kjJ5BhMeX/jI6zwE4qAZ+oZbOC2ttJcenDZoOlMoH9wdbhDRc9bSKrfYOa45PIYO qAnA== X-Gm-Message-State: AOAM530/DvPqPWK0TC/Ev2Xi8ZHE8D0dEHcHGu5Hq6ZNVuRIiQhZ/JSv 0XQXG0T20rCAnnjCiqSNI6JlP6Rrahc= X-Google-Smtp-Source: ABdhPJwVCMFs+43QyJHpZn65r0lO+DEe6iHHwBPdZmEzmGq7f0vwJ1uQrf47UPC/Z6H4rFV2CXho9w== X-Received: by 2002:a17:90a:ea12:: with SMTP id w18mr33037600pjy.103.1626828929709; Tue, 20 Jul 2021 17:55:29 -0700 (PDT) Received: from smtpclient.apple ([155.98.131.1]) by smtp.gmail.com with ESMTPSA id w18sm22816143pjg.50.2021.07.20.17.55.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jul 2021 17:55:29 -0700 (PDT) From: Rob Sargent Message-Id: <44CF8418-C67F-405C-BD36-763F4F2412E4@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_EFBC4798-65CD-428D-A99D-DF1D6B389E8C" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: More records after sort Date: Tue, 20 Jul 2021 18:55:27 -0600 In-Reply-To: Cc: "pgsql-general@lists.postgresql.org" To: Nicolas Seinlet References: <368621.1626791677@sss.pgh.pa.us> X-Mailer: Apple Mail (2.3654.100.0.2.22) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_EFBC4798-65CD-428D-A99D-DF1D6B389E8C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > Query: > INSERT INTO invl_aml_mapping_temp(invl_id, aml_id, cond) > SELECT il.id, ml.id, 48 > FROM account_invoice_line il > JOIN account_invoice i ON i.id =3D il.invoice_id > JOIN account_move m ON m.id =3D i.move_id > JOIN account_move_line ml ON ml.move_id =3D m.id > JOIN res_company comp ON comp.id =3D i.company_id > WHERE il.display_type IS NULL > AND ml.tax_line_id IS NULL > AND NOT EXISTS (SELECT invl_id FROM invl_aml_mapping = WHERE invl_id=3Dil.id) > AND NOT EXISTS (SELECT aml_id FROM invl_aml_mapping = WHERE aml_id=3Dml.id) > AND i.id =3D=20 Out of curiosity, would combining those two NOT EXISTS in one help? = Ever?=20 i.e. WHERE invl_id=3Dil.id or aml_id =3D ml.id --Apple-Mail=_EFBC4798-65CD-428D-A99D-DF1D6B389E8C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Query:
INSERT INTO = invl_aml_mapping_temp(invl_id, aml_id, cond)
=             &n= bsp;  SELECT il.id, ml.id, 48
=             &n= bsp;      FROM account_invoice_line il
=             &n= bsp;      JOIN account_invoice i ON i.id =3D il.invoice_id
=             &n= bsp;      JOIN account_move m ON m.id =3D i.move_id
=             &n= bsp;      JOIN account_move_line ml ON = ml.move_id =3D m.id
=             &n= bsp;      JOIN res_company comp ON comp.id =3D i.company_id
=             &n= bsp;  WHERE il.display_type IS NULL
=             &n= bsp;    AND ml.tax_line_id IS NULL
=             &n= bsp;    AND NOT EXISTS (SELECT invl_id FROM = invl_aml_mapping WHERE invl_id=3Dil.id)
=             &n= bsp;    AND NOT EXISTS (SELECT aml_id FROM = invl_aml_mapping WHERE aml_id=3Dml.id)
=             &n= bsp;    AND i.id =3D 

Out of curiosity, would combining those two NOT = EXISTS in one help? Ever? 
i.e. WHERE invl_id=3Dil.id or aml_id =3D ml.id


= --Apple-Mail=_EFBC4798-65CD-428D-A99D-DF1D6B389E8C--