Look up existing IDs before writing new rows.