From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Christophe Pettus <xof(at)thebuild(dot)com> |
Cc: | Marcelo Fernandes <marcefern7(at)gmail(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Best way to check if a table is empty |
Date: | 2025-03-24 04:24:26 |
Message-ID: | CAKFQuwZjeeU_XOioWD+C=MzKLaeM3VUHt=g6gno3BQ7OPJxtkQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sunday, March 23, 2025, Christophe Pettus <xof(at)thebuild(dot)com> 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias Apitz | 2025-03-24 05:57:18 | Re: COLLATION update in 13.1 |
Previous Message | Christophe Pettus | 2025-03-24 04:16:31 | Re: Best way to check if a table is empty |