Postgresql different configuration for different tablespace

optimizationpostgresql

I'm configuring new server with both SSD/HDD disk with ubuntu 18.04. I've installed system in SSD and created two different tablespaces one in ssd and one in hdd. I would like for configuration purposes put:

HDD

random_page_cost 4
effective_io_concurrency 2

SDD

random_page_cost 1.1
effective_io_concurrency 200

for each correct tablespace. Is it possible or are there some suggestions?

Best Answer

See the docs for ALTER TABLESPACE.

Since version 9.6, you can set "effective_io_concurrency" on a per-tablespace basis. You can do so for "random_page_cost" long before 9.6.

These changes have to be made inside the database itself. For discoverability purposes, I would also add a comment inside postgresql.conf near the global settings, saying that they have been tweaked per tablespace. Otherwise, it is not very obvious that these changes have been made.