Postgres master

**NOT INTENDED FOR MERGE YET, JUST DISCUSSION**

@jennyd and I are going to sit down and talk this through face-to-face, but other comments (particularly from @issyl0 and @fatbusinessman) should go here. We're aiming for merge tomorrow prior to postgres transition on Tuesday 28th.

Rebased out.