This method should only be performed by advanced computer users who are familiar with PostgreSQL configurations.
-
Open 'My Computer' and browse to your C:\Program Files\PostgreSQL\8.x\data directory and make a copy of "postgresql.conf" as a backup.
-
Open the original postgresql.conf file in Notepad or go Start->Programs->PostgreSQL->Configuration Files->Edit postgresql.conf
-
Find the following configurations:
-
"shared_buffers = xMB" and set this number equal to about 1/4 of your total memory. That is, if you have 2GB of RAM, set this to 512MB.
-
"work_mem = xMB" and set this value equal to about 1/64 of your total memory. That is, if you have 2GB of RAM, set this to 32MB.
-
"maintenance_work_mem = xMB" and set this value equal to about 1/16 of your total memory. That is, if you have 2GB of RAM, set this to 128MB.
Note: work_mem and maintentance_work_mem by default are commented out in the configuration file (e.g. has a # in front of them), so make sure to remove those symbols to put the changes into effect.
-
File->Save to save the changes
-
Go Start->Programs->PostgreSQL->Reload Configuraitons for the changes to take effect.
VERY IMPORTANT:
The exact configuration values are more of an art than a science. While these values will work for most users, it could potentially cause problems for other users. If you are experiencing issues, lower the values or follow the "Recommend Method" above.
Vista and Windows 7 Users:.
If you receive an error message saying that the file can't be written when you try to save the configuration file after having made these changes, make sure that you're running as administrator. To do that, go Start->Programs->PostgreSQL->Configuration Files and now right-click on "Edit postgresql.conf" and choose "Run as administrator".
Linux Users:
If you have PostgreSQL running on a Linux machine, you may receive the following error message when changing these settings:
-
EDT DETAIL: Will not verify client certificates.
-
EDT FATAL: could not create shared memory segment: Invalid argument
-
EDT DETAIL: Failed system call was shmget(key=5432001, size=549330944, 03600).
If you get this message, you need to edit /etc/sysctl.conf and add the following line:
kernel.shmmax = N
Where you need to replace N with a number larger than the one you just set for "shared_buffers" in the postgresql.conf. Now, this setting uses bytes and not megabytes. If you set shared_buffers to 512 MB, a working value for the kernel.shmmax would be 550000000. You can also see the "size=X" mentioned in the error message above, this is the value that you need to exceed. After having done this change you need to run sysctl -p to load the settings.