Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aufFv-0003R1-T5 for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Apr 2016 12:04:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aufFu-0003uj-VO for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Apr 2016 12:04:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aufFI-0002pY-Ib for pgsql-bugs@postgresql.org; Mon, 25 Apr 2016 12:04:08 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aufFE-0008WR-5I for pgsql-bugs@postgresql.org; Mon, 25 Apr 2016 12:04:07 +0000 MIME-Version: 1.0 Subject: BUG #14111: After minor upgrade (9.2.6 -> 9.2.16): ERROR: failed to build any 2-way joins To: pgsql-bugs@postgresql.org From: bgrundmann@janestreet.com Date: Mon, 25 Apr 2016 12:03:28 +0000 Message-ID: <20160425120328.2710.24609@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.1 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 14111 Logged by: Benedikt Grundmann Email address: bgrundmann@janestreet.com PostgreSQL version: 9.2.16 Operating system: Linux Description: From all I know so far we have a query that used to work last week and after upgrading from 9.2.6 to 9.2.16 this weekend, we get ERROR: failed to build any 2-way joins when trying to plan the same query (that is either run the query or even just explain it). The query is this: explain SELECT COALESCE(x11.x13, x10.x13) AS x13, SUM(ABS(COALESCE(x11.x14,0) - COALESCE(x10.x14,0))) AS x15, SUM(COALESCE(x11.x14,0) - COALESCE(x10.x14,0)) AS x16, SUM(ABS((COALESCE(x11.x14,0) - COALESCE(x10.x14,0)) * COALESCE(x2.x17,0))) AS x18, SUM((COALESCE(x11.x14,0) - COALESCE(x10.x14,0)) * COALESCE(x2.x17,0)) AS x25, COALESCE(SUM(ABS((COALESCE(x11.x14,0) - COALESCE(x10.x14,0)) * COALESCE(x2.x17,0)))/(x4.x12 * x5.divisor),0) AS gross_pct, COALESCE(SUM((COALESCE(x11.x14,0) - COALESCE(x10.x14,0)) * COALESCE(x2.x17,0))/(x4.x12 * x5.divisor),0) AS net_pct FROM ( SELECT x3.x22, x3.x13, x3.x23, x3.x14 FROM x3 WHERE x3.x22 = '4/25/2016' ) x11 FULL JOIN ( SELECT x3.x22, x3.x13, x3.x23, x3.x14 FROM x3 WHERE x3.x22 = '4/22/2016' ) x10 ON x11.x13 = x10.x13 AND x11.x23 = x10.x23 LEFT JOIN x2 ON x2.x22 = (( SELECT x20('4/25/2016', (-1)) AS x20)) AND x2.x24 = COALESCE(x11.x23,x10.x23) LEFT JOIN x4 ON ('4/25/2016' = x4.x22 AND COALESCE(x11.x13,x10.x13) = x4.x13) LEFT JOIN x5 ON ('4/25/2016' = x5.x22 AND COALESCE(x11.x13,x10.x13) = x5.x13) WHERE (COALESCE(x11.x14, 0) - COALESCE(x10.x14, 0)) <> 0 GROUP BY COALESCE(x11.x13, x10.x13), (x4.x12 * x5.divisor) ORDER BY COALESCE(SUM(ABS((COALESCE(x11.x14,0) - COALESCE(x10.x14,0)) * COALESCE(x2.x17,0)))/(x4.x12 * x5.divisor),0) DESC; -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs