Note: for a join on n tables, there are potentially O(n!) possible trees
The query optimiser aims to find version with lowest total cost.