Re: New GUC to sample log queries
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Adrien Nayrat <adrien.nayrat@anayrat.info>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Date: 2018-05-31T01:34:19Z
Lists: pgsql-hackers
On 31 May 2018 at 06:44, Adrien Nayrat <adrien.nayrat@anayrat.info> wrote: > Here is a naive SELECT only bench with a dataset which fit in ram (scale factor > = 100) and PGDATA and log on a ramdisk: > shared_buffers = 4GB > seq_page_cost = random_page_cost = 1.0 > logging_collector = on (no rotation) It would be better to just: SELECT 1; to try to get the true overhead of the additional logging code. > I don't know the cost of random() call? It's probably best to test in Postgres to see if there's an overhead to the new code. It may be worth special casing the 0 and 1 case so random() is not called. + (random() < log_sample_rate * MAX_RANDOM_VALUE); this should be <=, or you'll randomly miss logging a query when log_sample_rate is 1.0 every 4 billion or so queries. Of course, it would be better if we had a proper profiler, but I can see your need for this. Enabling logging of all queries in production is currently reserved for people with low traffic servers and the insane. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
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