Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 0F2BF14D379 for ; Sun, 18 Mar 2012 17:33:54 -0300 (ADT) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S9MnZ-0008Fv-1j for pgsql-bugs@postgresql.org; Sun, 18 Mar 2012 20:33:53 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Sun, 18 Mar 2012 15:33:40 -0500 Message-Id: <4F66005202000025000463DC@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.2 Date: Sun, 18 Mar 2012 15:33:38 -0500 From: "Kevin Grittner" To: "Aren Cambre" Cc: ,"Tom Lane" Subject: Re: BUG #6535: LEFT JOIN on large table is altering data References: <10102.1331920604@sss.pgh.pa.us> <4F65FDBE02000025000463D6@gw.wicourts.gov> In-Reply-To: <4F65FDBE02000025000463D6@gw.wicourts.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201203/135 X-Sequence-Number: 32696 "Kevin Grittner" wrote: > Aren Cambre 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