Reputation: 652
Assuming that referential integrity is out of the picture, what are the differences (especially in terms of performance) between a join on 2 indexed columns vs a join on two indexed columns, one of which having been defined as referencing the other?
Upvotes: 2
Views: 1307
Reputation: 24490
It looks like performance gains only come from adding an index; not from the foreign key itself (i.e. the foreign key only provides referential integrity).
http://postgresql.1045698.n5.nabble.com/indexes-on-primary-and-foreign-keys-td2054279.html
You'll probably take a slight performance hit on inserts (and updates involving the foreign key field), as the system will need to validate that the item exists in the referenced table.
Upvotes: 4