Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A6BDB9FB20A for ; Tue, 10 Oct 2006 00:18:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 19891-02 for ; Tue, 10 Oct 2006 00:18:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pro25.abac.com (pro25.abac.com [66.226.64.26]) by postgresql.org (Postfix) with ESMTP id 6DB5F9FA432 for ; Tue, 10 Oct 2006 00:18:39 -0300 (ADT) Received: from [192.168.0.3] (wsip-70-167-125-69.sd.sd.cox.net [70.167.125.69]) (authenticated bits=0) by pro25.abac.com (8.13.8/8.13.8) with ESMTP id k9A3IYU2019317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 Oct 2006 20:18:35 -0700 (PDT) (envelope-from cjames@modgraph-usa.com) Message-ID: <452B108C.7020703@modgraph-usa.com> Date: Mon, 09 Oct 2006 20:16:28 -0700 From: "Craig A. James" User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 To: Brian Herlihy CC: Postgresql Performance Subject: Re: Simple join optimized badly? References: <20061010011042.93217.qmail@web52308.mail.yahoo.com> In-Reply-To: <20061010011042.93217.qmail@web52308.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.074 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/177 X-Sequence-Number: 21306 Brian Herlihy wrote: > PG does support hints actually.. > The only thing is, the hints are expressed in an obscure, ad-hoc and > implementation dependant language. > > For example, the "Don't use index X" hint (the one I used) can be accessed by > replacing your index with an index on values derived from the actual index... And then there's select ... from (select ... offset 0) where the "offset 0" prevents any rewriting between the two levels of query. This replaces joins and AND clauses where the planner makes the wrong choice of join order or filtering. I grepped my code and found four of these (all workarounds for the same underlying problem). Imagine I got run over by a train, and someone was reading my code. Which would be easier for them to maintain: Code with weird SQL, or code with sensible, well-written SQL and explicit hints? Luckily for my (hypothetical, I hope) successor, I put massive comments in my code explaining the strange SQL. The bad applications are ALREADY HERE. And they're WORSE to maintain than if we had a formal hint language. The argument that hints lead to poor application is true. But lack of hints leads to worse applications. Craig