Problem with pg database ordering