0 like 0 dislike
138 views

Please log in or register to answer this question.

1 Answer

0 like 0 dislike
answered by (4k points)  

A first solution is to modify PostgreSQL postgresql.conf configuration file:

Connect to the database server,
open postgresql.conf configuration file,
enable query logging and set maximum execution time to 30 ms:

logging_collector = on
log_directory = 'pg_log'

log_min_duration_statement = 30

Restart PostgreSQL server for logging_collector and log_directory to take effect.
The logs will be written in log_directory under PostgreSQL data directory.

You can decide to print the query plan using these variables (unckeck # to modify):

#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = on
#log_checkpoints = off
#log_connections = off
#log_disconnections = off
#log_duration = off
#log_hostname = off
log_line_prefix = '%t ' 

These settings apply to the whole database server.

A second solution is to log slow queries interactively using an SQL command.

Connect to the database server, open postgresql.conf file and enable query logging and set maximum execution time to 30 ms:

logging_collector = on
log_directory = 'pg_log'

Restart PostgreSQL for settings to take effect.

 

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
...