Skip to content

refactor: track required columns for from_many subqueries - #282

Closed
jechol wants to merge 3 commits into
ash-project:mainfrom
jechol:perf/collect-projection-fields
Closed

jechol wants to merge 3 commits into
ash-project:mainfrom
jechol:perf/collect-projection-fields

Conversation

@jechol

@jechol jechol commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

This replaces #281, following the suggestion to collect required columns during query construction.

Field references and correlation keys are recorded as expressions and joins are built. The final pass uses this metadata to narrow implicit from_many? selections, without re-scanning expression ASTs. When dependencies cannot be tracked reliably, the original selection is retained.

I've updated the benchmark to compare the upstream base, #281's AST scan, and this implementation with identical dependencies and data.

For the latest Payment query:

The motivation remains easier-to-read SQL; PostgreSQL already prunes unused projections.

Execution integration is in ash-project/ash_postgres#919.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@jechol
jechol marked this pull request as ready for review November 12, 2026 14:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T14:44:52.441290Z 20005f4 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20005f4577

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/aggregate.ex Resolved
Comment thread lib/join.ex Resolved
@zachdaniel

Copy link
Copy Markdown
Contributor

Honestly...I'm just not convinced this is worth the maintenance burden 😓. This is quite complex just for more readable SQL.

jechol commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Keeping this dependency tracking correct across all query-building paths is a lot to maintain for SQL readability alone. I'll close this and the related PRs. Thanks for reviewing.

@jechol jechol closed this Nov 14, 2026
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.

2 participants