Re: Improving N-Distinct estimation by ANALYZE
Greg Stark <gsstark@mit.edu>
From: Greg Stark <gsstark@mit.edu>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-hackers@postgresql.org
Date: 2006-01-05T15:02:11Z
Lists: pgsql-hackers
Josh Berkus <josh@agliodbs.com> writes: > > Only if your sample is random and independent. The existing mechanism tries > > fairly hard to ensure that every record has an equal chance of being selected. > > If you read the entire block and not appropriate samples then you'll introduce > > systematic sampling errors. For example, if you read an entire block you'll be > > biasing towards smaller records. > > Did you read any of the papers on block-based sampling? These sorts of issues > are specifically addressed in the algorithms. We *currently* use a block based sampling algorithm that addresses this issue by taking care to select rows within the selected blocks in an unbiased way. You were proposing reading *all* the records from the selected blocks, which throws away that feature. -- greg