Re: statistic target and sample rate - Mailing list pgsql-general

From Tom Lane
Subject Re: statistic target and sample rate
Date
Msg-id 3484552.1626273029@sss.pgh.pa.us
Whole thread Raw
In response to statistic target and sample rate  (Luca Ferrari <fluca1978@gmail.com>)
List pgsql-general
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=0c9591415e4b97dd5c5e693af1860294284a1575;hb=HEAD#l1919

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



pgsql-general by date:

Previous
From: Laura Smith
Date:
Subject: Re: returning setof from insert ?
Next
From: Sasha Aliashkevich
Date:
Subject: ERROR: cannot freeze committed xmax