Is an index required for columns in ON clause?
Posted
by
newbie
on Stack Overflow
See other posts from Stack Overflow
or by newbie
Published on 2011-06-26T01:18:28Z
Indexed on
2011/06/26
8:22 UTC
Read the original article
Hit count: 136
sql
|postgresql
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.
© Stack Overflow or respective owner