From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Aren Cambre <aren@arencambre.com>
Cc: pgsql-bugs@postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: BUG #6535: LEFT JOIN on large table is altering data
Date: Sun, 18 Mar 2012 15:33:38 -0500
Message-ID: <4F66005202000025000463DC@gw.wicourts.gov> (raw)
In-Reply-To: <4F65FDBE02000025000463D6@gw.wicourts.gov>
References: <E1S8YgG-0002hJ-SR@wrigleys.postgresql.org>
<10102.1331920604@sss.pgh.pa.us>
<CAA1mBrpZRhjRgCqPvMoj=p2-J-S4OsNnMhKX3-GTXdhpmDs=LA@mail.gmail.com>
<4F65FDBE02000025000463D6@gw.wicourts.gov>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:
> 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.
> Never assume that the rows will be returned in any particular
> order from a query unless you specify ORDER BY.
Hmm. That doesn't explain why the numbers don't add up, though. Is
that a copy/paste from an actual query run, or was there some
hand-editing there? In particular, you might easily get that result
if that last line was really:
WHERE citation_id = ''
instead of the IS NULL test. In the ANSI standard and in PostgreSQL
there is a big difference between an empty string and NULL, although
there is at least one product I know of which breaks from standard
compliance by treating them as equivalent.
-Kevin
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, aren@arencambre.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #6535: LEFT JOIN on large table is altering data
In-Reply-To: <4F66005202000025000463DC@gw.wicourts.gov>
References: <E1S8YgG-0002hJ-SR@wrigleys.postgresql.org> <10102.1331920604@sss.pgh.pa.us> <CAA1mBrpZRhjRgCqPvMoj=p2-J-S4OsNnMhKX3-GTXdhpmDs=LA@mail.gmail.com> <4F65FDBE02000025000463D6@gw.wicourts.gov> <4F66005202000025000463DC@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox