free-space-map

Analyze PostgreSQL Free Space Map tree structure and category encoding.

Updated Jun 1, 2026
One-click install
npx skills add https://github.com/matejformanek/postgres-claude --skill free-space-map
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: free-space-map
Source: https://github.com/matejformanek/postgres-claude/tree/main/.claude/skills/free-space-map
Command: npx skills add https://github.com/matejformanek/postgres-claude --skill free-space-map

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves uncertainty regarding how PostgreSQL tracks free space within heap pages, preventing inefficient storage utilization and helping diagnose why INSERT operations might be extending relations instead of reusing existing space.

Core Features & Use Cases

  • FSM Navigation: Provides deep insight into the 3-level tree structure and category encoding used for space tracking.
  • Debugging: Offers a systematic approach to investigate why INSERTs or COPY operations are not finding available space.
  • Patch Guidance: Assists in implementing new FSM consumers or modifying existing storage logic with proper WAL and locking discipline.

Quick Start

Use the free-space-map skill to analyze the current FSM category encoding for the specified relation and identify potential reconciliation issues.

Frequently Asked Questions about free-space-map

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does PostgreSQL Free Space Map tracking work for heap pages?

PostgreSQL Free Space Map tracking uses a 3-level tree structure with category encoding to monitor available space within heap pages. This mechanism facilitates efficient storage utilization by allowing operations to find and reuse existing space rather than unnecessarily extending relations.

Why are my PostgreSQL INSERT operations extending relations instead of reusing available space?

INSERT operations extend relations when the Free Space Map fails to reconcile available space properly, often due to VACUUM issues or lock protocol conflicts. Debugging the FSM tree structure and category encoding helps identify why space tracking is failing.

How do I debug VACUUM space reconciliation issues in PostgreSQL?

Debug VACUUM space reconciliation by systematically analyzing the Free Space Map category encoding for the target relation. This approach identifies potential reconciliation issues and verifies if VACUUM is correctly updating the FSM tree structure for page reuse.

What locking protocols are required for modifying PostgreSQL storage logic and FSM consumers?

Modifying PostgreSQL storage logic requires strict lock protocols for safe interaction with heap and index storage. Proper WAL and locking discipline must be maintained when implementing new FSM consumers to prevent data corruption and ensure space tracking accuracy.

What are the limitations of PostgreSQL FSM category encoding for space tracking?

FSM category encoding limitations stem from its 3-level tree structure granularity, which may not capture exact byte-level free space. When space reconciliation fails, INSERT or COPY operations cannot find available space, causing unexpected relation extension instead of page reuse.