Reputation: 324650
Very simple question: Which is more efficient?
DELETE
query on a parent table, followed by a DELETE
query on a child tableDELETE
query on a parent table that results in a foreign key deleting rows from a child tableTo explain further, I'm working with very large tables (holding a few million rows), and I'm just wondering if the integrity offered by foreign keys is worth the extra work that MySQL has to do, over just remembering to update/delete child tables. I'd like to know before I actually go ahead and update to use foreign keys ;)
Upvotes: 4
Views: 90
Reputation: 310915
Whatever you think you can code yourself, the database can do at least as well, and without having to use the network to do it.
Use the foreign keys.
Upvotes: 3