Out of the box, PostgreSQL is configured to run on very limited hardware. On a modern VPS with 2–8GB of RAM you can get significantly better performance by adjusting a handful of settings in postgresql.conf.
Memory settings
shared_buffers = 1GB
effective_cache_size = 3GB
work_mem = 16MB
maintenance_work_mem = 256MB
shared_buffers is Postgres's own cache — set it to 25% of RAM. effective_cache_size is a hint to the query planner about total available memory — set it to 75% of RAM.
Write performance
wal_buffers = 16MB
checkpoint_completion_target = 0.9
default_statistics_target = 100
Connection settings
max_connections = 100
Use pgtune.leopard.in for a starting point — enter your server specs and it generates a complete config.