Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TbEPG-0006tZ-1o for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 17:48:14 +0000 Received: from mailout01.ims-firmen.de ([213.174.32.96]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TbEPE-0004F1-83 for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 17:48:13 +0000 Received: from mailin02.ims-firmen.de ([192.168.1.142]) by mailout01.ims-firmen.de with esmtp (envelope-from ) id 1TbEPB-0007ug-i9 for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 18:48:09 +0100 Received: from [87.170.223.1] (helo=a-kretschmer.de) by mailin02.ims-firmen.de with esmtpsa (TLSv1:AES256-SHA:256) (envelope-from ) id 1TbEPB-0006Zu-4b for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 18:48:09 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1TbEPA-0007mb-E9 for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 18:48:08 +0100 Date: Wed, 21 Nov 2012 18:48:08 +0100 From: Andreas Kretschmer To: pgsql-performance@postgresql.org Subject: Re: Hints (was Poor performance using CTE) Message-ID: <20121121174808.GA29567@tux> References: <20121121134232.68590@gmx.com> <50ACFBBD.30204@vmware.com> <50AD0EA0.7070009@joeconway.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201211/244 X-Sequence-Number: 48610 Craig James wrote: > On 11/21/2012 08:05 AM, Heikki Linnakangas wrote: > > Rather than telling the planner what to do or not to do, I'd much rather > > have hints that give the planner more information about the tables and > > quals involved in the query. A typical source of bad plans is when the > > planner gets its cost estimates wrong. So rather than telling the > > planner to use a nested loop join for "a INNER JOIN b ON a.id = b.id", > > the user could tell the planner that there are only 10 rows that match > > the "a.id = b.id" qual. That gives the planner the information it needs > > to choose the right plan on its own. That kind of hints would be much > > less implementation specific and much more likely to still be useful, or > > at least not outright counter-productive, in a future version with a > > smarter planner. > > > > You could also attach that kind of hints to tables and columns, which > > would be more portable and nicer than decorating all queries. > > I like this idea, but also think that if we have a syntax to allow > hints, it would be nice to have a simple way to ignore all hints (yes, I > suppose I'm suggesting yet another GUC). That way after sprinkling your > SQL with hints, you could easily periodically (e.g. after a Postgres > upgrade) test what would happen if the hints were removed. > > > Or a three-way choice: Allow, ignore, or generate an error. That would allow > developers to identify where hints are being used. > > Craig +1 I think, we HAVE a smart planner, but hints in this direction are okay, and we need a simple way to make such hints obsolete - for/in the future. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknown) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°