Running PostgreSQL in Power Saving Mode16 October, 2019written by Bill

Have you heard about it? Running in power saving mode, is it a feature? Actually, it is only for for laptop though. Why for laptop? Let say if your PostgreSQL is only used very sporadically or has periods of total inactivity, like when you're developing an application on your laptop or computer.

Just for your information, i found this tips from a book but i forgot the title.

How to do it?

We all know that a database server mostly does nothing at all if there are no active clients. So, to minimize server activity, set the following paramaters in the postgresql.conf file:

  • autovacuum = off
  • wal_writer_delay = 10000 # milliseconds
  • bgwriter_delay = 10000 # milliseconds

NOTE: please backup your default or current configuration before doing it.

As you can see, we turned off the autovacuum, but why? PostgreSQL has so many awesome features and autovacuum is one of them. I do recommend to use it in production only, and for development, we usually not doing heavy activity or even having a large data on our database, so it should be okay to turn it off.

The WAL writer process wakes up by default every 200 milliseconds. The maximum setting is also 10 seconds. This setting cannot be disable though, if there's no write activity then no work will be performed.

It is actually just a tunning, not a feature. It won't impact the performance while you're doing a development. I'm still using this setting on my laptop though.

Well, i hope this article is useful for you, and i highly recommend you guys to read the PostgreSQL Official Documentation: Config Settings for more details.

postgresql

Reading Time1 min



© Repodev - Muh Ibnu Habil Hanafi