Issue #276: Optimize db_merge() to use one fewer query on updates.