Merge jdb's merge optimisations

As requested, breaking the DVV bucket props work into two, independent, PRs. This one merges @jtuple's merge optimisation work (and adds some comments.)