public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Christophe Pettus <[email protected]>
Cc: Marcelo Fernandes <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Best way to check if a table is empty
Date: Sun, 23 Mar 2025 21:24:26 -0700
Message-ID: <CAKFQuwZjeeU_XOioWD+C=MzKLaeM3VUHt=g6gno3BQ7OPJxtkQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAM2F1VMbOEubpXk44B5KaWKX0OSVrA8-9xqidhJMNtDprhTSTg@mail.gmail.com>
	<[email protected]>

On Sunday, March 23, 2025, Christophe Pettus <[email protected]> wrote:

>
> (And to be pedantic, #1 returns TRUE / FALSE while #2 returns <int> /
> NULL, so they aren't exactly equivalent.  If you are able to handle <int> /
> NULL, you don't need the EXISTS clause.)
>

Leaving the limit in place, without exists #1 returns either an empty set
or an <int>, never NULL.

Always returning a Boolean seems like a better API choice though; but
standardizing on that final transform doesn’t change the base comparison.

David J.


view thread (6+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Best way to check if a table is empty
  In-Reply-To: <CAKFQuwZjeeU_XOioWD+C=MzKLaeM3VUHt=g6gno3BQ7OPJxtkQ@mail.gmail.com>

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

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