May 2018
Intermediate to advanced
576 pages
30h 25m
English
A tablespace is just a directory where we store PostgreSQL data files. We use symbolic links from the data directory to the tablespace.
We exclude TOAST tables because they are always in the same tablespace as their parent tables, but remember that TOAST tables are always in a separate schema. You can exclude TOAST tables using the relkind column, but that would still include the indexes on the TOAST tables. TOAST tables and TOAST indexes both start with pg_toast, so we can exclude those easily from our queries.
The preceding query needs to be complex because pg_class entry for an object will show reltablespace = 0 when an object is created in the database's default tablespace. So if you directly join pg_class and pg_tablespace ...