> you should increase shared_memory to 40GB. General philosphy is to allocate 80% of system memory to shared_memory
Uhm...
80% is too much, likely:
https://www.postgresql.org/docs/9.5/static/runtime-config-resource.html
Bye,Chris.