Update some queries for pgsql.