Skip to content

Generate index lookups for filters that appear in lateral joins#3380

Merged
nicktobey merged 3 commits intomainfrom
nicktobey/lateral_index
Jan 15, 2026
Merged

Generate index lookups for filters that appear in lateral joins#3380
nicktobey merged 3 commits intomainfrom
nicktobey/lateral_index

Conversation

@nicktobey
Copy link
Copy Markdown
Contributor

@nicktobey nicktobey commented Jan 15, 2026

This PR enhances the "applyIndexesFromOuterScope" analysis pass to transform filters on tablescans into indexed table lookups, when the table's column is being compared with a column visible from a lateral join.

An example of a query that can be optimized with this change: select x, u from xy, lateral (select * from uv where y = u) uv;

Users don't often write lateral joins, but the engine can transform WHERE EXISTS expressions into lateral joins, and this lets us optimize those too.

Copy link
Copy Markdown
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

LGTM!

@nicktobey nicktobey merged commit 200fcbf into main Jan 15, 2026
8 checks passed
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