|
|
|
|
|
by hu3
753 days ago
|
|
Correct me if I'm wrong but, FKs are rarely created for existing columns. You usually create the column and the FK in the same script. And usually starting with a NULL value for existing rows. And if it's a new table then there's no rows anyway. So the most common operations when creating FK's aren't expensive as far as I know. You know what's expensive? Creating an index on a large table because you or your RDMS forgot to create the index when the FK was created and now JOINS are crawling to halt. |
|
To be clear I 100% agree that adding indexes later is extremely painful. A little care when first creating tables goes a long way, and I’ve never seen a database fall over due to preemptive over-indexing but I’ve seen countless do so thanks to being underindexed.
Still, taking a DDL operation which is presumed to be essentially instantaneous and adding a default behavior that requires locking completely separate tables for a potentially-lengthy update does give me pause.