Usage of disk space by temporary data

In addition to ordinary stable tables, you can also create temporary tables.

Also, PostgreSQL may use temporary files for query processing if it can't fit all the necessary data into the memory.

So, how do you find out how much data is used by temporary tables and files? You can do this 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:

  1. First, check whether your database defines special tablespaces for temporary files, as follows:
    SELECT current_setting('temp_tablespaces');
    

    As explained later ...

Get PostgreSQL 9 Administration Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.