3 ms·
In the case that you use your database for more than just a persistence backend to your Rails app (blasphemy, I know, but odds are your Rails app is generating
by philwelch 13y ago
In the case that you use your database for more than just a persistence backend to your Rails app (blasphemy, I know, but odds are your Rails app is generating transactional data that's worthy of analysis you need real SQL for and not just ActiveRecord), indexing foreign keys is still worthwhile because sometimes you'll join the same foreign key in two different tables without ever needing to join in the table they normally map to.
- asdasf 13y agoWhat you describe doesn't need an index on the foreign key, that's the point I was making.
- philwelch 13y agoIf you designate it as a foreign key in the schema it'll just use the PK index even if you don't join that table in at all? Wait, how does that even work? Does the PK index include the foreign key rows then? That's an awesome feature.