pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: josh@agliodbs.com, Greg Stark <gsstark@mit.edu>
Cc: Marko Ristola <marko.ristola@kolumbus.fi>
Cc: pgsql-perform <pgsql-performance@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested?
Date: Mon, 25 Apr 2005 11:23:00 -0400
Message-ID: <19276.1114442580@sss.pgh.pa.us> (raw)
In-Reply-To: <1114419467.21529.210.camel@localhost.localdomain>
References: <200504191209.05181.josh@agliodbs.com>
	<200504221336.08325.josh@agliodbs.com>
	<8764ydapky.fsf@stark.xeocode.com>
	<200504231639.11897.josh@agliodbs.com>
	<1114419467.21529.210.camel@localhost.localdomain>

Simon Riggs <simon@2ndquadrant.com> writes:
> My suggested hack for PostgreSQL is to have an option to *not* sample,
> just to scan the whole table and find n_distinct accurately.
> ...
> What price a single scan of a table, however large, when incorrect
> statistics could force scans and sorts to occur when they aren't
> actually needed ?

It's not just the scan --- you also have to sort, or something like
that, if you want to count distinct values.  I doubt anyone is really
going to consider this a feasible answer for large tables.

			regards, tom lane



view thread (53+ messages)  latest in thread

Message-ID: <19276.1114442580@sss.pgh.pa.us>
Permalink:  ../19276.1114442580@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19276.1114442580@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, simon@2ndquadrant.com, gsstark@mit.edu, marko.ristola@kolumbus.fi, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested?
  In-Reply-To: <19276.1114442580@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