Re: New GUC to sample log queries
Vik Fearing <vik.fearing@2ndquadrant.com>
From: Vik Fearing <vik.fearing@2ndquadrant.com>
To: Adrien Nayrat <adrien.nayrat@anayrat.info>,
Michael Paquier <michael@paquier.xyz>
Cc: David Rowley <david.rowley@2ndquadrant.com>,
PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Date: 2018-06-24T18:41:11Z
Lists: pgsql-hackers
Attachments
- sample_rate-3-reviewed.patch (text/x-patch) patch
On 24/06/18 13:22, Adrien Nayrat wrote:
> Attached third version of the patch with documentation.
Hi. I'm reviewing this.
> exceeded = (log_min_duration_statement == 0 ||
> (log_min_duration_statement > 0 &&
> (secs > log_min_duration_statement / 1000 ||
> - secs * 1000 + msecs >= log_min_duration_statement)));
> + secs * 1000 + msecs >= log_min_duration_statement))) &&
> + log_sample_rate != 0 && (log_sample_rate == 1 ||
> + random() <= log_sample_rate * MAX_RANDOM_VALUE);
A few notes on this part, which is the crux of the patch.
1) Is there an off-by-one error here? drandom() has the formula
(double) random() / ((double) MAX_RANDOM_VALUE + 1)
but yours doesn't look like that.
2) I think the whole thing should be separated into its own expression
instead of tagging along on an already hard to read expression.
3) Is it intentional to only sample with log_min_duration_statement and
not also with log_duration? It seems like it should affect both. In
both cases, the name is too generic. Something called "log_sample_rate"
should sample **everything**.
Otherwise I think it's good. Attached is a revised patch that fixes 2)
as well as some wordsmithing throughout. It does not deal with the
other issues I raised.
Marked "Waiting on Author".
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
Commits
-
Use pg_strong_random() to select each server process's random seed.
- 4203842a1cd0 12.0 landed
-
Use a separate random seed for SQL random()/setseed() functions.
- 6645ad6bdd81 12.0 landed
-
Marginal performance hacking in erand48.c.
- 6b9bba2df8d4 12.0 landed
-
Fix latent problem with pg_jrand48().
- e09046641114 12.0 landed
- f256995e33d2 10.7 landed
- d58e01f8abe2 11.2 landed
-
Silence compiler warning
- 9dc122585551 12.0 landed
-
Add log_statement_sample_rate parameter
- 88bdbd3f7460 12.0 landed