Skip to content

A query for detecting cyclic joins in QL#22093

Open
josefs wants to merge 1 commit into
mainfrom
josefs/cyclicJoins
Open

A query for detecting cyclic joins in QL#22093
josefs wants to merge 1 commit into
mainfrom
josefs/cyclicJoins

Conversation

@josefs

@josefs josefs commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

A query for detecting cyclic joins. This is an artifact of me trying to understand joins in QL better. It's a one-off query but I though it could be nice to save it for posterity.
There are plenty of cyclic joins in QL, but based on a preliminary analysis by copilot, we spend approximately 0% of time in these joins.

len cycles
3 7,065
4 4,284
5 1,417
6 721
7 185
8 102
9 48
10 41

This query only has cycle lengths up to 10. There isn't a way to write a general query to catch all lengths of cycles (copilot says so, and I have no idea what such a query would even look like so I agree).

@josefs josefs requested review from aschackmull and kaspersv June 30, 2026 15:03
@josefs josefs changed the title josefs/cyclicJoins A query for detecting cyclic joins in QL Jun 30, 2026
@josefs josefs marked this pull request as ready for review June 30, 2026 15:03
@josefs josefs requested a review from a team as a code owner June 30, 2026 15:03
Copilot AI review requested due to automatic review settings June 30, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new QL performance-oriented query (CyclicJoin.ql) intended to locate non-recursive predicate bodies and query where clauses whose join graph contains irreducible cycles (triangles or chordless cycles of length 4–10), as an aid to understanding / auditing join structure.

Changes:

  • Introduces ql/ql/src/queries/performance/CyclicJoin.ql, implementing detection/reporting of cyclic joins up to length 10.
  • Reports the enclosing scope and a descriptive message including cycle length and involved variables.
Show a summary per file
File Description
ql/ql/src/queries/performance/CyclicJoin.ql New query that enumerates irreducible cyclic joins (3–10) within predicate/select scopes and reports them.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread ql/ql/src/queries/performance/CyclicJoin.ql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants