Update backend stats query to work with postgres 9.2