Skip to content

Optimize repeated queryplan term analysis#242

Closed
carli2 wants to merge 1 commit intomasterfrom
codex/keyed-term-dedup
Closed

Optimize repeated queryplan term analysis#242
carli2 wants to merge 1 commit intomasterfrom
codex/keyed-term-dedup

Conversation

@carli2
Copy link
Copy Markdown
Contributor

@carli2 carli2 commented Apr 18, 2026

What

  • replace deep equal? dedup in hot scalar/domain helper paths with serialized string keys
  • pre-group aggregate scalar parts by alias instead of rescanning the same join-condition list per alias
  • memoize top-level pure AST analysis helpers for repeated planner traversals:
    • extract_tblvars
    • extract_columns_for_tblvar
    • extract_outer_columns_for_tblvar
    • unnest_expr_outer_refs

Why

Large app queries compile through repeated planner traversals over the same nested scalar and permission terms. This PR reduces repeated term analysis without changing lowering semantics.

Validation

  • python3 run_sql_tests.py tests/32_expr_subselects.yaml
  • python3 run_sql_tests.py tests/117_dashboard_unnesting_regressions.yaml
  • make test was started locally and ran through the broad suite without failures in the observed output; CI will provide the definitive full run

Cold benchmark

Fresh restart / fresh in-memory queryplan cache, same copied app data and badge query:

  • master: 28.78s
  • this branch: 29.09s

So the branch is currently correctness-safe but benchmark-neutral on that exact homepage badge query. I am still opening it because the optimization direction is general and the changes are isolated enough for CI review.

@carli2 carli2 marked this pull request as ready for review April 18, 2026 13:29
@carli2
Copy link
Copy Markdown
Contributor Author

carli2 commented Apr 18, 2026

nonsense

@carli2 carli2 closed this Apr 18, 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.

1 participant