Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YLKnO-0000Hn-2D for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Feb 2015 00:04:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YLKnN-0006nV-Dg for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Feb 2015 00:04:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YLKnM-0006nN-Fz for pgsql-bugs@postgresql.org; Wed, 11 Feb 2015 00:04:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YLKnF-0000mF-1f for pgsql-bugs@postgresql.org; Wed, 11 Feb 2015 00:04:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t1B04Xik004214; Tue, 10 Feb 2015 19:04:33 -0500 From: Tom Lane To: Stephen Frost cc: moe1234512345@gmail.com, pgsql-bugs@postgresql.org Subject: Re: BUG #12760: Lateral files with more than 2 laterals In-reply-to: <20150210230833.GQ3854@tamriel.snowman.net> References: <20150210224138.18788.34504@wrigleys.postgresql.org> <20150210230833.GQ3854@tamriel.snowman.net> Comments: In-reply-to Stephen Frost message dated "Tue, 10 Feb 2015 18:08:34 -0500" Date: Tue, 10 Feb 2015 19:04:33 -0500 Message-ID: <4213.1423613073@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Stephen Frost writes: > Looks like an issue where GEQO and LATERAL don't get along. :/ On inspection, it seems like the error check that this is triggering is just plain wrong. What's happening is that the geqo pool initialization code (random_init_pool) is proposing the join order A, C0, B0 (1, 3, 2); which cannot work in this example because B0 (rel 2) has to be joined to A before C0 is. Now merge_clump first tries to join A and C0 (1 and 3), which is legal although it generates only a path parameterized by B0. Then there is no way to join that to B0 (rel 2) since each side of the join is wanting to be parameterized by the other. You could argue that desirable_join should figure out that the 1+3 join isn't so desirable; but that would still not prevent dead-end joins like this from being made once gimme_tree starts setting the "force" parameter. Or you could argue that gimme_tree+merge_clump should be willing to back off and try another clumping once they realize that what they're doing is a dead end. That seems pretty complicated. On the whole, it seems like the best choice is to allow overall failure, since we're certainly going to try other tours anyway. My recollection is that this code used to have a failure case, which it handled by returning DBL_MAX as the estimated cost of the tour. We got rid of that at some point, essentially assuming that this logic could always succeed at finding a legal join order --- but considering that it's fundamentally a heuristic, it doesn't seem too bright to assume that it will *always* find one. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs