Skip to content

design: correct the fetch plan's ordering - #145

Merged
jdatcmd merged 1 commit into
mainfrom
design/fetch-plan-order
Jul 25, 2026
Merged

design: correct the fetch plan's ordering#145
jdatcmd merged 1 commit into
mainfrom
design/fetch-plan-order

Conversation

@jdatcmd

@jdatcmd jdatcmd commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #144, design document only.

I checked the call path before writing the piece the plan listed first, and it does not do what the plan assumed. The uniqueness check reaches columnar_index_fetch_tuple through core's table_index_fetch_tuple_check, which builds a slot, calls the ordinary fetch callback, and throws the slot away. The access method cannot distinguish that from a real fetch, so a needed-columns bitmap cannot help the caller it was aimed at.

Reordered: the statement-scoped decoded-group cache goes first, since it helps every caller including the check. Also recorded that GetCurrentCommandId(false) is enough to scope the cache to a statement, so a pgcolumnar.vacuum in the same transaction invalidates it without a dedicated hook.

…he check

The plan put a needed-columns bitmap first, on the argument that the uniqueness
check only needs the key columns. Reading the call path before writing any of it
says otherwise: core's table_index_fetch_tuple_check creates a slot, calls
table_index_fetch_tuple, and discards it, so the access method cannot tell that
call from a real fetch and columnar_index_fetch_tuple fills every column either
way. The caller that would benefit most has no way to declare what it needs.

The statement-scoped decoded-group cache moves first, since it is the only piece
that helps every caller. Also records that GetCurrentCommandId is enough to scope
it, so an in-transaction vacuum invalidates the entry without a dedicated hook.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012uKWWwBDt5TWWS5DR2tzDb
@jdatcmd
jdatcmd merged commit b4b1159 into main Jul 25, 2026
@jdatcmd
jdatcmd deleted the design/fetch-plan-order branch July 25, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant