Last week I was made aware that we had some foreign keys not backed by indexes in the system we’re developing at work. Foreign keys in postgres must be backed by an index only on the side they refer to, not necessarily the side they refer from. Here’s an example: createtableauthor(idbigintgeneratedalwaysasidentityprimarykey,nametextnotnull);createtablebook(idbigintgeneratedalwaysasidentityprimarykey,authorbigintnotnullreferencesauthor(id),titletextnotnull); In this example, there’s a fo...