postgresql: first cuts based on sameersbn/postgresql