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.
You have to use an untrusted language, because trusted languages run in a sandbox, which prohibits them from directly accessing the host filesystem.
Perform the following steps:
As explained later ...