Book Image

PostgreSQL Administration Essentials

Book Image

PostgreSQL Administration Essentials

Overview of this book

Table of Contents (14 chapters)

Making log creation more fine grained


Until now, you learned how to configure logs on a per-instance basis. We changed parameters in postgresql.conf globally, and we enjoyed the fact that logging was easy and fast.

However, in some cases, we might want to be a bit more fine grained and more specific about what has to be logged and what can go unnoticed.

Logging selectively

PostgreSQL provides us with some instructions that allow us to set variables (work_mem, time_zone, logging related stuff, and so on) on a per-database basis. This can come in handy if you want to be a bit more selective. Here is how you can change logging for an entire database in your database instance:

test=# ALTER DATABASE test SET log_statement = 'all';
ALTER DATABASE

Of course, we can also do this for a user. The syntax works like this:

ALTER ROLE name [ IN DATABASE database_name ]
   SET configuration_parameter { TO | = }
      { value | DEFAULT }

The following example shows how we can make the hs user in the test database...