Heap storage & bloatsenior🔒 Pro concept

The Free Space Map: how INSERT finds a page with room

Simple terms

You delete a few hundred thousand rows. The file doesn't shrink, which you expected. What you didn't expect is that new inserts keep piling onto the end of the table instead of filling the hole you just made. Each table keeps a small map of how much room is left on every page. DELETE marks rows dead but never touches that map, so as far as Postgres knows there is nowhere to put anything. VACUUM is what updates it. Run that, and the space comes back.

You might be asked

I delete a few hundred thousand rows from a table and the table file on disk doesn't shrink -- fine, I know VACUUM doesn't truncate. But I also notice new INSERTs keep appending to the END of the table instead of reusing the space I just freed, until I run VACUUM. Walk me through the mechanism. What is the Free Space Map and exactly when does it learn about freed space?

TopicThe Free Space Map: how INSERT finds a page with room, why deleted space isn't reused until VACUUM, and the 32-byte category granularity
PostgreSQL17.10 (the 256-category FSM and its 3-level tree are unchanged since 8.4; behavior identical on 12-17)
Tools usedpgi17 lab (PostgreSQL 17.10), pg_freespacemap (pg_freespace), ctid, source @REL_17_10 src/backend/storage/freespace/freespace.c
Last reviewed2026-06-19

Pro concept

Full answer and evidence depth sit behind Pro

You have the question and a plain-English lead. Pro unlocks the short answer, what the docs say, what the code does, the labeled lab evidence or reproduction protocol, how to use it under pressure, and the references.

ProFull answer + evidence depth

Unlock the full breakdown for The Free Space Map: how INSERT finds a page with room

You have the interview question and a plain-English lead. Pro opens the short answer, the manual walkthrough, the source decode, and a 15-line evidence section that states whether it is raw output, a captured run summary, or a protocol to run yourself, plus how to use it under pressure.
  • How you'd answer it, the full senior-level short answer
  • What the docs say, the manual's actual wording, with the citations
  • What the code does, the mechanism decoded from PostgreSQL's own source at a pinned tag
  • Proof from a real run, labeled as raw output, a captured run summary, or a run-it-yourself protocol
  • Using it under pressure, the situation, the call you'd make, what goes wrong, and what people get wrong
  • Version notes, what changed across PostgreSQL releases

Card required. Cancel before day 7 and you are not charged.

Compare plans

How this was verified

The open teaser is the question and a plain-English lead. The short answer, the manual walkthrough, the source decode, the lab evidence, and how to use it under pressure unlock with Pro. Evidence is labeled as raw output, a captured run summary, or a run-it-yourself protocol.

Connected

Where this concept connects

How this concept links across the library, the interview questions that test it, its plain-English glossary definition, and the guided pathways it belongs to. Open the full map to explore further.

Open in the interactive map →