Cannot enable log_min_duration_statement in YugabyteDB YSQL

82 Views Asked by At

[Question posted by a user on YugabyteDB Community Slack]

Testing adding sql long query logging but it appears prepare statement executions are not following the min_duration gflags. The output in the postgres log also is not showing the duration which might be part of the issue? Or I am just misunderstanding the documentation? Version 2.8.0.0b37. 5 tservers/3 masters in universe. tserver flags used in tserver startup:

--ysql_log_min_duration_statement=60000
--ysql_log_statement=all

The log:

2022-03-04 16:28:53.595 UTC [1548953] LOG:  execute lrupsc_349_3:
                UPDATE table SET
                        f1    = $1,
                        f2    = $2,
                        f3 = $3
                WHERE
                        f4 = $4
2022-03-04 16:28:53.595 UTC [1548953] DETAIL:  parameters: $1 = 'Running', $2 = 'worker-0', $3 = '2022-03-04 16:28:53.597931+00', $4 = 'c8h3shbp695ddkmko6e0'
f4 is table pk

I’m looking to ONLY show ysql statements that exceed the log_min_duration_statement duration.

1

There are 1 best solutions below

0
On BEST ANSWER

I would suggest to set only the log_min_duration_statement to desired value. That should be sufficient for the use case.

yugabyte=# set log_min_duration_statement = 1;
SET
yugabyte=# insert into t values (4);
INSERT 0 1
yugabyte=# show log_statement;
 log_statement
---------------
 none
(1 row)

Postgres logs –

2022-03-04 19:23:29.522 UTC [22684] LOG:  duration: 27.310 ms  statement: insert into t values (4);

ysql_log_statement and ysql_log_min_duration_statement are independent flags. The only dependency being if statement is logged by ysql_log_statement already, then won’t be repeated again even if it qualifies based on ysql_log_min_duration_statement.