pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: PostgreSQL 14.4 ERROR: out of memory issues
Date: Sat, 6 Aug 2022 10:25:59 +0200
Message-ID: <20220806082559.fjitjrqf3cvrog7h@hjp.at> (raw)
In-Reply-To: <CAODqTUaEBP-6+t9P7h9tVQZJK84L2QQgpyz9XiXyF+FhjK-jkw@mail.gmail.com>
References: <CAODqTUZ+pxQVKwOa-H4vSP+dbpLpQv-XyGp2Kbgp1H8fQ69oCQ@mail.gmail.com>
	<695843.1658154336@sss.pgh.pa.us>
	<CAODqTUbB+Vt0o2kv5pvNH1XpmWf6NQR2nnkPNvjOVd17Ts6z_w@mail.gmail.com>
	<787006.1658171039@sss.pgh.pa.us>
	<CAODqTUZYWnVWF41ELYxFY_8tzo0165LxFu7t52gRBwi-apx51A@mail.gmail.com>
	<CAODqTUZ1KJEEnhw6_+CVBtLkjPuo40hDxy6E5O6ShP4MfhMQTQ@mail.gmail.com>
	<3258036.1659567952@sss.pgh.pa.us>
	<CAODqTUY3fdj1qE_rv-F7tPVb=e0-yprps6D+MQ2n6vj_fKCBww@mail.gmail.com>
	<40a48d9d-a324-f69c-5ab6-5afb9050176e@joeconway.com>
	<CAODqTUaEBP-6+t9P7h9tVQZJK84L2QQgpyz9XiXyF+FhjK-jkw@mail.gmail.com>

On 2022-08-05 17:47:02 +0200, Aleš Zelený 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 = _id_data_provider
        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

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (22+ messages)  latest in thread

Message-ID: <20220806082559.fjitjrqf3cvrog7h@hjp.at>
Permalink:  ../20220806082559.fjitjrqf3cvrog7h@hjp.at/
Also on:    postgresql.org/message-id/20220806082559.fjitjrqf3cvrog7h@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: PostgreSQL 14.4 ERROR: out of memory issues
  In-Reply-To: <20220806082559.fjitjrqf3cvrog7h@hjp.at>
  References: <CAODqTUZ+pxQVKwOa-H4vSP+dbpLpQv-XyGp2Kbgp1H8fQ69oCQ@mail.gmail.com> <695843.1658154336@sss.pgh.pa.us> <CAODqTUbB+Vt0o2kv5pvNH1XpmWf6NQR2nnkPNvjOVd17Ts6z_w@mail.gmail.com> <787006.1658171039@sss.pgh.pa.us> <CAODqTUZYWnVWF41ELYxFY_8tzo0165LxFu7t52gRBwi-apx51A@mail.gmail.com> <CAODqTUZ1KJEEnhw6_+CVBtLkjPuo40hDxy6E5O6ShP4MfhMQTQ@mail.gmail.com> <3258036.1659567952@sss.pgh.pa.us> <CAODqTUY3fdj1qE_rv-F7tPVb=e0-yprps6D+MQ2n6vj_fKCBww@mail.gmail.com> <40a48d9d-a324-f69c-5ab6-5afb9050176e@joeconway.com> <CAODqTUaEBP-6+t9P7h9tVQZJK84L2QQgpyz9XiXyF+FhjK-jkw@mail.gmail.com> <20220806082559.fjitjrqf3cvrog7h@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox