1

If I do a VACUUM on a Postgres table (without the FULL option) I know that it should make any free-space available to the database, but not the operating system.

Should it make the freespace available to any database object? or just the table that's been vacuumed?

Laurenz Albe
62k4 gold badges57 silver badges93 bronze badges
asked Sep 17, 2019 at 11:48

1 Answer 1

0

After a VACUUM the table will be as big as before, just more of the space will be free and available for future INSERTs and UPDATEs. In other words, the file won't shrink (1). So the space will not be available for other tables, only for the table that has been vacuumed.

Note (1): Sometimes the file will shrink. If the last block is completely empty after the VACUUM, PostgreSQL will try to truncate all empty blocks off the end of the table.

answered Sep 17, 2019 at 12:49
3
  • So, If I want to do a space-consuming operation on TABLE_A, there's no point in doing a simple VACUUM on TABLE_B, TABLE_C, TABLE_D or TABLE_E because it won't free up any space for TABLE_A ? Commented Sep 17, 2019 at 13:09
  • Yes, exactly. You can use the pg_total_relation_size() function to measure the size of a table and all that goes with it. Commented Sep 17, 2019 at 13:19
  • Thanks, wish I'd known that years ago! That's a big revelation to me, for to long I've assumed that if I needed DB space for a big operation then a simple VACUUM on all the other tables would do the trick. Obviously not! Commented Sep 17, 2019 at 13:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.