Postgresql – How to find what tablespace a table/index is in on PostgreSQL


How do I find out what tablespace a table (or index) is in with PostgreSQL (9.3)?

Best Answer

For example, you have a table example_table (optionally in more than one schema):

SELECT tablespace 
FROM pg_tables 
WHERE tablename = 'example_table' [AND schemaname = 'your_schema'];

The same thing for the index example_index:

SELECT tablespace 
FROM pg_indexes 
WHERE indexname = 'example_index' [AND schemaname = 'your_schema'];