Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7DF0663407A for ; Fri, 22 May 2009 07:00:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 83863-03 for ; Fri, 22 May 2009 07:00:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay.ptn-ipout01.plus.net (relay.ptn-ipout01.plus.net [212.159.7.35]) by mail.postgresql.org (Postfix) with ESMTP id 1412B633C0E for ; Fri, 22 May 2009 06:59:58 -0300 (ADT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAEMUFkrUnw4T/2dsb2JhbADSEIQLBQ Received: from pih-relay06.plus.net ([212.159.14.19]) by relay.ptn-ipout01.plus.net with ESMTP; 22 May 2009 10:56:51 +0100 Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay06.plus.net with esmtp (Exim) id 1M7RUg-0000fr-U5; Fri, 22 May 2009 10:56:51 +0100 Received: from dell36.office.archonet.com (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 26514274058; Fri, 22 May 2009 10:56:50 +0100 (BST) Message-ID: <4A1676E1.6010102@archonet.com> Date: Fri, 22 May 2009 10:56:49 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: =?ISO-8859-1?Q?Frank_J=F6rdens?= CC: pgsql-sql@postgresql.org, Nic Ferrier , Edward George , Seb Potter , Hannu Krosing Subject: Re: Make the planner smarter about idiosyncratic (or broken) ORM behaviour References: <7d10d2df0905220233v3e54ab34lb9c3530fe3543a5c@mail.gmail.com> In-Reply-To: <7d10d2df0905220233v3e54ab34lb9c3530fe3543a5c@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Plusnet-Relay: 3a0dd8a824934979188ac0694f2abf1f X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200905/89 X-Sequence-Number: 32581 Frank J=F6rdens wrote: > Our Django experts are telling me that it is probably not practical to > fix in the ORM, as it seems to be structural (anyway not fixable for > us in the near term). Hence I am wondering if anyone has an idea as to > how to make the planner smarter about such weirdness (or brokenness); > you might argue that the 2nd join there is merely syntactic bloat > which the planner might just recognize as such? Even if you have funding to hire a developer to adapt PG's planner, it's=20 going to be an uphill struggle to get patches accepted unless there is a=20 simple, quick can-merge-two-joins test someone can come up with. Time=20 spent planning to deal with badly written queries costs every=20 well-written query too of course. Even with a patch and acceptance from core, 8.4 is in beta at the moment=20 so you'll have a long wait before 8.5 comes out with your patch. Are you sure it wouldn't be easier to hire a Python guru for a couple of=20 days and have him/her hack the ORM to make it less, um, "simplistic"?=20 There must be an "assemble references into JOINs" point in the code you=20 could rationalise this at. --=20 Richard Huxton Archonet Ltd