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 1oKF8M-0002dP-P5 for pgsql-general@arkaria.postgresql.org; Sat, 06 Aug 2022 08:26:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oKF8L-0000LI-FL for pgsql-general@arkaria.postgresql.org; Sat, 06 Aug 2022 08:26:09 +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 1oKF8L-0000BA-4C for pgsql-general@lists.postgresql.org; Sat, 06 Aug 2022 08:26:09 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oKF8E-0001eU-W8 for pgsql-general@lists.postgresql.org; Sat, 06 Aug 2022 08:26:08 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id E91DF772E; Sat, 6 Aug 2022 10:25:59 +0200 (CEST) Date: Sat, 6 Aug 2022 10:25:59 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL 14.4 ERROR: out of memory issues Message-ID: <20220806082559.fjitjrqf3cvrog7h@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <695843.1658154336@sss.pgh.pa.us> <787006.1658171039@sss.pgh.pa.us> <3258036.1659567952@sss.pgh.pa.us> <40a48d9d-a324-f69c-5ab6-5afb9050176e@joeconway.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mcfkvjb2k7ai2onq" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --mcfkvjb2k7ai2onq Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-08-05 17:47:02 +0200, Ale=C5=A1 Zelen=C3=BD wrote: > the construct surprised me when I saw it in the function the first time, = but it > is correct and works as expected - it allows writing the function as SQL > instead of PLPGSQL while it ensures that for a parameter null value it > evaluates to true instead of filtering the resultset. > What is the issue The problem Joe spotted is that a variable name is misspelled in one place. It should (probably) be external_complete_id, not _external_complete_id). > better solution proposal? I think you can make that clearer by using IS [NOT] DISTINCT FROM: SELECT ... simple join of two tables... WHERE opd.id_data_provider =3D _id_data_provider =C2=A0 AND external_id IS NOT DISTINCT FROM _external_id AND external_complete_id IS NOT DISTINCT FROM _external_complete_id ; However, your version may be faster, as last time I looked (it's been some time) the optimizer wasn't especially good at handlung DISTINCT FROM (probably because it's so rarely used). hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --mcfkvjb2k7ai2onq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmLuJZMACgkQ8g5IURL+ KF1AQg/9G6FovWP5PG5fArfFaCAit3BlhBiGM+TTa9BXsdELSu4v0ldkJat/ijCA faTkXmimDJ8DGKbap4Q/8n3lT9LuwhCIXsTCKcF9/AoXBuIF1HZ832e+EaSuxBAE 01bsF21f5kVXCWm5+dDg/eae+BIqFXMSIjKAw6L6a6/S6IgjYH58cAs/jNVd1/Uf crNdUsVHaDn7P2+vscS7jxnBtvoH6EPCsCw7iJaTbHm6eFmf3VG2zW2HGBRqxTRr sOTtCjKG26CKr+cy67rCIEMcY1tnI5VnMBJ8iQgnBHUo2eHso7iLH9+K9RZnWsD6 Ecx6+UCqCadfYu/NPeVNyikXqDwRGHdBWegP6qzzCK3hnVH/Kmtc9Yl/JSmCifYy NzrkqbRRcTDahJL9/Ilok1MmAXpxp70WmvYQSCIKNNtw2ZBUgda4rihmL8Cz0G/Y 0cCwjkZWBehNmHc5IX0DOGjqOhmjELItzaV5QCL9LMCl3ZtABfrf3bpN+rmFXMFE W9eEtBF95DYALOmIZx/fOOtwOHu5DWOXdAgRJ1IFbaoelYTKqB20EDKOz+vyqZ16 Ym6V0YabHRc/sUygwbrOp34vXSDPVLl5Nlmw8NtgueUrqtUT5XLZuUJuclBJEGU+ RMyn3kiHBr+h+XiJO6M+Zj/m62mHUX4RvXbWlbjvcPel/Rqc4JU= =Ohd9 -----END PGP SIGNATURE----- --mcfkvjb2k7ai2onq--