Re: aggregate functions, COUNT

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: aggregate functions, COUNT
Дата
Msg-id 10539.1002045566@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: aggregate functions, COUNT  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Ответы Re: aggregate functions, COUNT  (Kevin Way <kevin.way@overtone.org>)
Список pgsql-sql
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> I think you could use EXISTS for that,
> select EXISTS (<query>); should give a true/false on whether the 
> query returned any rows.  I'm not sure if it stops after one row
> or not, but if it doesn't you can add a limit 1 to the query.

Yes it does stop after one row; and furthermore, the planner knows to
generate a fast-start plan for it.  (Or at least it's supposed to
... hmm, this seems to be broken in current sources ...)  Anyway,
there's no need for LIMIT 1 inside an EXISTS, because the planner
assumes that automatically.
        regards, tom lane


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

Предыдущее
От: Devrim GUNDUZ
Дата:
Сообщение: Re: Stupid Question
Следующее
От: Esteban Gutierrez Abarzua
Дата:
Сообщение: jdbc driver