8

I suddenly found found my PostgreSQL out of space. It's a tmp instance running on ram disk. Limited space (around 800M) allowed. Data are not actually stored on it, all table will be dropped after some calculation done.

I checked the folder and found tons of data under base folder:

$ du -h
6.0M    ./pgsql_tmp
706M    ./16384
6.0M    ./12780
6.0M    ./12772
6.0M    ./1
730M    .

My questions are:

  • What is inside that folder?
  • Any chance I can clean it out?
1

1 Answer 1

12

This folder is where PostgreSQL keeps all the data you insert on your databases (see PostgreSQL Database File Layout). Each sub-directory is used by a database in you cluster, the files inside them are the actual data of the relations (tables, indexes, sequences, ...).

So, your answer is no! You cannot clean it out, and if you do so, you will lose your data and PostgreSQL server will stop with a panic.

Basically, only files inside the pg_log directory (if any) can be removed. A side note, do not, ever remove files inside pg_xlog, it is not useless as the name may suggest (you didn't ask for it, but I saw happening sometimes).

Tips to solve your problem:

There are some things you can do to use less space in your case, like:

  1. Use another (not in RAM) tablespace for some tables or databases;
  2. Run a VACUUM FULL. But notice that you will need some temporary space to do that, so you can't do it while you are really out of space;
  3. Move pg_xlog to another location;
  4. As you said it is a temporary database, try to remove some indexes that are not been used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.