DEV Community

Chiazam Ochiegbu
Chiazam Ochiegbu

Posted on

PostgreSQL Optimization: wal_buffers and wal_sync_method

wal_sync_method

This parameter defines the way Postgres will force WAL updates out to disk. By default the system will use “fdatasync”. However it is better to have it set to as “fsync_writethrough” if possible, it is considered to be safe and efficient.

random_page_cost

By default in Postgres, the random disk access is considered 4 times slower than sequence disk access. Base on this estimation, the query planner will decide whether it will be faster by using table scan than index scan or vice versa. Depending on the hardware, it is suggested to lower this number when fast disks are use, then query planner will have a higher chance to use index scan. With current hardware, most Postgres database administrators would prefer to have it with value of 2. However, in case a query planner is making bad decisions, this should not be the first place to look for answers. How autovacuum works is normally the factor that affects the decision of query optimizer.

Top comments (0)