Can We Read the Query in the Order We Explain the Job?

Use common table expressions to name meaningful query stages while keeping grain, scope and execution assumptions explicit.

13 sections · 4 questions · 1 coding challenge

1 / 13

Names Made Intermediate Relations Easier to Review

BOTIE

Nested queries let one operation use another’s result, but deeply nested expressions can be awkward to inspect. Common table expressions give those intermediate relations names inside one statement. SQLite added CTE support in its February 2014 release.

This is a language feature for expressing dependencies. Naming closed_jobs does not permanently create a table or promise a particular execution strategy. Its value for our report is that the next stage clearly receives completed work rather than every job in the system.

Sources for this history