3 ms·
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
by zeroimpl 5y ago
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.
- ComputerGuru 5y agoIsn’t the source almost always an indexed primary key?
- zeroimpl 5y agoNo. The target is normally a primary key but the source is not. The source is rarely even unique.