Fix some queries for pg.