开发者

How can I log progress of multiple sql queries in a single JdbcTemplate execute() and PostgreSQL

I have a SQL script with many statements which I execute using JdbcTemplat开发者_运维百科e.execute(). Some queries are slow and I'd like to write progress of the whole script to the logs.

As it stands, I only get logs written once all the statements have completed.


There is another way to get what you want. Use the PostgreSQL server log. Set the options in the config file postgresql.conf and reload, or set parameters per session like this:

Log every single SQL statement:

set log_statement = 'all';

Or hunt for slow queries in particular, for example: everything that takes longer than 1000 ms:

set log_min_duration_statement = 1000;

The manual about logging-parameters:

log_statement (enum)

Controls which SQL statements are logged. Valid values are none (off), ddl, mod, and all (all statements).

If you log everything remember to turn it off afterwards or the log files may grow huge.

log_min_duration_statement (integer)

Causes the duration of each completed statement to be logged if the statement ran for at least the specified number of milliseconds. Setting this to zero prints all statement durations. (...)

The manual on how to set parameters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜