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?
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.
Unlock the full breakdown for The Free Space Map: how INSERT finds a page with room
- 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.
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.
Part of these pathways
Related concepts