Postgresql – Postgres use multiple tablespaces in a single database


Is it possible to allocate tables directly to tablespaces within a single database/schema in postgres? Based on the docs, tablespace is a create database argument, but are there any workarounds?

Best Answer

Yes it's possible.

As documented in the manual you can specify a tablespace when creating a table.

However, tablespaces are rarely used in Postgres as they don't really provide any advantage.

One of the few reasons to use them is, when you can't easily expand the size of your filesystem where the data directory is located.