aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/sampling.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-01-15 11:02:09 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-01-15 11:14:39 -0300
commita166d408eb0b35023c169e765f4664c3b114b52e (patch)
tree1c432fec482f436cb6611988bff055ff5e27015d /src/backend/utils/misc/sampling.c
parent16a4a3d59cd5574fdc697ea16ef5692ce34c54d5 (diff)
downloadpostgresql-a166d408eb0b35023c169e765f4664c3b114b52e.tar.gz
postgresql-a166d408eb0b35023c169e765f4664c3b114b52e.zip
Report progress of ANALYZE commands
This uses the progress reporting infrastructure added by c16dc1aca5e0, adding support for ANALYZE. Co-authored-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Co-authored-by: Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp> Reviewed-by: Julien Rouhaud, Robert Haas, Anthony Nowocien, Kyotaro Horiguchi, Vignesh C, Amit Langote
Diffstat (limited to 'src/backend/utils/misc/sampling.c')
-rw-r--r--src/backend/utils/misc/sampling.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/misc/sampling.c b/src/backend/utils/misc/sampling.c
index daf75ee5d97..361c15614e7 100644
--- a/src/backend/utils/misc/sampling.c
+++ b/src/backend/utils/misc/sampling.c
@@ -32,8 +32,10 @@
* Since we know the total number of blocks in advance, we can use the
* straightforward Algorithm S from Knuth 3.4.2, rather than Vitter's
* algorithm.
+ *
+ * Returns the number of blocks that BlockSampler_Next will return.
*/
-void
+BlockNumber
BlockSampler_Init(BlockSampler bs, BlockNumber nblocks, int samplesize,
long randseed)
{
@@ -48,6 +50,8 @@ BlockSampler_Init(BlockSampler bs, BlockNumber nblocks, int samplesize,
bs->m = 0; /* blocks selected so far */
sampler_random_init_state(randseed, bs->randstate);
+
+ return Min(bs->n, bs->N);
}
bool