Postgres Optimization in JOIN

Join tables together starting with the smallest table (table with less cardinality) speeds things up.

To save resources, one should join tables together starting from the one that has the smallest cardinality whenever possible.

To inspect the cost of the query, append EXPLAIN to the query so that we can get an execution plan.

One could visualize the EXPLAIN results using visualizers such as this one by dalibo.

Planted: by ;

Lei Ma (2020). 'Postgres Optimization in JOIN', Datumorphism, 11 April. Available at: https://datumorphism.leima.is/til/data/postgres.join-begin-with-smallest-cardinality/.