Postgresql large result set handling