Re: index vs. seq scan choice?

From: "John D(dot) Burger" <john(at)mitre(dot)org>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: index vs. seq scan choice?
Date: 2007-05-25 12:55:24
Message-ID: CB2207B5-1E40-4C9B-9ABF-49AB813BFD51@mitre.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-www

Steve Atkins wrote:

> Would it be possible to look at a much larger number of samples
> during analyze,
> then look at the variation in those to generate a reasonable number of
> pg_statistic "samples" to represent our estimate of the actual
> distribution?
> More datapoints for tables where the planner might benefit from it,
> fewer
> where it wouldn't.

You could definitely try to measure the variance of the statistics
(using, say, bootstrap resampling), and change the target 'til you
got a "good" tradeoff between small sample size and adequate
representation of the distribution. Unfortunately, I think the
definition of "good" depends strongly on the kinds of queries that
get run. Basically, you want the statistics target to be just big
enough that more stats wouldn't change the plans for common queries.
Remember, too, that this is not just one number, it'd be different
for each column (perhaps zero for most).

I could imagine hillclimbing the stats targets by storing common
queries and then replaying them, while varying the sample size.
There was a discussion last year related to all of this, see:

http://archives.postgresql.org/pgsql-general/2006-10/msg00526.php

- John D. Burger
MITRE

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Munz 2007-05-25 13:18:45 Re: Wired behavor with LIMIT
Previous Message Richard Huxton 2007-05-25 11:56:39 Re: Wired behavor with LIMIT

Browse pgsql-www by date

  From Date Subject
Next Message Dave Page 2007-05-26 20:15:01 Re: Who is remus, and why is he beating up on pgfoundry.org?
Previous Message PFC 2007-05-25 08:09:17 Re: index vs. seq scan choice?