Re: Best way to check if a table is empty

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Best way to check if a table is empty
Дата
Msg-id CAKFQuwZjeeU_XOioWD+C=MzKLaeM3VUHt=g6gno3BQ7OPJxtkQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Best way to check if a table is empty  (Christophe Pettus <xof@thebuild.com>)
Список pgsql-general
On Sunday, March 23, 2025, Christophe Pettus <xof@thebuild.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.

В списке pgsql-general по дате отправления: