go to pgtune,
input your hardware and desired configuration and copy the recommended parameters at the bottom of your portgresql .conf file.
honestly after tweaking the setting with no much better performance, I changed the db to a server on an SSD, and the performance changed completely. So the conclusion is that the hard drive has a great importance on the query speed for large databases.
configure checkpoints for large dbs
\set AUTOCOMMIT off
wal_level = minimal