Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UcekW-0007Vc-4D for pgsql-performance@arkaria.postgresql.org; Wed, 15 May 2013 16:40:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UcekV-00074z-Hs for pgsql-performance@arkaria.postgresql.org; Wed, 15 May 2013 16:40:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UcekU-00074t-Gt for pgsql-performance@postgresql.org; Wed, 15 May 2013 16:40:18 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UcekQ-0000Aw-FR for pgsql-performance@postgresql.org; Wed, 15 May 2013 16:40:17 +0000 Received: from mfilter6-d.gandi.net (mfilter6-d.gandi.net [217.70.178.135]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 0469441C07F; Wed, 15 May 2013 18:39:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter6-d.gandi.net Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter6-d.gandi.net (mfilter6-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id uf05OmIbtPG8; Wed, 15 May 2013 18:39:49 +0200 (CEST) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 8B11641C0AC; Wed, 15 May 2013 18:39:47 +0200 (CEST) Message-ID: <5193BA52.7040007@dunslane.net> Date: Wed, 15 May 2013 12:39:46 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Craig James CC: sthomas@optionshouse.com, "pgsql-performance@postgresql.org" Subject: Re: Thinking About Correlated Columns (again) References: <5193AA62.2040700@optionshouse.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 05/15/2013 12:23 PM, Craig James wrote: > On Wed, May 15, 2013 at 8:31 AM, Shaun Thomas > > wrote: > > [Inefficient plans for correlated columns] has been a pain point > for quite a while. While we've had several discussions in the > area, it always seems to just kinda trail off and eventually > vanish every time it comes up. > > ... > Since there really is no fix for this aside from completely > rewriting the query or horribly misusing CTEs (to force sequence > scans instead of bloated nested loops, for example)... > I'm worried that without an easy answer for cases like this, more > DBAs will abuse optimization fences to get what they want and > we'll end up in a scenario that's actually worse than query hints. > Theoretically, query hints can be deprecated or have GUCs to > remove their influence, but CTEs are forever, or until the next > code refactor. > > I've seen conversations on this since at least 2005. There were > even proposed patches every once in a while, but never any > consensus. Anyone care to comment? > > > It's a very hard problem. There's no way you can keep statistics > about all possible correlations since the number of possibilities is > O(N^2) with the number of columns. > I don't see why we couldn't allow the DBA to specify some small subset of the combinations of columns for which correlation stats would be needed. I suspect in most cases no more than a handful for any given table would be required. cheers andrew -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance