Skip to content

refactor: create new queryopt package to target query plan optimizations#2970

Open
barakmich wants to merge 3 commits intomainfrom
barakmich/queryopt
Open

refactor: create new queryopt package to target query plan optimizations#2970
barakmich wants to merge 3 commits intomainfrom
barakmich/queryopt

Conversation

@barakmich
Copy link
Contributor

Description

Before, optimize.go lived in pkg/query and worked on iterator trees. With the introduction of Outlines, it's much more convenient to work on Outlines before compiling an iterator tree.

This creates the new package framework, registry, and ports the existing optimize files, deleting the old ones.

Testing

Testing ported to new package

@barakmich barakmich requested a review from a team as a code owner March 11, 2026 23:26
@github-actions github-actions bot added area/api v1 Affects the v1 API area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Mar 11, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 74.63768% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.84%. Comparing base (9d4d4b7) to head (90a93cb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/query/queryopt/registry.go 56.10% 14 Missing and 4 partials ⚠️
internal/services/v1/permissions_queryplan.go 0.00% 6 Missing ⚠️
pkg/query/canonicalize.go 64.29% 4 Missing and 1 partial ⚠️
pkg/query/advisor.go 40.00% 2 Missing and 1 partial ⚠️
pkg/query/queryopt/caveat_pushdown.go 95.84% 2 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (74.84%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2970       +/-   ##
===========================================
+ Coverage   48.86%   74.84%   +25.99%     
===========================================
  Files         431      498       +67     
  Lines       54679    60781     +6102     
===========================================
+ Hits        26714    45487    +18773     
+ Misses      25251    12133    -13118     
- Partials     2714     3161      +447     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

child := outline.SubOutlines[0]

// Do not push through IntersectionArrow (all() semantics require post-intersection caveat eval).
if child.Type == query.IntersectionArrowIteratorType {
Copy link
Member

Choose a reason for hiding this comment

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

As an improvement for the future, it might be worth add an .Is(...) onto the child that takes in one or more types, and returns true if any match

Type: query.CaveatIteratorType,
Args: outline.Args,
SubOutlines: []query.Outline{sub},
ID: originalID,
Copy link
Member

Choose a reason for hiding this comment

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

is the ID the thing that is carrying the caveat+local context?

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

Labels

area/api v1 Affects the v1 API area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants