Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UciE1-0004B7-6n for pgsql-performance@arkaria.postgresql.org; Wed, 15 May 2013 20:23:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UciE0-0004L2-CX for pgsql-performance@arkaria.postgresql.org; Wed, 15 May 2013 20:23:00 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UciDm-00049b-K7 for pgsql-performance@postgresql.org; Wed, 15 May 2013 20:22:46 +0000 Received: from mbx.knossos.net.nz ([202.160.48.10]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UciDe-0002o6-GO for pgsql-performance@postgresql.org; Wed, 15 May 2013 20:22:45 +0000 Received: from [10.1.1.3] (60-234-150-59.bitstream.orcon.net.nz [60.234.150.59]) (authenticated bits=0) by mbx.knossos.net.nz (8.14.4/8.14.4) with ESMTP id r4FKMXcv010212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 16 May 2013 08:22:34 +1200 Message-ID: <5193EE89.1090406@archidevsys.co.nz> Date: Thu, 16 May 2013 08:22:33 +1200 From: Gavin Flower Organization: ArchiDevSys User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Heikki Linnakangas CC: sthomas@optionshouse.com, "pgsql-performance@postgresql.org" Subject: Re: Thinking About Correlated Columns (again) References: <5193AA62.2040700@optionshouse.com> <5193AF36.3040409@vmware.com> In-Reply-To: <5193AF36.3040409@vmware.com> Content-Type: multipart/alternative; boundary="------------010006000501070207020702" X-Pg-Spam-Score: 0.8 (/) 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 This is a multi-part message in MIME format. --------------010006000501070207020702 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 16/05/13 03:52, Heikki Linnakangas wrote: > On 15.05.2013 18:31, Shaun Thomas wrote: >> 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? > > Well, as you said, there has never been any consensus. > > There are basically two pieces to the puzzle: > > 1. What metric do you use to represent correlation between columns? > > 2. How do use collect that statistic? > > Based on the prior discussions, collecting the stats seems to be > tricky. It's not clear for which combinations of columns it should be > collected (all possible combinations? That explodes quickly...), or > how it can be collected without scanning the whole table. > > I think it would be pretty straightforward to use such a statistic, > once we have it. So perhaps we should get started by allowing the DBA > to set a correlation metric manually, and use that in the planner. > > - Heikki > > How about pg comparing actual numbers of rows delivered with the predicted number - and if a specified threshold is reached, then maintaining statistics? There is obviously more to it, such as: is this a relevant query to consider & the size of the tables (no point in attempting to optimise tables with only 10 rows for example). Cheers, Gavin --------------010006000501070207020702 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 16/05/13 03:52, Heikki Linnakangas wrote:
On 15.05.2013 18:31, Shaun Thomas wrote:
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?

Well, as you said, there has never been any consensus.

There are basically two pieces to the puzzle:

1. What metric do you use to represent correlation between columns?

2. How do use collect that statistic?

Based on the prior discussions, collecting the stats seems to be tricky. It's not clear for which combinations of columns it should be collected (all possible combinations? That explodes quickly...), or how it can be collected without scanning the whole table.

I think it would be pretty straightforward to use such a statistic, once we have it. So perhaps we should get started by allowing the DBA to set a correlation metric manually, and use that in the planner.

- Heikki


How about pg comparing actual numbers of rows delivered with the predicted number - and if a specified threshold is reached, then maintaining statistics? There is obviously more to it, such as: is this a relevant query to consider & the size of the tables (no point in attempting to optimise tables with only 10 rows for example).


Cheers,
Gavin
--------------010006000501070207020702--