News for hackers. Stuff that matters.
Re:A terrible schema from a clueless programmer by zeroimpl on Sunday November 07, 2021 @03:45PM (#29143357)
Yeah I’ve run into this a few times. In Postgres, you can’t add a foreign key referencing columns that aren’t indexed. I assume this is for performance reasons so inserts/updates are efficient, but there is no such check that the source columns are also indexed, so updates/deletes on the referenced table can be terribly slow.
Re:A terrible schema from a clueless programmer by ComputerGuru on Monday November 08, 2021 @12:29AM (#29146337)
Isn’t the source almost always an indexed primary key?
Re:A terrible schema from a clueless programmer by zeroimpl on Tuesday November 09, 2021 @04:37PM (#29167832)
No. The target is normally a primary key but the source is not. The source is rarely even unique.