You should set autovacuum on. If it is turned off (which is the default) it will require manual vacuuming and analyzing to be performed.
You can run vacuuming by:
VACUUM (VERBOSE, ANALYZE)
You can set auto vacuuming on by the below commands. You will need to modify the “postgresql.conf” file for this. Windows is located “C:\Program Files\PostgreSQL\9.4\data\postgresql.conf” and on Ubuntu it is “/etc/postgresql/9.4/main/postgresql.conf”. In the off chance that it isn’t then run the below first.
find / -type f -name "postgresql.conf"
Locate the following line of text “# AUTOVACUUM PARAMETERS” and apply the following. You should note that turning on automatically will also run “VACUUM ANALYZE” command to update statistics.
autovacuum = on (remove #) autocavuum_analyze_threshold = 100 autovacuum_vacuum_threshold = 100 track_counts = on
Now you will need to restart postgresql service.
Ubuntu:
/etc/init.d/postgresql restart invoke-rc.d postgresql restart
Windows:
services.msc restart service "postgresql-x64-9.4"