Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id BC0EE9FB33B for ; Thu, 12 Oct 2006 18:07:38 -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 07478-07 for ; Thu, 12 Oct 2006 18:07:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) by postgresql.org (Postfix) with ESMTP id A67D09F9F77 for ; Thu, 12 Oct 2006 18:07:14 -0300 (ADT) Received: from [10.0.0.21] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) by olive.qinip.net (Postfix) with ESMTP id A406EEB951; Thu, 12 Oct 2006 23:07:09 +0200 (MEST) Message-ID: <452EAE80.5030501@tweakers.net> Date: Thu, 12 Oct 2006 23:07:12 +0200 From: Arjen van der Meijden User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Jeff Davis CC: Csaba Nagy , "Jim C. Nasby" , postgres performance list Subject: Re: Hints proposal References: <20061012151439.GT28647@nasby.net> <1160671375.31966.84.camel@dogma.v10.wvs> <1160673340.28751.83.camel@coppola.muc.ecircle.de> <1160680031.31966.128.camel@dogma.v10.wvs> In-Reply-To: <1160680031.31966.128.camel@dogma.v10.wvs> 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.104 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/260 X-Sequence-Number: 21389 On 12-10-2006 21:07 Jeff Davis wrote: > On Thu, 2006-10-12 at 19:15 +0200, Csaba Nagy wrote: > > To formalize the proposal a litte, you could have syntax like: > > CREATE HINT [FOR USER username] MATCHES regex APPLY HINT some_hint; > > Where "some_hint" would be a hinting language perhaps like Jim's, except > not guaranteed to be compatible between versions of PostgreSQL. The > developers could change the hinting language at every release and people > can just re-write the hints without changing their application. There are some disadvantages of not writing the hints in a query. But of course there are disadvantages to do as well ;) One I can think of is that it can be very hard to define which hint should apply where. Especially in complex queries, defining at which point exaclty you'd like your hint to work is not a simple matter, unless you can just place a comment right at that position. Say you have a complex query with several joins of the same table. And in all but one of those joins postgresql actually chooses the best option, but somehow you keep getting some form of join while a nested loop would be best. How would you pinpoint just that specific clause, while the others remain "unhinted" ? Your approach seems to be a bit similar to aspect oriented programming (in java for instance). You may need a large amount of information about the queries and it is likely a "general" regexp with "general" hint will not do much good (at least I expect a hinting-system to be only useable in corner cases and very specific points in a query). By the way, wouldn't it be possible if the planner learned from a query execution, so it would know if a choice for a specific plan or estimate was actually correct or not for future reference? Or is that in the line of DB2's complexity and a very hard problem and/or would it add too much overhead? Best regards, Arjen