Re: BUG #6535: LEFT JOIN on large table is altering data

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: BUG #6535: LEFT JOIN on large table is altering data
Дата
Msg-id 4F65FDBE02000025000463D6@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: BUG #6535: LEFT JOIN on large table is altering data  (Aren Cambre <aren@arencambre.com>)
Ответы Re: BUG #6535: LEFT JOIN on large table is altering data  (Aren Cambre <aren@arencambre.com>)
Re: BUG #6535: LEFT JOIN on large table is altering data  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Список pgsql-bugs
Aren Cambre <aren@arencambre.com> wrote:

> SELECT COUNT(*)
> FROM consistent.master
> WHERE citation_id IS NOT NULL
> UNION
> SELECT COUNT(*)
> FROM consistent.master
> UNION
> SELECT COUNT(*)
> FROM consistent.master
> WHERE citation_id IS NULL
>
> I got this result:
>
> 2085344
> 2085343
> 0
>
> Not clear how adding a WHERE clause, whose only practical effect
> is to reduce the number of rows returned, could cause *more* rows
> to be returned. That seems buggy to me.

Never assume that the rows will be returned in any particular order
from a query unless you specify ORDER BY.  Assuming, as you seem to
be doing, that rows from the left side of a UNION will be output
before rows from the right side is not safe.  You have no way of
knowing which row in a result set like that came from which of the
UNIONed SELECTs.  In this case your assumption is almost certainly
wrong.

-Kevin

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

Предыдущее
От: Aren Cambre
Дата:
Сообщение: Re: BUG #6535: LEFT JOIN on large table is altering data
Следующее
От: Aren Cambre
Дата:
Сообщение: Re: BUG #6535: LEFT JOIN on large table is altering data