Usage of disk space by temporary data
In addition to ordinary persistent tables, you can also create temporary tables.
PostgreSQL may use temporary files for query processing if it can't fit all the necessary data into memory.
So, how do you find out how much data is being used by temporary tables and files? You can do this by using any untrusted embedded language, or directly on the database host.
Getting ready
You have to use an untrusted language, because trusted languages run in a sandbox, which prohibits them from directly accessing the host filesystem.
How to do it…
Perform the following steps:
- First, check whether your database defines special tablespaces for temporary files, as follows:
SELECT current_setting('temp_tablespaces');
- As explained later on in this recipe, if the setting is empty, it means that PostgreSQL is not using temporary tablespaces, and temporary objects will be located in the default tablespace for each database.
- On the other hand, if
temp_tablespaces
has one or more tablespaces...