PostgreSQL allows configuring the settings of log queries that are running for more than a certain duration using some parameters. This helps admins in understanding the queries that need to be optimized to improve the overall application performance. In this recipe, we shall discuss the steps involved in enabling the logging of time-consuming queries in PostgreSQL.
Getting ready
It is always important to know that logging additional information to PostgreSQL logs causes more disk writes and uses a lot of disk space. For this reason, it is important to monitor the disk usage and the IOPS increase when any extensive logging has been enabled. It is also important to segregate logs and data across different disks. This way, none of the logging-specific writes cause any I/O saturation for the data directory that contains the database objects.
How to do it...
We will initiate the logging process using the following steps:
- Ensure that logging_collector...