We have a large query known to take long time and it runs frequently. We are only interested in logging duration of this query, but not the full query, which is about 10-20M characters long, and taking up a lot of disk space.
Currently in /var/lib/pgsql/9.6/data/pg_log/postgresql-2017-09-01.log
:
2017-09-01 01:00:12.511 UTC user@dbname 25304 x.x.x.x LOG: duration: 966.603 ms statement: INSERT INTO table_name (col1,col2,col3...) VALUES (val1)(val2)(val3)....
What we hope to achieve:
- Still log the duration, but maybe only log the first xxx (say, 200) characters of the statement.
- We can potentially increate log_min_duration_statement so this query won't be logged at all, but we have other queries we hope to log too, so that's not a good solution.
- If log the partial query is not possible, can we only exclude this query from being logged, or exclude this table from being logged, and still log other queries longer than log_min_duration_statement?