Fix high database UPDATE volume
In a couple of places, we were issuing bulk SQL UPDATE statements with
insufficient filtering, which resulted in the database unnecessarily
creating new tuples. This typically didn't change the
externally-visible behaviour, but was inefficient.