Re: Bug in query planer ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Clifford Wolf <clifford(dot)wolf(at)linbit(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug in query planer ?
Date: 2006-02-02 14:49:33
Message-ID: 12400.1138891773@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Clifford Wolf <clifford(dot)wolf(at)linbit(dot)com> writes:
>> This would only be helpful if the most-common-values list describes
>> practically all of the column population, which isn't typically the case.

> Not more than it is the case already for the simple 'variable = const'.

No, because while you may not know what the values are that aren't in
the MCV list, you do know that none of them are equal to any of the
values in the MCV list (according to the equality operator used to
develop the list, anyway). This simple bit of logic breaks down as
soon as you are considering f(x) rather than x, because it's entirely
possible that f(x) = f(y) when x != y. Therefore, I don't think it's
valid to infer that the MCV list of the function values would equal
the function computed over the variable's MCV values.

Also, what happens when there's more than one variable used in the
expression? It'll be expensive to compute the expression over the
cartesian product of the MCV lists, and logically dubious anyway
because any such calculation would have to assume that the variable
values are statistically independent, which they likely aren't.

> .. I would do that (auto-generate hundrets of indexes from our slow-query
> log) when there would be some kind of semi-index type which just collects
> statistics on ANALYZE.

Yeah, I've toyed with some such idea too, though I don't think of it as
an index --- just some way to tell ANALYZE that you'd like it to track
statistics for thus-and-such expressions.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2006-02-02 18:36:41 Re: [BUGS] BUG #2171: Differences compiling plpgsql in
Previous Message Peter Stys 2006-02-02 14:46:17 BUG #2233: Not a bug - trying to make a donation