Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLtwL-0004PK-8q for pgsql-general@arkaria.postgresql.org; Sun, 11 Nov 2018 17:54:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gLtwJ-0008IU-9l for pgsql-general@arkaria.postgresql.org; Sun, 11 Nov 2018 17:54:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLtwI-0008Hh-U9 for pgsql-general@lists.postgresql.org; Sun, 11 Nov 2018 17:54:27 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLtwG-0001jH-Qj for pgsql-general@postgresql.org; Sun, 11 Nov 2018 17:54:25 +0000 Received: from [192.168.127.1] (port=15259 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gLtwE-000Dxg-As; Sun, 11 Nov 2018 17:54:22 +0000 Received: from [127.0.0.1] (port=49778 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gLtwD-000OeH-Jn; Sun, 11 Nov 2018 17:54:21 +0000 From: Andrew Gierth To: Rob Nikander Cc: Postgres General Subject: Re: query patterns for multipass aggregating In-Reply-To: <87d0rbwp4a.fsf@news-spur.riddles.org.uk> (Andrew Gierth's message of "Sun, 11 Nov 2018 17:41:49 +0000") Message-ID: <878t1zwlh8.fsf@news-spur.riddles.org.uk> References: <11335409-A083-4951-BC7A-3C4FD118AC04@gmail.com> <87d0rbwp4a.fsf@news-spur.riddles.org.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Sun, 11 Nov 2018 17:54:21 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Andrew" == Andrew Gierth writes: Andrew> Unfortunately, the planner isn't smart enough yet to know that Andrew> these two are equivalent, oops, I edited the second one before posting in a way that made them not be equivalent: adding a "group by x0.item_id" in both subqueries in method 2 makes them equivalent again. Without that, the result differs slightly if there are no matching color or image rows (NULL vs. empty array). -- Andrew (irc:RhodiumToad)