Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id DF0D59FB2FA for ; Thu, 12 Oct 2006 12:55:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 03643-08 for ; Thu, 12 Oct 2006 15:55:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from webmail.enterprisedb.com (edb04.managed.contegix.com [63.246.7.176]) by postgresql.org (Postfix) with ESMTP id 4F5CF9FB2C0 for ; Thu, 12 Oct 2006 12:55:09 -0300 (ADT) Received: from [192.168.0.20] (unknown [62.232.55.86]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by webmail.enterprisedb.com (Postfix) with ESMTP id 97833A24ED0; Thu, 12 Oct 2006 10:55:06 -0500 (CDT) Message-ID: <452E6565.4010400@enterprisedb.com> Date: Thu, 12 Oct 2006 16:55:17 +0100 From: Heikki Linnakangas User-Agent: Thunderbird 1.5.0.7 (X11/20060915) MIME-Version: 1.0 To: Bruce Momjian CC: "Jim C. Nasby" , pgsql-performance@postgresql.org Subject: Re: Hints proposal References: <200610121519.k9CFJA416544@momjian.us> In-Reply-To: <200610121519.k9CFJA416544@momjian.us> 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.45 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SARE_MILLIONSOF X-Spam-Level: X-Archive-Number: 200610/237 X-Sequence-Number: 21366 Bruce Momjian wrote: > Because DB2 doesn't like hints, and the fact that they have gotten to a > point where they feel they do not need them, I feel we too can get to a > point where we don't need them either. The question is whether we can > get there quickly enough for our userbase. In all fairness, when I used to work with DB2 we often had to rewrite queries to persuade the planner to choose a different plan. Often it was more of an issue of plan stability; a query would suddenly become horribly slow in production because a table had grown slowly to the point that it chose a different plan than before. Then we had to modify the query again, or manually set the statistics. In extreme cases we had to split a query to multiple parts and use temporary tables and move logic to the application to get a query to perform consistently and fast enough. I really really missed hints. Because DB2 doesn't have MVCC, an accidental table scan is very serious, because with stricter isolation levels that keeps the whole table locked. That said, I really don't like the idea of hints like "use index X" embedded in a query. I do like the idea of hints that give the planner more information about the data. I don't have a concrete proposal, but here's some examples of hints I'd like to see: "table X sometimes has millions of records and sometimes it's empty" "Expression (table.foo = table2.bar * 2) has selectivity 0.99" "if foo.bar = 5 then foo.field2 IS NULL" "Column X is unique" "function foobar() always returns either 1 or 2, and it returns 2 90% of the time." "if it's Monday, then table NEW_ORDERS has a cardinality of 100000, otherwise 10." BTW: Do we make use of CHECK constraints in the planner? In DB2, that was one nice and clean way of hinting the planner about things. If I remember correctly, you could even define CHECK constraints that weren't actually checked at run-time, but were used by the planner. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com