Skip to content

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

Merged
barakmich merged 4 commits intomainfrom
barakmich/queryopt
Mar 16, 2026
Merged

refactor: create new queryopt package to target query plan optimizations#2970
barakmich merged 4 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.80%. Comparing base (b554261) to head (9e52f5b).

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 ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2970      +/-   ##
==========================================
- Coverage   74.83%   74.80%   -0.02%     
==========================================
  Files         497      497              
  Lines       60621    60656      +35     
==========================================
+ Hits        45359    45367       +8     
- Misses      12103    12126      +23     
- Partials     3159     3163       +4     

☔ 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.

miparnisari
miparnisari previously approved these changes Mar 12, 2026
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?

@barakmich barakmich merged commit e49cc12 into main Mar 16, 2026
69 of 78 checks passed
@barakmich barakmich deleted the barakmich/queryopt branch March 16, 2026 17:06
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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