pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: statistic target and sample rate
Date: Wed, 14 Jul 2021 10:30:29 -0400
Message-ID: <3484552.1626273029@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKoxK+7TD9848q2wxuwdOw7b5WW+QDza2omScJw5EPJjkVzh+w@mail.gmail.com>
References: <CAKoxK+7TD9848q2wxuwdOw7b5WW+QDza2omScJw5EPJjkVzh+w@mail.gmail.com>

Luca Ferrari <fluca1978@gmail.com> writes:
> Therefore my question is about how the statistic collectore decides
> about the number of tuples to be sampled.

It's basically 300 times the largest statistics target:

https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/commands/analyze.c;h=0c9591...

Per that comment, there is good math backing this choice for the task
of making a histogram.  It's a little shakier for other sorts of
statistics --- notably, for n_distinct estimation, the error can still
be really bad.

			regards, tom lane





view thread (2+ messages)

Message-ID: <3484552.1626273029@sss.pgh.pa.us>
Permalink:  ../3484552.1626273029@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3484552.1626273029@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, fluca1978@gmail.com
  Subject: Re: statistic target and sample rate
  In-Reply-To: <3484552.1626273029@sss.pgh.pa.us>
  References: <CAKoxK+7TD9848q2wxuwdOw7b5WW+QDza2omScJw5EPJjkVzh+w@mail.gmail.com> <3484552.1626273029@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