I've been digging the Internet over and over and couldn't find any reasonable answer. What's the difference between inlining and flattening in SQL query? I do actually use both interchangeably, eventually they lead to the same result - a big single query not many atomic ones. But maybe there is a difference in definitions? For instance inline refer only to functions and flattening means convert subquery to join only as stands here? But in another source one can find an example of completely different transformation.
Asked
Active
Viewed 96 times
1 Answers
1
I guess there may be slight differences in how “inlining” and “flattening” are defined by people, but the way these terms are normally understood in the PostgreSQL community is that inlining is to pull the definition of a LANGUAGE sql
function into the main query, and flattening is to transform a subquery or view into something else than a subquery, for example a join.

Laurenz Albe
- 209,280
- 17
- 206
- 263
-
thank you Laurenz, but with flattening - does it have to be a join? I've seen some definitions that say it is a join but other sources claim it can be another construct: https://my.vertica.com/docs/7.0.x/HTML/Content/Authoring/ProgrammersGuide/Queries/FlatteningFROMClauseSubqueriesAndViews.htm – Borys Feb 06 '18 at 08:30
-
1Point taken. I have edited the answer to be more general. – Laurenz Albe Feb 06 '18 at 11:45