3
Joins
Join types are not SQL joins
inner, left, right, full, and cross joins, along with 'in' and 'exists' — logical
operations
Join types are the implementation mechanism
It's not tables that are joined, but sets of rows.
may originate from any node in the execution plan tree
Row sets are joined in pairs
The order of joins is crucial for performance.
The order within the pair is typically important.
Simply retrieving data using the discussed access methods isn't enough;
you also need to know how to join them. PostgreSQL offers several methods
for this.
Join methods are algorithms designed to combine two row sets. These
methods also implement other SQL constructs, such as EXISTS. Avoid
confusing the two: SQL joins are logical operations on two sets, whereas
PostgreSQL's join methods are the actual implementations that consider
performance.
It's common to hear that tables are joined. This is a convenient
simplification, but in reality, row sets are what get joined. These sets can be
directly retrieved from the table (via one of the access methods), but they
can also, for instance, result from joining other row sets.
Finally, row sets are always joined pairwise. The order in which tables are
joined typically doesn't affect the query result (such as a join with b or b join
with c), but it can greatly impact performance. As we'll see later, the order in
which two row sets are joined matters (e.g., a join b versus b join a).