November 2019
Beginner to intermediate
470 pages
11h 59m
English
After verifying that your queries are actually correct from a business point of view, it makes sense to check what the optimizer can do to speed up your outer joins. The most important thing is that PostgreSQL can, in many cases, reorder inner joins to speed things up dramatically. However, in the case of outer joins, this is not always possible. Only a handful of reordering operations are actually allowed:
(A leftjoin B on (Pab)) innerjoin C on (Pac) = (A innerjoin C on (Pac)) leftjoin B on (Pab)
Pac is a predicate referencing A and C, and so on (in this case, clearly, Pac cannot reference B, otherwise the transformation is nonsensical):