Improve detection of inserting vs updating records