Use a temporary table to avoid doing insert / update.