I'm doing a project that involves a lot of PostgreSQL processing. i.e. a lot of relatively simple queries that UPDATE or INSERT a lot of data. Here are some tweaks I've made to my PostgreSQL setting file (/etc/postgres/9.1/main/postgres.conf) to make postgres a bit better for large, write heavy operations:
shared_buffers = 500MB work_mem = 200MB bgwriter_delay = 2000ms wal_buffers = 16MB checkpoint_segments = 16 effective_cache_size = 1750MB
You will have to restart postgres to make this changes have any effect.
These settings seem to make postgres use a lot more memory, and so you might get an error message like this in the postgres logs (/var/log/postgres/postgres-9.1-main.log)
2011-12-18 18:42:09 GMT FATAL: could not create shared memory segment: Invalid argument 2011-12-18 18:42:09 GMT DETAIL: Failed system call was shmget(key=5433001, size=554434560, 03600). 2011-12-18 18:42:09 GMT HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure the kernel with larger SHMMAX. To reduce the request size (currently 554434560 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections. If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for. The PostgreSQL documentation contains more information about shared memory configuration.
Which I solved with the folling command:
sudo sysctl -w kernel.shmmax=554434560
Which lets programmes use more shared memory (I think).
Comments !