Re: detecting poor query plans

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: detecting poor query plans
Date: 2003-11-26 16:59:33
Message-ID: 87wu9nm5fu.fsf@mailbox.samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> I think such a thing would have such a low signal-to-noise ratio as
> to be useless :-(. As you note, there are many places where the
> planner's estimate is routinely off by more than 3x (or any other
> threshold you might pick instead).

I wonder, perhaps we could add a "certainty" parameter to the
estimated query plan + result sizes + costs produced by the
planner. That way, when we run into a planner deficiency we can
basically mark the relevant portion of the query tree as a WAG, and
not bother with emitting hints for it.

> In some situations that doesn't really matter, as the same plan
> would have gotten picked anyway.

The hint is NOT "the chosen plan was non-optimal"; the hint is "the
query planner did not produce an accurate row count estimate for this
node in the query tree." The chosen query plan may or may not be
optimal -- we're merely pointing out that we chose the plan we did on
shakey grounds. The hint might just as well indicate a problem with
another query that happens to apply a similar predicate to the column
in question.

> The question you really want to know about is not whether the row
> count estimate is close, it's whether another plan could have done
> better.

Perhaps, but is there a reasonable way to answer the second question?

-Neil

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Gardner 2003-11-26 17:03:24 Materialized views proposal
Previous Message Hans-Jürgen Schönig 2003-11-26 16:34:28 Re: statistics about tamp tables ...