Hacker News new | ask | show | jobs
by AtNightWeCode 637 days ago
A common mistake I see is that people think foreign keys will automatically create indexes. Missing indexes is a general problem in SQL. Missing indexes on columns that are in foreign keys are even worse.
1 comments

In some RDBMS a foreign key will automatically create an index: https://dev.mysql.com/doc/refman/8.4/en/create-table-foreign...

I think this falls under the read the documentation fully point.

Edit: It occurs to me you likely meant on the column itself rather than on the referenced column. I don't have an example that does that.

Both columns needs the correct type of index. The best thing to do is to use a tool that scans for missing indexes.