Overwrite only if the incoming version is fresher
The products catalog is updated from two different sources, and both write the same row — but with different updated_at stamps. If you just overwrite on every arrival, you risk clobbering fresh data with stale data (the older source can arrive slightly later and win the race).
Implement an upsert that fires only if the incoming row is newer than the existing one by updated_at, otherwise it's ignored. After all updates each product's updated_at should be the maximum across every insertion attempt.
Just INSERT/UPDATE/DELETE — no trailing SELECT needed.
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in