Is an index required for columns in ON clause?
- by newbie
Do I have to create an index on columns referenced in Joins?
E.g.
SELECT
  *
FROM
  left_table
INNER JOIN
  right_table
ON
  left_table.foo = right_table.bar
WHERE
  ...
Should I create indexes on left_table(foo), right_table(bar), or both?
I noticed different results when I used EXPLAIN (Postgresql) with and without indexes and switching around the order of the comparison 
(right_table.bar = left_table.foo)
I know for sure that indexes are used for the left of the WHERE clause but I am wondering whether I need indexes for columns listed in ON clauses.