From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron Mayer <ron@intervideo.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Does "correlation" mislead the optimizer on large tables?
Date: Fri, 24 Jan 2003 01:48:19 -0500
Message-ID: <11025.1043390899@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.44.0301231909070.986-100000@localhost.localdomain>
References: <Pine.LNX.4.44.0301231909070.986-100000@localhost.localdomain>
Ron Mayer <ron@intervideo.com> writes:
> On a large tables, I think the "correlation" pg_stats field as calculated
> by "vacuum analyze" or "analyze" can mislead the optimizer.
If you look in the pghackers archives, you will find some discussion
about changing the equation that cost_index() uses to estimate the
impact of correlation on indexscan cost. The existing equation is
ad-hoc and surely wrong, but so far no one's proposed a replacement
that can be justified any better. If you've got such a replacement
then we're all ears...
> In particular, if I have a large table t with columns 'a','b','c', etc,
> and I cluster the table as follows:
> create table t_ordered as select * from t order by a,b;
> vacuum analyze t_ordered;
> Column "b" will (correctly) get a very low "correlation" in
> the pg_stats table -- but I think the optimizer would do better
> assuming a high correlation because similar 'b' values are still
> grouped closely on the same disk pages.
How would that be? They'll be separated by the stride of 'a'.
It seems likely to me that a one-dimensional correlation statistic may
be inadequate, but I haven't seen any proposals for better stats.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, ron@intervideo.com
Subject: Re: Does "correlation" mislead the optimizer on large tables?
In-Reply-To: <11025.1043390899@sss.pgh.pa.us>
References: <Pine.LNX.4.44.0301231909070.986-100000@localhost.localdomain> <11025.1043390899@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox