6 ms·
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 colu
by AtNightWeCode 2y 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.
- TheCycoONE 2y agoIn some RDBMS a foreign key will automatically create an index: https://dev.mysql.com/doc/refman/8.4/en/create-table-foreign-keys.html#foreign-key-restrictions 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.
- AtNightWeCode 2y agoBoth columns needs the correct type of index. The best thing to do is to use a tool that scans for missing indexes.