Skip to content

adapter: prep only once in peek/copy_to optimization#35777

Merged
ggevay merged 1 commit intoMaterializeInc:mainfrom
ggevay:prep-once
Apr 1, 2026
Merged

adapter: prep only once in peek/copy_to optimization#35777
ggevay merged 1 commit intoMaterializeInc:mainfrom
ggevay:prep-once

Conversation

@ggevay
Copy link
Copy Markdown
Contributor

@ggevay ggevay commented Mar 29, 2026

Prepping in two phases made sense before #33533 (where phase 1 is with EvalTime::Deferred), because meaningful things were happening between the two phases, which were benefitting from phase 1 doing at least partial prepping. But after phase 2 was moved earlier in that PR, now the two phases are very close to each other, and the code between them is not sensitive to phase 1's existence. So, this commit just removes phase 1, and then also removes the now-unused EvalTime::Deferred.

Prepping in two phases made sense before
MaterializeInc#33533
(where phase 1 is with `EvalTime::Deferred`)
because meaningful things were happening between the two phases,
which were benefitting from phase 1 doing at least partial
prepping. But after phase 2 was moved earlier in that PR, now the
two phases are very close to each other, and the code between them
is not sensitive to phase 1's existence. So, this commit just
removes phase 1, and then also removes the now-unused
`EvalTime::Deferred`.
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for opening this PR! Here are a few tips to help make the review process smooth for everyone.

PR title guidelines

  • Use imperative mood: "Fix X" not "Fixed X" or "Fixes X"
  • Be specific: "Fix panic in catalog sync when controller restarts" not "Fix bug" or "Update catalog code"
  • Prefix with area if helpful: compute: , storage: , adapter: , sql:

Pre-merge checklist

  • The PR title is descriptive and will make sense in the git log.
  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).

@ggevay ggevay added A-ADAPTER Topics related to the ADAPTER layer A-optimization Area: query optimization and transformation labels Mar 29, 2026
@ggevay ggevay marked this pull request as ready for review March 30, 2026 07:34
@ggevay ggevay requested a review from a team as a code owner March 30, 2026 07:34
@ggevay ggevay requested review from a team, mgree and ohbadiah March 30, 2026 07:37
Copy link
Copy Markdown
Contributor

@mgree mgree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Something I don't understand---likely a problem with my understanding of unmaterializable functions---is why we #33533 only applied to COPY TO and SELECT but not the read-then-write plans for INSERT, UPDATE, or DELETE. But even with that lack of understanding, I agree that we no longer need to do the expr prep twice.

@ggevay ggevay merged commit c0e930f into MaterializeInc:main Apr 1, 2026
122 checks passed
@ggevay
Copy link
Copy Markdown
Contributor Author

ggevay commented Apr 1, 2026

Thanks for the review!

#33533 does apply to read-then-write plans, in that sequence_read_then_write calls sequence_peek, which calls the peek optimizer, where #33533 and the current PR made changes. Does this answer the question?

@mgree
Copy link
Copy Markdown
Contributor

mgree commented Apr 1, 2026

Ah, yes---that makes sense. I saw peek.rs and overfit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ADAPTER Topics related to the ADAPTER layer A-optimization Area: query optimization and transformation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants