Issue #276: Optimize db_merge() to use 1-2 queries instead of 2-3.

PR for https://github.com/backdrop/backdrop-issues/issues/276.